We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

setRecalculateBeforeSave() does not work for PDF

workbook.getSettings().setRecalculateBeforeSave(true) is not effective when workbook is saved as PDF.

I need to add an explicit workbook.calculateFormula() before saving.


Thanks for your query.

Well, I think you may try to use PdfSaveOptions.setCalculateFormula() method, it will suit your needs:
Sample code:

PdfSaveOptions pdfOptions = new PdfSaveOptions(SaveFormat.PDF);
// Calculate formulas before saving to PDF.
workbook.save(outputPdfFile, pdfOptions);

Hope, this helps a bit.

Thank you.

Both solutions work but it does not prevent ‘setRecalculateBeforeSave’ from not workink as attended.


Well, the RecalculateBeforeSave option might be useful if you save the workbook to Excel (XLS, XLSX etc.) formats. So, for saving to PDF document, it is not a big deal to use either Workbook.calculateFormula() method or my suggested code segment.

Thank you.