excel to html

Excel to HTML file using C# .NET.

Excel spreadsheets serve as invaluable tools for organizing data, creating reports, and analyzing information. However, there are many instances where sharing or displaying this data in a web-friendly format becomes necessary. This is where the importance of converting Excel to HTML arises. By transforming Excel spreadsheets into HTML tables, users gain the ability to seamlessly integrate their data into web pages, presentations, and online reports.

In this article, we are going to delve into the reasons why Excel to HTML conversion is crucial and how to accomplish it using the REST API.

API for Excel to HTML Conversion

For users seeking a reliable and efficient solution for Excel to HTML conversion, GroupDocs.Conversion Cloud SDK for .NET stands out as an excellent choice. This SDK ensures high-quality conversion results, preserving the layout, formatting, and content of the original Excel files. Additionally, it offers advanced customization options, allowing you to tailor the conversion process to your specific requirements.

Firstly, we need to install the SDK by searching GroupDocs.Conversion-Cloud in NuGet package manager and click the Install button. Another option is to execute the following command in package manager console.

NuGet\Install-Package GroupDocs.Conversion-Cloud -Version 24.2.0

After the installation, please make sure you have obtained your personalized API credentials(i.e. Client ID and Client Secret). You may visit this short tutorial explaining the details on how to get the API credentials.

Convert XLS to HTML in C# .NET

In this section, we are going to explore how the SDK empowers you to seamlessly integrate document conversion capabilities into your applications using C# .NET.

  1. Create an instance of Configuration class where we pass client credentials as arguments.
var configurations = new Configuration(clientId, clientSecret1);
  1. Initialize the ConvertApi where we pass Configuration object as an input argument.
var apiInstance = new ConvertApi(configurations);
  1. Upload the input Excel workbook to the cloud storage.
fileUpload.UploadFile(new UploadFileRequest("input.xls", stream));
  1. Create an instance ConvertSettings where we specify the name for input XLS, resultant format as html and the name for resultant HTML file as arguments.
var settings = new ConvertSettings{...}
  1. Call the ConvertDocumentRequest API to turn Excel to HTML and save the resultant HTML to the cloud storage.
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
excel to html

Image:- A preview of Excel to HTML conversion.

The sample Excel workbook used in the above example can be downloaded from input.xls.

How to Convert Excel into HTML using cURL commands

For users preferring a straightforward and scriptable approach to Excel to HTML conversion, GroupDocs.Conversion Cloud combined with cURL commands offers a convenient solution. With cURL commands, you can easily initiate the conversion process from the command line or within scripts, eliminating the need for complex programming or integration.

The first step in this approach is to obtain a personalized JWT access token. So, once you have a JWT token, please execute the following cURL command to convert XLSX to HTML and save the resultant HTML to cloud storage.

curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{  \"StorageName\": \"internal\",  \"FilePath\": \"{sourceFile}\",  \"Format\": \"html\",  \"ConvertOptions\": {    \"FromPage\": 1,    \"PagesCount\": 1,    \"Pages\": [      1    ]  },  \"OutputPath\": \"{myOutput}\"}"

Please replace sourceFile with the name of input Excel workbook, myOutput with the name of resultant HTML and accessToken with personalized JWT access token. Please note that we have specified to convert one worksheet of input Excel workbook.

  • In order to save the resultant HTML on local drive, please try using the following cURL command.
curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H  "Content-Type: application/json" \
-d "{  \"StorageName\": \"internal\",  \"FilePath\": \"input.xls\",  \"Format\": \"html\",  \"ConvertOptions\": {    \"FromPage\": 1,    \"PagesCount\": 1,    \"Pages\": [      1    ]  }}" \
-o "myResultant.html"

Free Excel to HTML Converter

In order to quickly test the capabilities of GroupDocs.Conversion Cloud SDK, please try using our free online XLSX to HTML Converter. This App is developed on top of GroupDocs.Conversion Cloud REST APIs. Please try using this lightweight, super-efficient solution and witness the amazing capabilities of our Cloud SDK for Excel workbook to HTML conversion.

xlsx to HTML app

Conclusion

In conclusion, converting Excel files to HTML format opens up new possibilities for data visualization, sharing, and collaboration. Whether you choose to utilize GroupDocs.Conversion Cloud SDK for .NET or employ cURL commands with GroupDocs.Conversion Cloud, both approaches offer efficient and reliable solutions for Excel to HTML conversion. Therefore, we encourage you to explore the capabilities of GroupDocs.Conversion Cloud SDK for .NET and experience firsthand the benefits of seamless document conversion.

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