计算图表后读取轴标签

可能的使用场景

您可以在使用计算图表的值后读取图表的轴标签[图表.计算()](https://reference.aspose.com/cells/java/com.aspose.cells/chart#calculate()) 方法。请使用轴.轴标签用于此目的的属性将返回轴标签列表。

计算图表后读取轴标签

请参阅以下加载的示例代码示例 Excel 文件并读取第一个工作表中图表的类别轴标签。然后它在控制台上打印轴标签的值。请参阅下面给出的示例代码的控制台输出以供参考。

示例代码

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Load the Excel file containing chart
Workbook wb = new Workbook("64716829.xlsx");
//Access first worksheet
Worksheet ws = wb.getWorksheets().get(0);
//Access the chart
Chart ch = ws.getCharts().get(0);
//Calculate the chart
ch.calculate();
//Read axis labels of category axis
String[] lstLabels = ch.getCategoryAxis().getAxisTexts();
//Print axis labels on console
System.out.println("Category Axis Labels: ");
System.out.println("---------------------");
//Iterate axis labels and print them one by one
for(int i=0; i<lstLabels.length; i++)
{
System.out.println(lstLabels[i]);
}

控制台输出

 Category Axis Labels:

\---------------------

Iran

China

USA

Brazil

England