excel to html

Convert Excel to HTML in Java

We use Excel workbooks to perform data entry, organize data, perform accounting jobs, conduct financial analysis, time management, task management, and much more. At the same time, HTML is a popular format for sharing data and information over the internet, and it offers a wide range of benefits, including cross-platform compatibility, easy customization, and flexibility. By converting your Excel spreadsheets to HTML, you can easily share your data with others, and ensure that your information is accessible to anyone, anywhere, and on any device. In this step-by-step guide, we’ll explore the benefits of converting Excel to HTML, using Java REST API.

Excel to HTML Converter

Aspose.Cells Cloud SDK for Java is a powerful tool that offers a wide range of capabilities for converting Excel spreadsheets to HTML format. With this SDK, you can customize your output to meet your specific needs, including the ability to specify the HTML encoding, save images as separate files, and control the formatting of your output. It also supports a variety of other file formats, including XLS, XLSX, CSV, PDF, and more, making it a versatile tool for document conversion. Furthermore, it is highly scalable, allowing you to process large volumes of data quickly and efficiently. Whether you’re a developer, a business owner, or a document management professional, Aspose.Cells Cloud SDK for Java is an ideal choice for converting Excel to HTML.

Now first we need to add the SDK reference in Java project (maven build) by adding following information in pom.xml.

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

If you do not have an existing account on Cloud Dashboard, please create a free account using a valid email address and obtain your personalized client credential details.

Excel to Web in Java

Let’s discuss the details of how you can develop an online spreadsheet viewer by following the steps given below.

  • Create an instance of CellsApi class which takes client credentials as input arguments.
  • Specify the name of input Excel, resultant format as HTML, and the output file name in string variables.
  • Read the content of the Excel workbook from local drive using File instance.
  • Finally, call the method cellsWorkbookPutConvertWorkbook(…) to initiate the conversion operation.
excel to csv file preview

image1:- Excel to HTML conversion preview

The input Excel used in the above example can be downloaded from myDocument.xlsx.

Notice the amazing capability of the API where individual worksheets are appearing as separate tabs in resultant HTML.

Convert Excel to HTML using cURL Commands

Converting Excel to HTML / XLS to Web using REST API and cURL commands offers a number of benefits. First and foremost, this approach is highly flexible and can be easily integrated into your existing workflows. By using REST API and cURL commands, you can automate your document conversion tasks and reduce the amount of time and resources required for manual conversion. Additionally, using a cloud-based tool like Aspose.Cells Cloud enables you to perform conversions on a scalable and secure platform, without the need for any additional software. Lastly, using REST API and cURL commands for converting Excel to HTML is a cost-effective solution that can help you save money on licensing fees and maintenance costs.

So first we need to generate a JWT access token while executing the following command.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Once we have the JWT token, we need to execute the following command to convert XLS to HTML and save the output in Cloud storage.

curl -v -X PUT "https://api.aspose.cloud/v3.0/cells/convert?format=HTML&outPath=converted.html&checkExcelRestriction=true" \
-H  "accept: multipart/form-data" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: multipart/form-data" \
-d {"File":{}}

Final Comments

In conclusion, converting Excel to HTML is a common task that can be accomplished using a variety of tools and methods. However in this article, we explored two approaches for converting Excel to HTML: using Java code with the Aspose.Cells Cloud SDK, and using REST API and cURL commands. Both approaches offer their own unique benefits and advantages, depending on your specific requirements and workflow. Using Java code provides a more customizable and integrated solution, while using REST API and cURL commands offers more flexibility and scalability. Ultimately, the choice of approach depends on factors such as the size and complexity of your Excel files, the level of automation and integration required, and your overall budget and resources. Regardless of which approach you choose, Aspose.Cells Cloud provides a powerful and reliable platform for document conversion, with support for a wide range of file formats and features.

Please note that the complete source code of SDKs can be downloaded from GitHub (published under MIT license). Lastly, if case you encounter any issues while using the API, please feel free to contact us via free product support forum.

We highly recommend visiting the following links to learn more about: