How to Convert Excel to HTML with C#

 For MS Excel is very powerful on managing data, people would like to use it to display data. We can send with E-mail or print to share an Excel file. But if we want to display data with webpage, how should we do?

Actually, a webpage is based on HTML. Therefore, we can convert Excel to HTML file and display data by using browser.

In this post, I want to introduce the way to convert Excel to HTML with C#. And I use a component, Spire.XLS to realize this function more quickly. So, I have added its dll file as reference in project at the beginning. 

The following steps shows details.

  1. Load file which we want to convert to HTML with workbook.LoadFromFile(). Then, initialize worksheet.
  2.  Save Excel to HTML by using sheet.SaveToHTML()
  3.  Launch the converted HTML file.

Main Coding:

using System;
using Spire.Xls;

namespace ExceltoHTML
    class toHTML
        static void Main(string[] args)
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@”D:\Work\My Documents\vip.xlsx”);

            //Initailize worksheet
            Worksheet sheet = workbook.Worksheets[0];

            //Save Excel to HTML

Result Shown as Following:


Click Here to LEARN MORE about Spire.XLS

Click Here to DOWNLOAD Spire.XLS


One thought on “How to Convert Excel to HTML with C#

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s