计算图表后读取轴标签
Contents
[
Hide
]
可能的使用场景
您可以在使用计算图表的值后读取图表的轴标签图表.计算()方法。请使用轴.轴标签用于此目的的属性将返回轴标签列表。
计算图表后读取轴标签
请参阅以下加载的示例代码示例 Excel 文件并读取第一个工作表中图表的类别轴标签。然后它在控制台上打印轴标签的值。请参阅下面给出的示例代码的控制台输出以供参考。
示例代码
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 | |
//Load the Excel file containing chart | |
Workbook wb = new Workbook("sampleReadAxisLabelsAfterCalculatingTheChart.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
//Access the chart | |
Chart ch = ws.Charts[0]; | |
//Calculate the chart | |
ch.Calculate(); | |
//Read axis labels of category axis | |
string[] lstLabels = ch.CategoryAxis.GetAxisTexts(); | |
//Print axis labels on console | |
Console.WriteLine("Category Axis Labels: "); | |
Console.WriteLine("---------------------"); | |
//Iterate axis labels and print them one by one | |
for (int i = 0; i < lstLabels.Length; i++) | |
{ | |
Console.WriteLine(lstLabels[i]); | |
} |
控制台输出
Category Axis Labels:
---------------------
Iran
China
USA
Brazil
England