#1680 - can't get chart x-axis title


#1

Hello,

I can’t get the axis title text from chart using code below. Is there any other way to get this, can you help me with this? I am using aspose.cells for Java 19.4.0. Excel file and screenshot are attached. Axis title text which I want to get is highlighted in the attached screenshot (“Total”).

Workbook workbook = new Workbook("chart.xlsx");
Chart chart = workbook.getWorksheets().get(0).getCharts().get(2);
System.out.println(chart.getCategoryAxis().getTitle().getText());

chart.zip (59.0 KB)

Regards,
Milorad


#2

@Milorad,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-42956 - Chart x-axis title cannot be fetched

#3

@Milorad,
We have investigated the issue a bit more. It’s not the title of the X axis. It’s the Category Data of the series. You can try to set title of X axis with below code and verify the same.

chart.getCategoryAxis().getTitle().setText("Category Title");

#4

Thanks for answering. Can I access to that Category data of the series somehow using aspose?


#5

@Milorad,

See the line for your reference (it will give you the cells range which one can use to get the actual data from the cell(s)):

System.out.println(chart.getNSeries().getCategoryData());

But this may not work for your case. The reason is your chart is a pivot chart whose underlying Pivot Table’s source has external data/file and Aspose.Cells does not support to refresh/extract data or calculate a PivotTable data whose data source is external reference/file(s). Even I click on the PivotTable, e.g “PivotTable4” and then click “Refresh|Refresh” in MS Excel and I got the error that it cannot open pivot source.


#6

Ok, thank you very much for the answer and the explanation.

Best Regards,
Milorad


#7

@Milorad,

You are welcome.