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