Convert Excel to PDF, Excel to HTML, Excel to Image in Java

Excel to PDF
Convert Excel to PDF | Excel to XPS | Excel to TIFF | Excel to HTML in Java

Microsoft Excel files are widely used for office data management and information manipulation on Windows and macOS platforms. Many users also use OpenOffice (ODS), SpreadsheetML(XML), CSV, and other formats for data storage and distribution. However, in order to view these documents, you need to have a specific application. Therefore, for convenience, conversion of Excel to PDF is a reasonable solution. Or you may convert them to other formats of your choice such as DOCX, HTML, raster images (JPEG, PNG, BMP, etc), XPS, etc.

The operation to convert Excel to Word, save Excel as PDF, Excel to HTML, etc can be accomplished using Microsoft Excel but for a bulk conversion, it gets quite cumbersome to perform such operations with the installed software. Therefore, a software routine can be employed to do the conversion job and REST APIs can be a perfect choice.

Excel to PDF Conversion API

Aspose.Cells Cloud is developed on top of REST architecture and is accessible from any platform. Now in order to implement the XLSX to PDF, Excel to HTML, and Excel to JPG in Java application, you need to try using Aspose.Cells Cloud SDK for Java. Before further embark our journey of learning about conversion features, we recommend you to go through the following topics

Aspose.Cells Cloud supports leading industry file formats for both input and output operations. The details are available over the following link Supported File Formats.

XLS to PDF Conversion using cURL Commands

In order to perform the conversion of the XLS to PDF format, we may try using the cURL command over the command prompt or use Java code to fulfill this requirement in desktop or web applications.

cURL command

curl -X GET "https://api.aspose.cloud/v3.0/cells/conditional.xlsx?format=PDF&isAutoFit=true&onlySaveTable=false&outPath=resultant.pdf" \
-H  "accept: multipart/form-data" \
-H  "authorization: Bearer <JWT Token>"

In the above command, conditional.xlsx is the input excel worksheet, PDF is the resultant format and resultant.pdf is the name of the output file. After the command execution, the resultant PDF is stored over cloud storage. The sample files are available on

XLSX to PDF in Java

In order to render the Excel worksheet to PDF format using Java code, please follow the instructions given below

  • First, create an object of CellsApi object by passing clientID and clientSecret information as an argument.
  • Upload the file to cloud storage
  • Finally, call a method cellsWorkbookGetWorkbook(…) to render the output to PDF format.

Convert XLS to XPS

In order to convert the XLSX file to XPS format, we simply need to set the value of the format variable as XPS. Use any XPS viewer to view the resultant file. We recommend using our free XPS viewer App (the preview is shown below). Download the input file from conditional.xlsx.

XPS file preview
Image 1:- Preview of resultant XPS file.

How to convert XLSX to TIFF

Aspose.Cells Cloud can also be used to convert Excel to JPG or other raster image formats. So please try using the GetWorkBook method of API to save XLSX files to TIFF image format. All you need to do is provide the input excel worksheet as input and specify the output format value as TIFF.

cURL command

curl -X GET "https://api.aspose.cloud/v3.0/cells/conditional.xlsx?format=TIFF&isAutoFit=true&onlySaveTable=false&outPath=resultant.tiff" \
-H  "accept: multipart/form-data" \
-H  "authorization: Bearer <JWT Token>"

Use the following links to download conditional.xlsx and resultant.tiff.

convert excel to jpg
Image 2:- Preview of resultant TIFF file.

Conclusion

In this article, we have learned the conversion of Excel to PDF, Excel to HTML, Excel to TIFF, and other supported formats. With simple Java code snippets, you have explored the conversion of excel to jpg. Similarly, we have also learned the conversion of these files using cURL commands. Please note that you may consider downloading the source code of Aspose.Cells Cloud SDK for Java from GitHub and modify it as per your requirements. In case you encounter any issues while using the API, please feel free to contact us via the free support forum.

Related Articles

We sincerely recommend you to please visit the following links to learn more about