Excel to HTML in C#, VB.NET

This article describes a simple approach to convert Excel to HTML by using C#/VB.NET. We will use as few codes as you can image to convert Excel to HTML in C#/VB.NET, with the perfect quality as you expect. The appearance of data can be improved as you can edit the HTML by applying personal CSS. Thus we believe any effect and requirement you or your clients wished to have.

Spire.Xls for .NET provides a well-designed class-workbook, which allows us to create new Excel or load an Excel in, and then we can convert Excel to HTML; meanwhile most optimization on the Excel is also allowed during the conversion. Spire.Xls for .NET is always welcome to any kind of trial and evaluation. So now please feel free to download Spire.Xls for .NET and then follow our guide to quickly convert Excel to HTML using C#/VB.NET or try other function of Spire.Xls for .NET.

Now please check my code samples for converting Excel to HTML in C#/VB.NET.

C#.NET code for converting Excel to HTML

[C#]
using Spire.Xls;
namespace Xls2Html

{
    class Program
    {
        static void Main(string[] args)
        {
            //load Excel file
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"..\..\test.xls");
            
            //convert Excel to HTML
            Worksheet sheet = workbook.Worksheets[0];
            sheet.SaveToHtml("sample.html");

            //Preview HTML
            System.Diagnostics.Process.Start("sample.html");
        }
    }
}

VB.NET code for converting Excel to HTML

[VB.NET]
Imports Spire.Xls
Namespace Xls2Html

	Class Program
		Private Shared Sub Main(args As String())
			'load Excel file
			Dim workbook As New Workbook()
			workbook.LoadFromFile("..\..\test.xls")

			'convert Excel to HTML
			Dim sheet As Worksheet = workbook.Worksheets(0)
			sheet.SaveToHtml("sample.html")

			'Preview HTML
			System.Diagnostics.Process.Start("sample.html")
		End Sub
	End Class
End Namespace

Now we can run this application and then a perfect HTML will be presented in your browser. Please see our effective screenshot as below:

Excel to HTML

About Spire.XLS

Spire.Xls is now a family with Spire.Xls for WPF, Spire.Xls for Silverlight and Spire.Xls for .NET. All of them enable developers/programmers to manage files within their applications. Learn more about them, please click on the links listed below.

Download Spire.XLS

Spire.XLS family is now in one pack. The Spire.XLS Pack is a compilation of Spire.XLS for .NET, Spire.XLS for Silverlight and Spire.XLS for WPF. Just one click to download all of them and have a free trial.