I want to create a PDF from a XLSX (input.xlsx). The program writes some values into the Excel sheet, updates the pivot table and saves the excel as output.xlsx and output.pdf.
The file output.xlsx is correct shows the updated values (in Pivot Chart and Pivot Table), but the output.pdf has an incorrect Pivot Chart/Image. It still shows the source Pivot Chart from input.xlsx without the updated values.
val asposeLicense = File("./Aspose.Total.Java.lic")
License().setLicense(FileUtils.openInputStream(asposeLicense))
val workbook = Workbook("./input.xlsx")
val worksheet = workbook.worksheets[0]
for (i in 1..31) {
worksheet.cells[i + 14, 1].putValue(i)
}
val pivotTable = worksheet.pivotTables["PivotTable1"]
pivotTable.refreshData()
pivotTable.calculateData()
worksheet.refreshPivotTables()
workbook.calculateFormula()
workbook.save("./output.xlsx")
// save as pdf
val pdfSaveOptions = PdfSaveOptions()
val sheetSet = SheetSet(intArrayOf(0))
pdfSaveOptions.calculateFormula = true
pdfSaveOptions.sheetSet = sheetSet
workbook.save("./output.pdf", pdfSaveOptions)
How can I tell Aspose to update the PivotChart before exporting to PDF?
Source:
TestExportToPdf.zip (47,2 KB)
This shows the problem:
problem.jpg (382,0 KB)
Used aspose version:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells</artifactId>
<version>24.9</version>
</dependency>