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

Free Support Forum - aspose.com

Convert pdf to excel in xlsx format using Aspose.PDF for Java

Document doc = new Document(“C:\Users\user\Desktop\pdf\NL-28.pdf”);
ExcelSaveOptions ex = new ExcelSaveOptions();
doc.save(“C:\Users\user\Desktop\pdf\NL-28.xml” ,ex);
com.aspose.cells.Workbook workbook = new com.aspose.cells.Workbook(“C:\Users\user\Desktop\pdf\NL-28.xml”);
workbook.save(“C:\Users\user\Desktop\pdf\NL-28.xlsx”, com.aspose.cells.SaveFormat.XLSX);
this one create excel file but didnt write anything.plz help

@sunita14

Could you please share your sample PDF document with us. We will test the scenario in our environment and address it accordingly.

ya sure.NL-28.pdf (111.3 KB)

@sunita14

We have tested the scenario using Aspose.PDF for Java 19.5 and Aspose.Cells for Java 19.6. We were unable to notice any issue. Output XLSX file was fine and for your reference, it has been attached as well.

NL-28.zip (8.2 KB)

Would you please try using latest version of the APIs and in case you still face any issue, please share a sample console application which is able to reproduce the error. We will again test the scenario in our environment and address it accordingly.

Document document = new Document();
document.open();
FileOutputStream fos=new FileOutputStream(“C:\Users\user\Desktop\pdf\1.xlsx”);
StringBuilder parsedText=new StringBuilder();

     PdfReader reader1 = new PdfReader("C:\\Users\\user\\Desktop\\pdf\\NL-26.pdf");
     int n = reader1.getNumberOfPages();
     for (int i = 0; i <n ; i++) {
         parsedText.append(parsedText+PdfTextExtractor.getTextFromPage(reader1, i+1).trim()+"\n") ;
         
     }
     StringReader stReader = new StringReader(parsedText.toString());
     int t;
     while((t=stReader.read())>0)
         fos.write(t);
     document.close();

this one is my code .this one create csv file but not xlsx file

@sunita14

The code you have shared does not seem related to Aspose.PDF for .NET. It has other classes involved like PdfReader. Furthermore, you are referring an input .xlsx file in the code. Would you please share a sample console application which is able to reproduce the original issue you are facing with Aspose.PDF for .NET API. We will again test the scenario in our environment and address it accordingly.

@sunita14

As per your first post, you were generating XLSX file using Aspose.PDF and Aspose.Cells. However, we would like to share with you that you can now convert PDF to XLSX using Aspose.PDF for Java. Please use the following code snippet to convert PDF to XLSX:

PDF to XLSX in Java using Aspose.PDF

Document doc = new Document(dataDir + "input.pdf");
ExcelSaveOptions ex = new ExcelSaveOptions();
ex.setFormat(ExcelSaveOptions.ExcelFormat.XLSX);
doc.save(dataDir + "Testxlsx.xlsx", ex);