We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert PDF to XLS/XLSX using Aspose.PDF for .NET - Warning after conversion

Hi Aspose team,

after I converted PDF to Excel with following code:

DateTime start = DateTime.Now;
fileNameNew = fileNameOld.Replace(".pdf", ".xls");
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(uploadFolder + @"\" + fileNameOld);
ExcelSaveOptions saveOptions = new ExcelSaveOptions();
saveOptions.InsertBlankColumnAtFirst = false;
saveOptions.MinimizeTheNumberOfWorksheets = true;
pdfDocument.Save(uploadFolder + @"\" + fileNameNew, saveOptions);

When I try to open Excel (see attachment) I am getting warning:
"The file format and extension of XXXX don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway?"

Code is more or less the same like that what you have in documentation.

Hi Oliver,

Thanks for contacting support. I have opened your shared Excel document in MS Excel 2010 and noticed the warning which you have mentioned. I would like to share with you that the warning you are facing is an expected behavior of the API. Please note that Aspose.Pdf supports generating Excel file from PDF in MS Excel 2003 format. So when you open the file in later versions of MS Excel it will prompt such warning.

However in order to avoid the warning in higher versions, you may save the PDF into XML format. Please check the following code snippet to save the PDF file into XML format using ExcelSaveOptions.

Document doc = new Document(dataDir + “SamplePDF.pdf”);<o:p></o:p>

ExcelSaveOptions options = new ExcelSaveOptions();

doc.Save(dataDir + "SampleExcel.xml", options);

Generated output file from the above code can be opened into MS Excel without showing any warning. In case of any further query please feel free to ask.

Best Regards,


We would like to share with you that you can generate XLSX files directly from PDF using Aspose.PDF for .NET. Please check following code snippet in order to achieve that:

Generate XLSX from PDF using Aspose.PDF for .NET

Document document = new Document(dataDir + "Input.pdf");
ExcelSaveOptions saveOptions = new ExcelSaveOptions();
saveOptions.Format = ExcelSaveOptions.ExcelFormat.XLSX;
// optional settings
saveOptions.InsertBlankColumnAtFirst = false;
saveOptions.MinimizeTheNumberOfWorksheets = true;
document.Save(dataDir + "output.xls", saveOptions);