Bug 64256 - Chart PIE
Summary: Chart PIE
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 4.1.x-dev
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2020-03-22 16:19 UTC by Francesco Baldi
Modified: 2021-01-23 03:01 UTC (History)
0 users

image bugs and image google sheets (61.74 KB, application/vnd.rar)
2020-03-22 16:19 UTC, Francesco Baldi

Note You need to log in before you can comment on or make changes to this bug.
Description Francesco Baldi 2020-03-22 16:19:55 UTC
Created attachment 37116 [details]
image bugs and image google sheets

By opening an xlsx file generated with apache poi-ooxml 4.1.2, it enters recovery mode by deleting the pie chart.
Instead on google sheets it works!!!!!

Comment 1 Francesco Baldi 2020-03-23 09:44:22 UTC
this is the code implemented:

private Integer generateChart(XSSFSheet worksheet, String seriesChart, String keyChart, ExcelChart excelChart, Integer indexRow, String xAxis) {
		// ExcelChart
		// excelChart=sheetData.getClass().getAnnotation(ExcelChart.class)
		XSSFDrawing drawing = worksheet.createDrawingPatriarch();
		Integer startChart = indexRow;
		indexRow += excelChart.sizeRow();
		logger.debug("Start Chart: " + startChart);
		XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, startChart, excelChart.sizeColumn(), indexRow);

		XSSFChart chart = drawing.createChart(anchor);

		XDDFChartLegend legend = chart.getOrAddLegend();
		XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(excelChart.categoryAxis());
		XDDFValueAxis leftAxis = chart.createValueAxis(excelChart.valueAxis());
		logger.debug("-----------------xAxis: " + xAxis);
		XDDFDataSource<String> xs = XDDFDataSourcesFactory.fromStringCellRange(worksheet, CellRangeAddress.valueOf(xAxis));
		XDDFChartData chartData = chart.createData(excelChart.chartTypes(), bottomAxis, leftAxis);
		XDDFChartData.Series series = null;
		logger.debug("------------seriesChart: " + seriesChart);
		series = chartData.addSeries(xs, XDDFDataSourcesFactory.fromNumericCellRange(worksheet, CellRangeAddress.valueOf(seriesChart)));
		series.setTitle(keyChart, null);



		return indexRow;

Comment 2 Alain Fagot Bearez 2021-01-23 03:01:39 UTC
You can refer to the newly introduced example manipulating Doughnut chart:

Like the Doughnut chart, the Pie chart chart does not have category axis and value axes. if you remove your lines:

		XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(excelChart.categoryAxis());
		XDDFValueAxis leftAxis = chart.createValueAxis(excelChart.valueAxis());

your example should produce a file which will not be cleaned by PowerPoint upon opening it.

I hope we can now close this issue.