Excel spreadsheet is one of the most used software applications, developed by Microsoft for Windows. PDF (Portable Document Format) is a reliable, secure, and cross-platform file format. It may contain flat text, structuring elements, annotations, and graphics. You can convert Excel spreadsheets XLSX or XLS to PDF programmatically in Java on the cloud using REST API. There are several reasons why you might want to convert an Excel spreadsheet to a PDF. For example, to protect the data, to share the spreadsheet document, to keep the formatting of the spreadsheet, or to help reduce file size and make it easier to share and store. Therefore, in this article, we will see how to convert Excel to PDF using Java API.
This article will go over the following topics:
- Excel to PDF Converter Free download online API - Installation
- How to Convert XLSX to PDF Online in Java using REST API
- Convert Excel Spreadsheet to PDF in Java using Advanced Settings
Excel to PDF Converter Free download online API - Installation
In order to convert Excel to PDF in Java, I will be using the Java SDK of GroupDocs.Conversion Cloud API. This Java library is easy to install and offers a wide range of methods to achieve Excel XLSX or XLS to PDF conversion, without installing any 3rd party software. Java file format conversion API allows you to convert your documents and images of any supported file format to any format you need. Quickly convert between more than 50 types of documents and images online like Word, PDF, PowerPoint, Excel, HTML, CAD, raster images, etc.
However, you can either download the APIs JAR file or install the API using Maven configurations. Add repository and dependency into your project’s pom.xml file. Below are the steps for Maven:
Maven Repository:
<repository>
<id>groupdocs-artifact-repository</id>
<name>GroupDocs Artifact Repository</name>
<url>https://repository.groupdocs.cloud/repo</url>
</repository>
Maven Dependency:
<dependency>
<groupId>com.groupdocs</groupId
<artifactId>groupdocs-conversion-cloud</artifactId>
<version>23.4</version>
<scope>compile</scope>
</dependency>
Please obtain your Client ID and Secret from the dashboard before following the mentioned steps. Once you have your ID and secret, add the code snippet in a Java-based application:
How to Convert XLSX to PDF Online in Java using REST API
An Excel spreadsheet can be converted to a PDF file. This helps to keep the formatting and layout of the file and to reduce the file size. Let’s convert Excel to PDF file format by following the steps and code snippets given below:
Upload the File
Firstly, upload the Excel spreadsheet file to the Cloud using the following code sample:
As a result, the uploaded Excel spreadsheet will be available in the files section of your dashboard on the cloud.
Convert Excel into PDF Online using Java
Please follow the steps mentioned below to convert XLSX spreadsheet to PDF programmatically:
- Firstly, create an instance of ConvertApi
- Secondly, create ConvertSettings instance
- Thirdly, set the storage name and input the XLSX file path
- Now, provide the output file format as “pdf”
- Next, set the output file path
- Then, create ConvertDocumentRequest with convert settings as a parameter
- Finally, invoke conversion using the ConvertApi.convertDocument() class
The following code example shows how to convert Excel format to PDF file in Java using REST API:
The Excel file is now saved as a PDF. You can open the PDF file using a PDF viewer, such as Adobe Acrobat Reader, to view and print the contents.
Download the Converted File
The above code sample will save the converted PDF file on the cloud. You can download it using the following code sample:
Convert Excel Spreadsheet to PDF in Java using Advanced Settings
Please follow the steps mentioned below to change XLSX file to PDF document programmatically:
- Firstly, create an instance of ConvertApi
- Secondly, create ConvertSettings instance
- Thirdly, set the storage name and input Excel file path
- Next, set “pdf” as the output file format
- Next, create an instance of the PdfConvertOptions
- Next, set various convert options like setFromPage, setPagesCount, setZoom, setImageQuality, setPassword, setHeight, setMarginTop, setDpi, etc.
- Now set convert options and output file path values
- Then, create ConvertDocumentRequest with convert settings as a parameter
- Finally, get the output file by invoking the ConvertApi.convertDocument() class
The following code snippet shows how to convert Excel file to PDF file online in Java using REST API:
Online Excel to PDF Converter Free
How to convert XLSX to PDF online for free? Please try the following free online XLSX to PDF converter, which is developed using the above API.
Conclusion
We conclude this article at this point in the hope that you have learned:
- how to convert Excel format to PDF file in java on the cloud;
- programmatically upload the Excel file and then download the converted PDF file from the cloud;
- how to convert Excel to PDF online in java using advanced settings;
- free Excel to PDF converter online;
Additionally, you can learn more about GroupDocs.Conversion Cloud API using the documentation, or examples available on GitHub. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser.
Finally, groupdocs.cloud is writing new blog articles on different file formats conversions using REST API. So, please stay in touch for the latest updates.
Ask a question
You can post your questions/questions about how to convert Excel to PDF, via our forum.
FAQs
How do I convert Excel data to PDF in Java?
Please follow this link to learn the Java code snippet for how to convert Excel file to PDF quickly and easily.
How to convert Excel table to PDF in Java using REST API?
Create an instance of ConvertApi, set the values of the convert settings, and invoke the convertDocument method with ConvertDocumentRequest for converting Excel file to PDF.
How to save Excel to PDF free online?
Excel spreadsheet to PDF converter online free allows you to export Excel to PDF file, quickly and easily. Once the conversion is completed, you can download the PDF file.
How do I convert Excel XLSX to PDF online for free?
- Open online Excel to PDF converter free
- Click inside the file drop area to upload an Excel sheet or drag & drop an Excel file.
- Click on Convert Now button, online XLSX to PDF converter will turn Excel table into PDF file.
- Download link of the output file will be available instantly after converting convert Excel to PDF online.
How to install Excel to PDF online library?
Install Excel to PDF converter free download Java library to create, and convert Excel to PDF programmatically.
How do I convert Excel to PDF in windows?
Please visit this link to download the Excel file to PDF converter for free. This offline converter can be used to change Excel spreadsheet to PDF file in windows, using a single click.
See Also
Please follow the links below to learn more about:
- Convert EXCEL to JSON and JSON to EXCEL in Python
- How to Convert CSV to JSON and JSON to CSV in Python
- Convert Word to Markdown and Markdown to Word in Python
- Convert Word Documents to PDF using REST API in Python
- How to Convert PDF to Editable Word Document with Python SDK
- Convert MSG and EML files to PDF in Python
- Convert XML to CSV and CSV to XML in Python
- Merge PowerPoint PPT/PPTX Files Online using REST API in Ruby
- Annotate DOCX Files using a REST API in Python
- Extract or Remove Annotations from Word Files using REST API in Python
- How to Convert CSV to JSON and JSON to CSV in Java
- Convert Word to PNG and PNG to Word Document in Java
- Convert Word to JPG and JPG to Word Programmatically in Java