Hello,
I want a job that converts from PDF to XLSX, The code below converts it to XLS and not XLSX. I’m planning to use the SaveFormat Enumeration but the examples on the Aspose are not enough. Using the ExcelSaveOptions allows you to only save XLS. The XLS file can be opened but it prompts an error upon opening. Is there a way where I can define the format type of an Excel? Thanks in advance for the help! Below was the aspose code used.
//Convert
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(“test.pdf”);
// Instantiate ExcelSave Option object
com.aspose.pdf.ExcelSaveOptions excelsave = new com.aspose.pdf.ExcelSaveOptions();
// Save the output to XLS format, changing this to .xlsx wont allow in ExcelSaveOptions
pdfDocument.save(“test.xls”), excelsave)
Hi there,
Thanks for your inquiry. Please note currently Aspose.Pdf does not support conversion of PDF to XLSX, we have already logged a ticket PDFNEWJAVA-34777 for the purpose. We have linked your post to the issue and will notify you as soon as it is resolved.
Furthermore in reference to error message upon opening resultant XLS file, it is not a Aspose.Pdf bug. It is expected behavior, as this message appears because Aspose.Pdf provides support of saving resultant Excel file in MS Excel 2003 XML format. To avoid this warning message in MS Excel version 2007 and higher versions you can save output file as XML as following.
// save the output in XLS format
doc.save(myDir + “PDFtoExcel2007.xml”, excelsave);
We are sorry for the inconvenience caused.
Best Regards,
Hello Aspose Family,
Thank you for the help. Its been days that I was trying to make this work when its actually not supported, finally, I can stop and try on saving the file as XML instead. then XML to CSV.
I will get back on this.
Thanks again.
Hi,
Please continue using above stated solution and in case you face any issue or you have any further query, please feel free to contact.
Now concerning to conversion of XML to CSV, you may try using Aspose.Cells for Java. Please take a look over following code snippet.
[Java]
Workbook workbook = new Workbook("e:\\test2\\IPO.xml", new LoadOptions(LoadFormat.SPREADSHEET_ML));
TxtSaveOptions options = new TxtSaveOptions();
workbook.Save("out1.csv", options);
Hello Aspose Family,
I tried converting the PDF to XML (from the code above) and was able to get the XML0, from there I was also able to convert the converted XML to XLSX. The excel didn’t have any issues anymore, should have consulted help earlier :). So, converting PDF to XLSX needs an XML in between.
Thank you so much for the help, I appreciate it!
All the Best,
Lois
Hi Lois,
Thanks for your feedback. It is good to know that suggested workaround worked for you. However we will notify you when the above logged ticket for direct conversion of PDF to XLSX is resolved.
Best Regards,
The issues you have found earlier (filed as PDFJAVA-34777) have been fixed in Aspose.PDF for Java 18.6.