DEV Community

IronSoftware
IronSoftware

Posted on • Originally published at ironsoftware.com

Convert Excel to HTML

How to convert "Excel to HTML" in C#.

C#:

using IronXL;
using IronXL.Options;

WorkBook workbook = WorkBook.Load("test.xlsx");

var options = new HtmlExportOptions()
{
    //This is how we can make row/column numbers visible in html document
    OutputRowNumbers = true,
    OutputColumnHeaders = true,
    OutputHiddenColumns = true,

    //This is how we can make hidden rows/columns visible in html document
    OutputHiddenRows = true,
    OutputLeadingSpacesAsNonBreaking = true
};

//This is how we can export workbook to the HTML file
workbook.ExportToHtml("workbook.html",options);
Enter fullscreen mode Exit fullscreen mode

VB:

Imports IronXL
Imports IronXL.Options

Private workbook As WorkBook = WorkBook.Load("test.xlsx")

Private options = New HtmlExportOptions() With {
    .OutputRowNumbers = True,
    .OutputColumnHeaders = True,
    .OutputHiddenColumns = True,
    .OutputHiddenRows = True,
    .OutputLeadingSpacesAsNonBreaking = True
}

'This is how we can export workbook to the HTML file
workbook.ExportToHtml("workbook.html",options)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)