Convert Excel Files to PDF using Java

Convert Excel to PDF Java

Excel to PDF conversion might be required in various scenarios for exporting tabular data from worksheets to PDF pages. In this article, you’ll learn how to convert Excel files to PDF using Java in order to automate XLS/XLSX to PDF conversion within your web or desktop applications.

Java Excel to PDF Converter API – Installation

Aspose.Cells for Java is a well-known spreadsheet processing API that lets you create, manipulate, and convert Excel XLS/XLSX and other spreadsheet formats quite easily. With a few lines of code and easy to use methods, you can perform quality Excel to PDF conversion with high fidelity. Aspose.Cells for Java can be downloaded as JAR or installed using the following Maven configurations.


    <name>Aspose Java API</name>



Convert Excel XLS/XLSX to PDF using Java

The following are the steps to convert an Excel XLS or XLSX file to PDF using Aspose.Cells for Java API. The links to API references let you explore more about the classes and methods of the API.

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

Convert Excel to PDF with Particular Compliance using Java

PDF format supports various compliance standards such as PDF/A and etc. Being compliant with a particular standard means that the file fulfills the requirements or rules defined in that standard. In order to convert Excel to PDF with a particular compliance standard, you can use the PdfSaveOptions class. The following are the steps to set a particular compliance standard for the output PDF.

The following code sample shows how to convert XLSX to PDF with a particular PDF standard using Java.

Excel to PDF with One Page Per Sheet Settings using Java

By default, the API renders the worksheets according to the page size in the PDF document. In this case, one worksheet can possibly be rendered on multiple pages in the PDF. In order to override this operation, you can configure the API to render all the content of a worksheet on one page using PdfSaveOptions.setOnePagePerSheet(boolean) method.

The following code sample shows how to convert XLSX to PDF with one page per sheet settings using Java.

Convert a Range of Sheets to PDF using Java

In certain cases, you may need to convert only a selective range of the Excel sheets instead of the whole workbook. In such a case, you can tell the API about the range of the sheets to be included in the rendering process using PdfSaveOptions.setPageIndex(int) and PdfSaveOptions.setPageCount(int) methods.

The following code sample shows how to render a range of sheets to PDF using Java.


In this article, you have learned how to convert Excel files to PDF using Java. Furthermore, you have seen how to customize Excel to PDF conversion in various scenarios. You can learn more about Aspose.Cells for Java using the documentation.

See Also