Problema al ejecutar ejemplos LineChars y ScatterChart oficiales con Apache POI 4.0

TrimToSize:

Hay un problema con el oficial ejemplos LineChart y ScatterChart para Apache POI 4.0. Ellos compilar y ejecutar sin errores, pero el archivo de Excel creado no se pueden abrir indica que no hay contenido ilegible. Excel 2010 y 2016 están dando la opción de recuperar los datos desde el libro y después pinchando sí, esto diálogo aparece. ¿Cuál podría ser el problema?

Axel Richter:

El nuevo XDDFcódigo le falta el ajuste de las axIds en el lineCharte scatterChart.

En /xl/charts/chart1.xmlesto se parece a:

<c:lineChart>
 ...
 <c:axId val="0"/>
 <c:axId val="1"/>
</c:lineChart>

para un gráfico de líneas ..

Hacer añadiendo:

...
            XDDFChartData data = chart.createData(ChartTypes.LINE, bottomAxis, leftAxis);
            data.addSeries(xs, ys1);
            data.addSeries(xs, ys2);
            chart.plot(data);

            //setting the axis Ids to the LineChart
            chart.getCTChart().getPlotArea().getLineChartArray(0).addNewAxId().setVal(bottomAxis.getId());
            chart.getCTChart().getPlotArea().getLineChartArray(0).addNewAxId().setVal(leftAxis.getId());


            // Write the output to a file
            try (FileOutputStream fileOut = new FileOutputStream("ooxml-line-chart.xlsx")) {
                wb.write(fileOut);
            }
...

en LineChart.java

y

...
            XDDFChartData data = chart.createData(ChartTypes.SCATTER, bottomAxis, leftAxis);

            data.addSeries(xs, ys1);
            data.addSeries(xs, ys2);
            chart.plot(data);

            //setting the axis Ids to the ScatterChart
            chart.getCTChart().getPlotArea().getScatterChartArray(0).addNewAxId().setVal(bottomAxis.getId());
            chart.getCTChart().getPlotArea().getScatterChartArray(0).addNewAxId().setVal(leftAxis.getId());


            // Write the output to a file
            try (FileOutputStream fileOut = new FileOutputStream("ooxml-scatter-chart.xlsx")) {
                wb.write(fileOut);
            }

...

en ScatterChart.java

y funcionará.

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=213206&siteId=1
Recomendado
Clasificación