0

I've been trying to get chart info from excel 2007 using POI.

plotArea.getScatterChartList().size();

This method keeps returning 0.

Here is my code:

XSSFDrawing drawing = sheet.createDrawingPatriarch();
List<XSSFChart> chartsList = drawing.getCharts();

for (XSSFChart chart : chartsList){
    CTChart ctChart = chart.getCTChart();
    CTPlotArea plotArea = ctChart.getPlotArea();
    int size = plotArea.getScatterChartList().size();
    for (int j = 0; j<size; j++){
        List<CTScatterSer> seriesList = plotArea.getScatterChartList().get(j).getSerList();
        System.out.println("series size: " + seriesList.size());
        for (int i = 0; i<seriesList.size(); i++){
            CTScatterSer ser = seriesList.get(i);
            XmlObject serieX = ser.getXVal();
            XmlObject serieY = ser.getYVal();
            System.out.println("serie x: " + serieX.xmlText() + " serie y: " + serieY.xmlText());
            }
        }

}
  • Check [this SO link](http://stackoverflow.com/questions/5599304/how-to-get-chart-info-from-an-excel-spreadsheet-using-apache-poi) , that might help – mustangDC Jul 29 '15 at 10:49
  • I reached to that point but I can't go any further. I can't get anything from CTChart. I need to know chart position, legend, series etc. – SzikakaPupu Jul 29 '15 at 14:51

1 Answers1

0

Had a similar problem, when I wanted to get a list of LineCharts of my plotArea.

Here is what worked for me: Don't use

plotArea.getScatterChartList()

but instead

plotArea.getScatterChartArray()

If you do this, your code will do an exception at

List<CTScatterSer> seriesList = plotArea.getScatterChartList().get(j).getSerList();

Same solution here, use get...Array() instead of get...List()

List<CTScatterSer> seriesList = plotArea.getScatterChartArray().get(j).getSerArray();

For some reasons I don't understand get...List() returns nothing, but get...Array() works fine.

schmusehase
  • 49
  • 1
  • 6