Im using:
var xlsxProvider = new XlsxFormatProvider();
var pdfFormatProvider = new PdfFormatProvider();
byte[] docBytes = File.ReadAllBytes(path);
Workbook workbook = xlsxProvider.Import(docBytes, null);
byte[] resultBytes = pdfFormatProvider.Export(workbook, null);
File.WriteAllBytes(resultPath, resultBytes);
to conver xlsx file to pdf. In source xlsx file a have a Table and a formula '=SUBTOTAL(109, Table2[...]) that work in xlsx, but when i export it to PDF i need to have the calculated value, but instead im getting the string '=SUBTOTAL(109, Table2[...]) .
Is there a simple way to force calculation of all formulas in the sheet before exporting it to PDF?
var xlsxProvider = new XlsxFormatProvider();
var pdfFormatProvider = new PdfFormatProvider();
byte[] docBytes = File.ReadAllBytes(path);
Workbook workbook = xlsxProvider.Import(docBytes, null);
byte[] resultBytes = pdfFormatProvider.Export(workbook, null);
File.WriteAllBytes(resultPath, resultBytes);
to conver xlsx file to pdf. In source xlsx file a have a Table and a formula '=SUBTOTAL(109, Table2[...]) that work in xlsx, but when i export it to PDF i need to have the calculated value, but instead im getting the string '=SUBTOTAL(109, Table2[...]) .
Is there a simple way to force calculation of all formulas in the sheet before exporting it to PDF?
Hello Velijko,
Thank you for reaching out. I am sorry to hear you are experiencing unexpected results.
In order for me to get a better context and understanding of the scenario you are experiencing, would you be able to share with us a sample document and project you are using to reproduce this behavior? This way I can try to achieve the same results on my end, investigate the issue further, try to identify the cause, and get back to you with details and feedback.
I tried replicating the same scenario on my end with a dummy document, however, the result of the formula was successfully exported to PDF. I am attaching my project for your disposal so you can test and examine it for yourself and let me know if I am missing something. You might also notice the disappearing table in my example which is due to missing support by the library - SpreadProcessing: Add support for tables and table styles.
NOTE: While sharing resources please keep in mind that this is a Q&A Forum thread and anything attached here will be publicly accessible so make sure you remove or replace any sensitive data.
Regards,
Yoan
When i use your sample file with my code, i get this:
Also i noticed that you are using Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf and i am using Telerik.Documents.Spreadsheet.FormatProviders.Pdf (24.4.1106). Am i using the wrong namespace?
here is the method that im using:
private void ConvertXlsxToPdfSingle(string path, string resultPath) { var xlsxProvider = new XlsxFormatProvider(); var pdfFormatProvider = new PdfFormatProvider(); FixedExtensibilityManager.FontsProvider = new FontsProvider(); byte[] docBytes = File.ReadAllBytes(path); Workbook workbook = xlsxProvider.Import(docBytes, null); foreach (Worksheet? sheet in workbook.Worksheets) { CellRange usedCellRange = sheet.UsedCellRange; if (usedCellRange == null) continue; pdfFormatProvider.ExportSettings = new PdfExportSettings([usedCellRange]); } byte[] resultBytes = pdfFormatProvider.Export(workbook, null); File.WriteAllBytes(resultPath, resultBytes); }
I have managed to run your example with my file, and the function is not calculated. It must be the way that the table is created or how the function is created. I created the table using Insert Table in Excel and added Total Row by checking the checkbox.

I did the same with the sample file you provided and run the sample code you provided and got this result:
65 is calculated it is the same formula but for the quantity column. But my formula is not calculated, even thou its the same formula but a different column