获取图表的工作表

Contents
[ ]

下面的例子展示了如何使用图表.工作表财产。该代码首先打印工作表的名称,然后访问工作表上的第一个图表。然后它再次打印工作表名称,使用图表.工作表财产。

// 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