I want to get primary and secondary axes from chart. Is there any way I can fetch it?
I have attached a chart image for reference.
img.JPG (19.0 KB)
Thanks for the screenshot.
See the following sample code to get axis’s labels from a chart:
e.g.
Sample code:
...........
Chart chart1 = worksheet.getCharts().get(0);
chart1.calculate();
for (int k = 0; k < chart1.getValueAxis().getAxisLabels().size(); k++)
{
System.out.println(chart1.getValueAxis().getAxisLabels().get(k));
}
.......
Also, to get axis labels from secondary axis, you may try to use, e.g., chart1.getSecondValueAxis().getAxisLabels()
Hope, this helps a bit.
Good to know that the suggested code segment works for your needs. Feel free to write us back if you have further queries or comments.