I have a c# page that renders an HTML table. Is there an easy way to just convert the page to excel or insert the stream into a worksheet or something similar? Thanks.
Yes, you can load the HTML content to an
For example, try this:
string htmlTable = "<table><tr><td>Sample</td></tr></table>"; var htmlOptions = new HtmlLoadOptions(); var htmlStream = new MemoryStream(htmlOptions.Encoding.GetBytes(htmlTable)); var workbook = ExcelFile.Load(htmlStream, htmlOptions); workbook.Save("output.xlsx");
If you need to insert the HTML content to the existing
ExcelFile object, then you can copy the sheet that’s created from loaded HTML.
I hope this helps, let me know if you need anything else.