https://bz.apache.org/bugzilla/show_bug.cgi?id=65016
Bug ID: 65016 Summary: Creating a chart throws IndexOutOfBoundsException Product: POI Version: unspecified Hardware: PC OS: Linux Status: NEW Severity: major Priority: P2 Component: XDDF Assignee: dev@poi.apache.org Reporter: dominik.stad...@gmx.at Target Milestone: --- Created attachment 37636 --> https://bz.apache.org/bugzilla/attachment.cgi?id=37636&action=edit List of dates and values for a chart The following unit-test combined with the attached sample document throws an exception. I tried to "fix" it, but couldn't, if this is some incorrect usage of the new XDDFChart functionality, we should at least try to validate the inputs and provide a better error message. java.lang.IndexOutOfBoundsException at org.apache.xmlbeans.impl.store.Xobj.removeElement(Xobj.java:2099) at org.apache.xmlbeans.impl.store.Xobj.remove_element(Xobj.java:2130) at org.openxmlformats.schemas.drawingml.x2006.chart.impl.CTNumDataImpl.unsetPtCount(CTNumDataImpl.java:168) at org.apache.poi.xddf.usermodel.chart.XDDFDataSource.fillNumericalCache(XDDFDataSource.java:84) at org.apache.poi.xddf.usermodel.chart.XDDFChartData$Series.plot(XDDFChartData.java:214) at org.apache.poi.xddf.usermodel.chart.XDDFChart.plot(XDDFChart.java:418) at org.apache.poi.xddf.usermodel.chart.TestXDDFChart.testException(TestXDDFChart.java:102) @Test public void testException() throws IOException { try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chart20201220.xlsx")) { XSSFSheet splitSheet = wb.getSheet("Splits"); XDDFChart chart = newXDDFChart(); XDDFChartLegend legend = chart.getOrAddLegend(); legend.setPosition(LegendPosition.BOTTOM); // Use a category axis for the bottom axis. XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM); XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT); leftAxis.setCrosses(AxisCrosses.AUTO_ZERO); XDDFChartData data = chart.createData(ChartTypes.LINE, bottomAxis, leftAxis); // starting row 1 to include description XDDFNumericalDataSource<Double> xs = XDDFDataSourcesFactory.fromNumericCellRange(splitSheet, new CellRangeAddress(2, 100, 0, 0)); XDDFNumericalDataSource<Double> ys1 = XDDFDataSourcesFactory.fromNumericCellRange(splitSheet, new CellRangeAddress(2, 100, 1, 1)); data.addSeries(xs, ys1); chart.plot(data); try (OutputStream out = new FileOutputStream("/tmp/chart20201220.xlsx")) { wb.write(out); } } } -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org