Convert XLS, XLSX, CSV files to HTML without using MS Excel.
Introduction
This example shows how to convert XLS/XLSX/CSV files to HTML file format from your .NET app by using GemBox.Spreadsheet.
Detail
This example shows how to convert active worksheet from XLS/XLSX/CSV files to HTML file
format.
Output HTML file contains all cell data and style from input file.
Setup
Download the sample code using the above link and unzip it. After you unzip sample code you
will notice that there are two solutions - one for C# and one for VB.
Convert XLS/XLSX/CSV file to HTML
Button "Convert to HTML" will load selected XLS/XLSX/CSV file and save it as HTML.
Converting to HTML is done like this:
C#
ExcelFile excelFile = new ExcelFile();
switch (inputFileFilterIndex)
{
case 1:
excelFile.LoadXls(inputFileName);
break;
case 2:
excelFile.LoadXlsx(inputFileName, XlsxOptions.None);
break;
case 3:
excelFile.LoadCsv(inputFileName, CsvType.CommaDelimited);
break;
}
excelFile.SaveHtml(outputFileName, null, true);
VB
Dim excelFile As New ExcelFile
Select Case Me.inputFileFilterIndex
Case 1
excelFile.LoadXls(inputFileName)
Exit Select
Case 2
excelFile.LoadXlsx(inputFileName, XlsxOptions.None)
Exit Select
Case 3
excelFile.LoadCsv(inputFileName, CsvType.CommaDelimited)
Exit Select
End Select
excelFile.SaveHtml(outputFileName, Nothing, True)
Conclusion
This simple solution describes how to convert different spreadsheet files HTML file
format.
Capabilities of GemBox.Spreadsheet are really impressive. You can use it for reading XLS,
XLSX and CSV files and writing to XLS, XLSX, CSV and HTML files.
GemBox.Spreadsheet has many functionalities that are not presented in this example. You can
use: styles, formulas, hyperlinks, images, merged regions, named ranges, print options, view
options, comments, preservation of illustrations, shapes, charts, auto filter, data validation,
conditional formatting, macros, pivot tables and more features that you can find at link
below.
Visit
GemBox Software
for more information and more samples.