Formula in text field is not calulcated when saving as pdf


#1

Hi,

it seems there is a problem with calculation of formulas within text fields when workbook is saved as PDF.

Aspose TestTextField.zip (10.2 KB)

Given example file “TextField.xls” contains a text field that refers to cell H1. Value of cell H1 will be shown in this text field. Ok.
Problem: Modified value will not be shown in text field anymore, if modified workbook is saved as PDF.
Thanks a lot.

Best regards
Matthias


#2

@curmas,

Thanks for the template file and sample code segment.

When you update some shape’s referenced value, you got to use ShapeCollection.updateSelectedValue() method to refresh the shapes values. See the following sample code that works fine as I tested (you may adjust the code in your custom classes, e.g “AsposeCalcWorkbook” accordingly):
e.g
Sample code:

Workbook workbook = new Workbook("f:\\files\\TextField.xls");
		Worksheet worksheet = workbook.getWorksheets().get(0);
		Cell cell = worksheet.getCells().get(0, 7); // Cell H1
		cell.setValue(1);

		workbook.calculateFormula();
		worksheet.getShapes().updateSelectedValue();
		
		

		PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(com.aspose.cells.SaveFormat.PDF);
		pdfSaveOptions.setAllColumnsInOnePagePerSheet(true);
		pdfSaveOptions.setPrintingPageType(PrintingPageType.IGNORE_BLANK);
		pdfSaveOptions.setCompliance(PdfCompliance.NONE);

		workbook.save("f:\\files\\out1.pdf", pdfSaveOptions);

Hope, this helps a bit.


#3

Hi @Amjad_Sahi,

it works fine! Thanks a lot.

Best regards
Matthias


#4

@curmas,

Good to know that your issue is sorted out by the suggested line of code. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.