The following topics shall be covered in this article:
JSON to HTML Converter Java API
For converting JSON to HTML, we will be using the Aspose.Cells for Java API. It is a feature-rich, powerful and easy to use API to work with Microsoft Excel-associated worksheets within the Java applications. It can be used for comprehensive charting, scalable reporting, and reliable calculations.
The Workbook class of the API represents an Excel workbook. Each workbook or spreadsheet can contain multiple worksheets. It allows opening and saving native Excel files. It also provides some advanced features like copying data from other Workbooks, combining two Workbooks, and protecting the Excel spreadsheet. The save() method of this class allows saving the workbooks in the provided formats. The HtmlSaveOptions class of the API represents the options for saving the HTML file.
Please either downloads the JAR of the API or add the following pom.xml configuration in a Maven-based Java application.
<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>22.6</version> </dependency>
Convert JSON to HTML in Java
We can convert JSON file to HTML by following the steps given below:
- Load the JSON file using the Workbook class.
- Save the HTML file using the save() method. It takes the output HTML file path as an argument.
The code example given below shows how to convert a JSON file to HTML using Java.
Convert JSON to HTML with Options in Java
We can convert JSON file to HTML using advanced options by following the steps given below:
- Firstly, load the JSON file using the Workbook class.
- Next, create an instance of the HtmlSaveOptions class.
- After that, specify the required HTML save options, such as ExportGridLines.
- Finally, save the HTML file using the save() method. It takes the output HTML file path and the HtmlSaveOptions object as arguments.
The code example given below shows how to convert a JSON to HTML with advanced options using Java.
Get a Free License
You can get a free temporary license to try the library without evaluation limitations.
In this article, we have learned how to convert JSON to HTML format programmatically in Java. We have also seen how to specify various options while converting JSON to HTML. Besides, you can learn more about Aspose.Cells for Java API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.