Export as HTML

To export specified worksheet as html into stream:

worksheet.ExportAsHTML(System.IO.Stream stream)
worksheet.ExportAsHTML(System.IO.Stream stream, string pageTitle)
worksheet.ExportAsHTML(System.IO.Stream stream, string pageTitle, bool exportHeader)

For example:

var worksheet = grid.CurrentWorkbook;

using (FileStream fs = new FileStream("sample.html", FileMode.Create, FileAccess.Write))
  worksheet.ExportAsHTML(fs, "Sample Page");

Export as string in memory

string outputString;

using (MemoryStream ms = new MemoryStream(8192))
  outputString = Encoding.Default.GetString(ms);

Export without html header (only table element and children)

By passing the third argument exportHeader as false to prevent exporting default html header, it's useful to make application own html or embed into existing html.

worksheet.ExportAsHTML(stream, null, false);


Worksheet displayed in Editor


Worksheet exported as HTML (displayed in Internet Explorer)


Was the content of the page helpful?