How to Convert Excel to HTML using C#

This quick tutorial demonstrates how to convert Excel to HTML using C# where the Excel file can be in XLSX or XLS format. Using C# Excel to HTML conversion can be completed with high fidelity output. HTML files can be viewed using any browser on any operating system like MS Windows, Linux, or macOS.

Steps to Convert Excel to HTML using C#

  1. Add the reference to Aspose.Cells in your Excel to HTML conversion application with the Nuget Package Manager
  2. Create a Workbook class instance to load the source Excel file
  3. Create a HtmlSaveOptions class instance to set the properties for the output file
  4. Save the generated HTML file with the Save method and HtmlSaveOptions object

These simple steps describe the procedure for converting Excel file to HTML in C# in a way that first, we load the input Excel workbook, then we specify different preferences for the output HTML file like the encoding, CSS properties, etc. as per the requirements. You can also set the appearance of the images as well as the grid lines of the output HTML page and render the file to HTML format.

Code to Export Excel to HTML in C#

To convert Excel to HTML C# code is used having a few API calls where first it loads the input file using the Workbook class and then lets you set different rendering options like embedding the font or image resources. Finally, the output HTML webpage is exported using the Save method of the Workbook class. You can configure the conversion process to convert hidden sheets in the workbook or convert each worksheet to a separate HTML file according to your needs.

Here we have seen the process to convert Excel to HTML in C#. However, if you are interested to learn Excel to SVG conversion then refer to the article on how to convert Excel to SVG in C#.