チャートのワークシートを取得
Contents
[
Hide
]
チャートのリファレンスからワークシートにアクセスしたい場合があります。 Aspose.Cells はChart.ワークシートチャートを含むワークシートの参照を返すプロパティ。
次の例は、Chart.ワークシート財産。このコードは、最初にワークシートの名前を出力し、次にワークシートの最初のグラフにアクセスします。次に、ワークシート名を再度出力します。Chart.ワークシート財産。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook from sample Excel file | |
Workbook workbook = new Workbook(dataDir + "sample.xlsx"); | |
// Access first worksheet of the workbook | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Print worksheet name | |
Console.WriteLine("Sheet Name: " + worksheet.Name); | |
// Access the first chart inside this worksheet | |
Chart chart = worksheet.Charts[0]; | |
// Access the chart's sheet and display its name again | |
Console.WriteLine("Chart's Sheet Name: " + chart.Worksheet.Name); |
以下は、サンプル コードの結果のコンソール出力です。ご覧のとおり、同じワークシート名が両方とも出力されます。
Sheet Name: Portfolio
Chart's Sheet Name: Portfolio