I want to get info like x, y, width, height, title of the chart. Here is my version for HSSFChart which works (It returns non-zero values):
HSSFChart chart
title = chart.getChartTitle();
x = chart.getChartX();
y = chart.getChartY();
width = chart.getChartWidth();
height = chart.getChartHeight();
The problem is that I can't get the same or any other info from XSSFChart.
XSSFDrawing drawing = sheet.createDrawingPatriarch();
List<XSSFChart> chartsList = drawing.getCharts();
for (XSSFChart chart : chartsList){
#ctChart
CTChart ctChart = chart.getCTChart();
CTPlotArea plotArea = ctChart.getPlotArea();
title = ctChart.getTitle.toString();
int size = plotArea.getScatterChartList().size();
for (int j = 0; j < size; j++){
List<CTScatterSer> seriesList = plotArea.getScatterChartList().get(j).getSerList();
for (int i = 0; i < seriesList.size(); i++){
CTScatterSer ser = seriesList.get(i);
XmlObject serieX = ser.getXVal();
XmlObject serieY = ser.getYVal();
System.out.println("x: " + serieX.xmlText() + " y: " + serieY.xmlText());
}
}
if (plotArea.getLayout() != null)
if (plotArea.getLayout().getManualLayout() != null)
System.out.println("x: " + plotArea.getLayout().getManualLayout().getX() + " y: " +
plotArea.getLayout().getManualLayout().getY());
#chart
chart.getManualLayout().getX(); // returns 0
chart.getManualLayout().getY(); // returns 0
chart.getManualLayout().getHeightRatio(); // returns 0.0
chart.getManualLayout().getWidthRatio(); // returns 0.0
It prints nothing even if there are many charts and series.