Imports System.IO Imports System.Text Imports System.Web Imports GemBox.Spreadsheet Module GemBoxSpreadsheetHelper Public Sub SaveAsSingleHtml(ef As ExcelFile, filePath As String) Dim singleHtmlFileContent As New StringBuilder() Dim htmlTopContent As String = "" Dim htmlBottomContent As String = "" Dim worksheetCount As Integer = ef.Worksheets.Count Dim saveOption As HtmlSaveOptions = New HtmlSaveOptions() With {.SelectionType = SelectionType.ActiveSheet, .HtmlType = HtmlType.HtmlTable} singleHtmlFileContent.Append(htmlTopContent) For i As Integer = 0 To worksheetCount - 1 ef.Worksheets.ActiveWorksheet = ef.Worksheets(i) Using stream = New MemoryStream() ef.Save(stream, saveOption) singleHtmlFileContent.Append(saveOption.Encoding.GetString(stream.ToArray())) End Using Next singleHtmlFileContent.Append(htmlBottomContent) File.WriteAllText(filePath, singleHtmlFileContent.ToString(), saveOption.Encoding) End Sub Public Sub SaveAsSingleHtml(ef As ExcelFile, response As HttpResponse) Dim singleHtmlFileContent As New StringBuilder() Dim htmlTopContent As String = "" Dim htmlBottomContent As String = "" Dim worksheetCount As Integer = ef.Worksheets.Count Dim saveOption As HtmlSaveOptions = New HtmlSaveOptions() With {.SelectionType = SelectionType.ActiveSheet, .HtmlType = HtmlType.HtmlTable} singleHtmlFileContent.Append(htmlTopContent) For i As Integer = 0 To worksheetCount - 1 ef.Worksheets.ActiveWorksheet = ef.Worksheets(i) Using stream = New MemoryStream() ef.Save(stream, saveOption) singleHtmlFileContent.Append(saveOption.Encoding.GetString(stream.ToArray())) End Using Next singleHtmlFileContent.Append(htmlBottomContent) response.Write(singleHtmlFileContent.ToString()) response.Flush() response.Close() response.End() End Sub End Module