Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon Nov 25, 2013 12:14 pm

Hi,
I have a problem with xls to PDF conversion.
This is the code that I've used to generate PDF file:
Code: Select all
 
// Set PDF template
PdfConverter pdfConverter = new PdfConverter(workbook);//where workbook corresponds to my XLS file
PdfDocument pdfDocument = new PdfDocument();
pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;

//Convert Excel to PDF using the template above
PdfConverterSettings settings = new PdfConverterSettings();
settings.FitSheetToOnePage = FitToPageType.ScaleWidthDifferentFactor;
settings.ExportDocumentProperties = true;
settings.EmbedFonts = true;
settings.TemplateDocument = pdfDocument;
settings.ExportBookmarks = true;
pdfDocument = pdfConverter.Convert(settings);

// Save PDF to stream
System.IO.MemoryStream stream = new System.IO.MemoryStream();
pdfDocument.SaveToStream(stream);


If in the XLS file I have a cell that contains a formula (eg "=SUM(A1+A2)"), in the corresponding cell of the PDF file, the value is equal to 0.
Why?! :shock:

nencioli
 
Posts: 4
Joined: Tue Sep 10, 2013 2:36 pm

Tue Nov 26, 2013 7:34 am

Hello,

Thanks for your inquiry.
Do you mean that the value in PDF is not right?
Please kindly try to add a line workbook.CalculateAllValue(); before the line PdfConverter pdfConverter = new PdfConverter(workbook);.. If you still have this issue, would you please provide us with your excel file if convenience?
It will help us do a research and solve it soon. Thank you very much!

PS: you could also send your file to support@e-iceblue.com.

Best regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Nov 26, 2013 8:20 am

Thanks a lot! It works!
The problem was that the value of any type of formula was equal to 0.

Goodbye!

nencioli
 
Posts: 4
Joined: Tue Sep 10, 2013 2:36 pm

Tue Nov 26, 2013 8:56 am

Hello,

Thanks for your reply.
Welcome to write to us again for further problems.

Best regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.XLS

cron