I've been trying to get chart info from excel 2007 using POI.
我一直在尝试使用POI从excel 2007获取图表信息。
plotArea.getScatterChartList().size();
This method keeps returning 0.
此方法保持返回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());
}
}
}
1 个解决方案
#1
0
Had a similar problem, when I wanted to get a list of LineCharts of my plotArea.
有一个类似的问题,当我想得到我的plotArea的LineCharts列表。
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()
在这里使用相同的解决方案,使用get ... Array()而不是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.
由于某些原因,我不明白得到... List()什么都不返回,但是get ... Array()工作正常。
#1
0
Had a similar problem, when I wanted to get a list of LineCharts of my plotArea.
有一个类似的问题,当我想得到我的plotArea的LineCharts列表。
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()
在这里使用相同的解决方案,使用get ... Array()而不是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.
由于某些原因,我不明白得到... List()什么都不返回,但是get ... Array()工作正常。