using System; using System.Text; using GemBox.Spreadsheet; namespace HtmlExportSampleCS { /// <summary> /// Html export sample. /// </summary> class HtmlExportSampleCS { [STAThread] static void Main(string[] args) { // TODO: If using GemBox.Spreadsheet Professional, put your serial key below. // Otherwise, if you are using GemBox.Spreadsheet Free, comment out the // following line (Free version doesn't have SetLicense method). // SpreadsheetInfo.SetLicense("YOUR-SERIAL-KEY-HERE"); ExcelFile excelFile = new ExcelFile(); string inputFileName = @"..\..\HtmlExportSampleIN.xls"; string outputFileName = @"..\..\HtmlExportSampleOUT.html"; excelFile.LoadXls(inputFileName, XlsOptions.None); // Here you can set HTML exporter options. HtmlExporterOptions options = new HtmlExporterOptions(); options.ShowColumnLetters = true; options.ShowRowNumbers = true; excelFile.Worksheets.ActiveWorksheet.GetUsedCellRange().ExportToHtml(outputFileName, options, true); // You can use simple ExcelFile.SaveHtml method for the same result. //excelFile.SaveHtml(outputFileName, null, true); TryToDisplayGeneratedFile(outputFileName); } static void TryToDisplayGeneratedFile(string fileName) { try { System.Diagnostics.Process.Start(fileName); } catch (Exception) { Console.WriteLine(fileName + " created in application folder."); } } } }