We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Convert Excel File to PDF throw a nullReferenceException.

Hello.
I need convert one excel file to PDF and save it.
I use the code as your sample code.
But it was running and throwed a NullReferenceException.
I tested a simple excel file. it worked well. But another one not. It contains some formula.


I post the two excel file with attach file. please test.

thank you.

//Step 1: Instantiates the spreadsheet creation engine.
ExcelEngine excelEngine = new ExcelEngine();

//Step 2: Instantiates the excel application object.

IApplication application = excelEngine.Excel;

 

IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"ExcelOpenType.Automatic);

 

//Opens the Excel Document to Convert.

ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);

 

//Intializes the PDFDocument.

PdfDocument pdfDoc = new PdfDocument();

 

//Intializes the ExcelToPdfconverterSettings.

ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

 

//Converts Excel Document into PDF document.

// this line throw exception!

pdfDoc = converter.Convert(settings);

 

//Saves the pdf file.

pdfDoc.Save("ExceltoPDF.pdf");


Attachment: excellFile_6e28acfc.zip

3 Replies

BR Bronts July 8, 2015 09:44 AM UTC

And I tested with Microsoft API. 
Microsoft.Office.Interop.Excel
It saved to PDF and worked well.
So I guess there is some bug in XlsIO


IN Ishwarya Narayanan Syncfusion Team July 9, 2015 08:56 AM UTC

Hi Bronts,

 

Thank you for using Syncfusion products.

We were able to reproduce the issue and have logged defect report regarding this. We have provided the estimation time line for this fix in the incident you have created. Kindly follow up that incident to get further updates.


Please let me know if you have any questions.

Regards,
Ishwarya N



WI will January 4, 2023 08:26 AM UTC

Click the Select a file button above or drag and drop a file into the drop zone. Select the file you want to convert from XLS or XLSX to PDF format. After uploading the Excel sheet, Acrobat automatically converts it to the PDF file format. Sign in to download or share your converted PDF.


Regards,

Will


Loader.
Up arrow icon