In the dynamic landscape of data presentation, the need to seamlessly convert Excel spreadsheets to HTML has become more pronounced than ever. The ability to transform complex Excel data into web-friendly HTML is no longer just a feature but a fundamental necessity. This article embarks on a journey to address this need, delving into the details of this conversion process using .NET REST API. Join us as we explore the transformative power of seamlessly translating Excel data into HTML. Let’s unlock a realm of possibilities for dynamic and visually engaging online representation.
Excel to HTML Conversion API
The conversion of Excel to HTML becomes a seamless endeavor with the Aspose.Cells Cloud SDK for .NET, offering a robust and comprehensive Excel manipulation features in .NET applications. The process of converting Excel spreadsheets to HTML is not only simplified but enriched with advanced capabilities. Beyond Microsoft Excel to HTML conversion prowess, the API offers a wide array of features. It also supports various Excel formats, allowing for seamless interoperability, and provides functionalities like worksheet manipulation, formula calculations, and chart generation.
In order ot use the SDK in application, first we need to search Aspose.Cells-Cloud
in NuGet packages manager and click the Add Package
button. Secondly, obtain your client credentials from cloud dashboard. If you do not have an existing account, simply create a free account by following the instructions specified in the quick start article.
Convert Excel to HTML in C# .NET
In order to display MS Excel online, the easiest and simple procedure is to transform the Microsoft Excel online to HTML format. This section explains the details on how we can accomplish this feature using C# .NET.
CellsApi cellsInstance = new CellsApi(clientID, clientSecret);
Create an object of CellsApi class where we pass client credentials as arguments.
cellsInstance.UploadFile("sourceFile.xls", inputFile);
Upload the input Excel workbook to cloud storage.
var response = cellsInstance.CellsWorkbookGetWorkbook("sourceFile.xls", null, format: "HTML", isAutoFit: true, null, null, null, "resultant.html", null);
Call the API to initiate the Excel to HTML conversion operation. After successful operation, the resultant HTML is stored in cloud storage.
The input Excel workbook and the resultant HTML generated in the above example can be downloaded from:
After downloading the resultant HTML, please rename the extension to .html, because due to security reasons, the file with .html extension could not be uploaded.
XLS to HTML using cURL Commands
Aspose.Cells Cloud offers a cloud-based environment where you can leverage its robust API to perform various Excel operations, including the transformation of Excel data into HTML. When it’s coupled with cURL commands, this process becomes scriptable and adaptable, allowing for easy integration into various development environments. This method not only simplifies the integration of Excel to HTML conversion into your workflow, but also ensures a consistent and reliable process.
The first step in this approach is to generate a JWT access token using the following command:
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=921363a8-b195-426c-85f7-7d458b112383&client_secret=2bf81fca2f3ca1790e405c904b94d233" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Now, please execute the following command to convert XLS to HTML online. This method expects the input Excel to be already available in cloud storage and after conversion, the resultant HTML is also stored in cloud storage.
curl -v "https://api.aspose.cloud/v3.0/cells/{sourceFile}?format=HTML&isAutoFit=true&onlySaveTable=false&outPath={Resultant}&checkExcelRestriction=true&pageWideFitOnPerSheet=true&pageTallFitOnPerSheet=true" \
-X GET \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}"
Replace sourceFile
with the name of input Excel workbook available in cloud storage, Resultant
with the name of resultant HTML to be generated andaccessToken
with a JWT access token generated above.
In case we need to save the resultant HTML on local drive, please use the following cURL command. Notice we have skipped the output file name in the GET request and have used -o argument to save the output on local drive.
curl -v "https://api.aspose.cloud/v3.0/cells/{sourceFile}?format=HTML&isAutoFit=true&onlySaveTable=false&checkExcelRestriction=true&pageWideFitOnPerSheet=true&pageTallFitOnPerSheet=true" \
-X GET \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-o "myOutput.html"
Conclusion
In conclusion, the conversion of Excel to HTML is marked by two versatile approaches, i.e. leveraging the Aspose.Cells Cloud SDK for .NET and harnessing the power of cURL commands with Aspose.Cells Cloud API. So , whether you opt for the comprehensive toolkit and granular control offered by the SDK or the scriptable efficiency and cross-platform compatibility of cURL commands, both approaches effortlessly export Excel data into responsive and visually appealing HTML files. Unlock the full potential of Excel to HTML conversion for users across the spectrum.
Useful Links
Related Articles
We highly recommend visiting the following blogs: