|
|
April
05,
2016
Version
2.1
Update
Html To Excel .NET converter
|
December
23,
2015
Version
2.1
Update
Html To Excel .NET converter
|
February
12,
2015
Version
2.1
Update
Html To Excel .NET converter
|
May
02,
2013
Version
2.1
Update
Html To Excel .NET converter
|
December
12,
2012
Version
2.1
Update
Html To Excel .NET converter
|
August
11,
2012
Version
2.1
Update
Html To Excel .NET converter
|
June
07,
2012
Version
2.1
New Release!
Html To Excel .NET converter
|
|
|
|
Html to Excel without Saving on server
"My reporting service generates different reports in HTML format at the corporate
website. We thought that it will be great if our customers can view the report in
Excel format. But we don't want to save Excel reports on our server. How can
it be done?"
Alan Kirk
After converting html to excel, the excel can be saved to memory stream instead
of excel file. Use Response object
to stream data to browser window. Note, there are different content types (mime)
for XLS and XLSX formats.
- // Read the specified html file.
- HtmlDoc html = HtmlDoc.ReadHTML(@"Html_to_Excel.html");
-
- // Convert Html table to
Excel
- HtmlToExcel htmlexcel =
new HtmlToExcel();
- ExcelWorkbook excel
= htmlexcel.Convert(html);
-
- // XLS
- // Save Excel Workbook (XLS) to MemoryStream
- byte[] bytes = excel.WriteXLS().ToArray();
-
- // Show Excel (XLS) in
Browser window without saving on disk
- Response.ContentType = "application/vnd.ms-excel";
- Response.BinaryWrite(bytes);
- Response.Flush(); Response.End();
-
- // XLSX
- // Save Excel Workbook
(XLSX) to MemoryStream
- byte[] bytes = excel.WriteXLSX().ToArray();
-
- // Show Excel (XLSX) in Browser window without saving
on disk
- Response.ContentType =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
- Response.BinaryWrite(bytes);
- Response.Flush(); Response.End();
-
|
|