Skip to content
Advertisement

Second Line in an Apache-POI chart with seperate axis

Hi this code taken from the answer here is working as expected, but I want exactly the same Chart but in an Excel-Sheet

JavaScript

So I modified the code like this to get an XLSX document, but the Chart isn’t the same chart in excel

JavaScript

Advertisement

Answer

The problem is that for a Word (XWPF) chart, the data are stored in a Excel workbook which is embedded in the Word file. There the data can be given as arrays and handled via XDDFDataSourcesFactory.fromArray. This then fills the embedded Excel data sheet.

But for a Excel(XSSF) chart the data needs to be in a Excel data sheet. Of course Excel will not embedding a Excel sheet in it’s files as it has worksheets already. So for Excel the data needs to be in a worksheet and needs to be handled via XDDFDataSourcesFactory.fromStringCellRange or XDDFDataSourcesFactory.fromNumericCellRange then.

Complete example which creates the Excel XSSFChart:

JavaScript

Works using current apache poi 4.1.2.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement