Convert Excel XLS/XLSX to HTML using C#

excel to html C#

Excel to HTML conversion could be useful in various scenarios such as converting sheets to web pages or embedding the content of the sheets within the web applications and so on. In this article, you will learn how to convert MS Excel XLSX or XLS files to HTML using C#. Furthermore, you will come to know how to use additional options to customize the Excel to HTML conversion.

Excel to HTML C# API

Aspose.Cells for .NET is a well-known spreadsheet manipulation API that lets you create, read, and modify Excel files without MS Office. The API also provides a built-in spreadsheet converter that allows you to convert Excel worksheets to HTML files with high fidelity. You can download the API or install it within your application using NuGet.

PM> Install-Package Aspose.Cells

Excel XLSX to HTML C# Conversion

Excel to HTML conversion can be achieved within a couple of lines of code. Just load the Excel file and save it with .html extension. The following are the steps to perform this operation.

The following code sample shows how to convert XLS/XLSX file to HTML using C#.

C# XLSX to HTML – Enable Tooltips

There might be the case when the text’s length exceeds the width of cells in the worksheets. In such a scenario, the text gets cut off in the converted HTML file. To tackle this issue, Aspose.Cells for .NET provides the option for enabling tooltips in the HTML file. The following are the steps to do so.

The following code sample shows how to enable tooltips in Excel to HTML conversion in C#.

Use Presentation Preference in Excel to HTML Conversion

Aspose.Cells for .NET provides HtmlSaveOptions.PresentationPreference property that makes you enhance the rendering of the spreadsheet’s layout in the resultant HTML file. In other words, it is used to get a more attractive presentation of Excel workbooks.

The following code sample shows how to enhance the presentation of Excel files.


In this article, you have learned how to convert Excel XLSX and XLS files to HTML using C#. Furthermore, you have seen how to enable tooltips and presentation preference options in Excel to HTML conversion. You can read more about Aspose.Cells for .NET using documentation.

See Also