How to Convert Excel to HTML in Java

This quick tutorial explains the process to convert Excel to HTML in Java by loading the source XLSX file and then saving it as HTML. You can set different properties of the output HTML file before you export Excel to HTML in Java like setting the encoding, image format, and flag to display the grid lines. The output file can be saved to a file or stream or even sent as an HTTP response if required.

Steps to Convert Excel to HTML in Java

  1. For converting Excel to HTML, add a reference to Aspose.Cells library from the Maven repository
  2. Load the source Excel file that is to be converted to HTML using the Workbook object
  3. Create and initialize the save options for the output HTML using the HtmlSaveOptions object
  4. Set few properties of HTML like image format, encoding, and grid display
  5. Save the output HTML file using the save options

The above steps have described the procedure to change the sample XLSX to HTML in Java by loading it into a Workbook class object and then configuring the output HTML file. This configuration may include a number of settings and is required while saving the HTML to the disk.

Code to Export Excel to HTML in Java

For this conversion of Excel to Html Java code contains very few statements where the Excel file is loaded into a workbook class object and saved as HTML. There are optional parameters that can be set to configure the output HTML file like image format, encoding, grid display, default font, excluding unused styles to reduce the size, and a number of other parameters. The output can be saved to disk and stream as well.

This brief tutorial has described how to convert Excel to HTML in Java. If any other information is required like converting Excel to an image, refer to the article on how to convert Excel to SVG in Java.