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 .NETprovides 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#]
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]
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: