Convert Excel Files to HTML using Java

Java Excel to HTML

Excel spreadsheets allow you to store and well organize the data in tabular form. You can perform computations as well as generate different types of graphs and charts in order to analyze the data. However, in various scenarios, you may need to carry out Excel to HTML conversion to convert worksheets to HTML pages. For example, when embedding the content of the spreadsheets into web pages. In accordance with that, this article aims to cover how to convert Excel XLSX files to HTML programmatically using Java.

Excel to HTML Java Converter API

Aspose.Cells for Java is a spreadsheet manipulation API that is designed to implement Excel automation within the Java applications. In addition, the API’s built-in spreadsheet converter engine allows you to convert XLSX files to HTML or other formats. You can either download the API or install it within your Maven-based applications.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-cells</artifactId>
    <version>20.11</version>
</dependency>

Excel to HTML Java Conversion

Excel to HTML conversion using Aspose.Cells is as easy as pie. Just load the Excel spreadsheet and save it as an HTML file. The following are the steps to convert an Excel XLSX file to HTML.

The following code sample shows how to convert an Excel file to HTML using Java.

Convert Excel to HTML with Tooltip

In certain situations, the text exceeds the width of the cell in the worksheet. When you convert such a worksheet to an HTML page, some part of the text becomes hidden. For such scenarios, you can enable tooltips to view the exceeded text. The following are the steps to enable tooltips in Excel to HTML conversion.

The following code sample shows how to enable tooltips in Excel to HTML conversion in Java.

Convert Excel to HTML with Presentation Preference

Aspose.Cells for Java provides an additional feature of setting presentation preference for the rendered HTML pages. You can use this feature to get a more attractive presentation of Excel workbooks when rendered to HTML. For this, you can set HtmlSaveOptions.setPresentationPreference(true) property. The following code sample shows how to enable presentation preference in Excel to HTML conversion.

Try Aspose.Cells for Free

You can use Aspose.Cells for Java for free without restrictions using a free trial license.

Conclusion

In this article, you have learned how to convert Excel files to HTML using Java. Furthermore, you have seen how to enable tooltips and presentation preference in Excel to HTML conversion. You can explore more about the Java Excel API using the documentation.

See Also