Convert PDF Documents to Excel XLS/XLSX using Java

PDF to Excel Java

There could be various scenarios when you need to export the data within the tables from PDF to Excel workbooks. PDF to Excel lets you edit the data, apply formulas, plot charts, and perform other operations that are supported by the spreadsheets. In this article, I’ll show you how to automate the PDF to Excel conversion and convert PDF to XLS to XLSX workbooks programmatically using Java. For this, we’ll leverage the capabilities of Aspsoe.PDF for Java API.

Java PDF to Excel Converter – Installation

Aspose.PDF for Java is available for download as a JAR file. In addition, you can install it in your Maven-based applications using the following configurations.

Repository

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>

Dependency

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-pdf</artifactId>
    <version>20.5</version>
    <classifier>jdk17</classifier>
</dependency>

Convert PDF to Excel XLS using Java

In order to convert PDF to Excel XLS, you simply need to load the PDF document and save it with .xls extension. The following are the steps to perform this conversion.

The following code sample shows how to convert PDF to Excel XLS using Java.

Input PDF Document

Convert PDF to Excel

Output Excel Spreadsheet

PDF to XLS XLSX

Convert PDF to Excel XLSX using Java

For converting PDF to XLSX spreadsheet, you need to define the output Excel format using ExcelSaveOptions class. The following are the steps to perform PDF to XLSX conversion using Aspose.PDF for Java.

The following code sample shows how to convert PDF to XLSX using Java.

Minimize the Number of Worksheets in PDF to Excel

By default, Aspose.PDF converts each page in the PDF document to a separate worksheet. However, you may customize the API to minimize the number of worksheets in case of large PDF documents. The following are the steps to perform this operation.

The following code sample shows how to convert PDF to XLSX with a minimized number of worksheets using Java.

Conclusion

In this article, you have seen how to convert PDF to Excel XLS or XLSX files using Java. Furthermore, the feature of minimizing the number of worksheets in PDF to Excel is also discussed with the help of the code sample. You can explore more about Aspose.PDF for Java using the documentation.

See Also