Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating Excel file from HTML

Tags:

c#

asp.net

excel

I'm aware that I can generate an HTML <table> and save it as an .xls file to read into Excel, and that works fine and all, but it only gives me one sheet.

Is there a way to generate HTML so that I can have multiple sheets in a single .xls file? I've tried to simply generate more then one <table>, but they just end up getting appended to eachother.

like image 484
Jesse Avatar asked Oct 25 '22 03:10

Jesse


1 Answers

Short Answer: No.

Longer Answer: You cannot cause an HTML generated page to split into multiple worksheets in an Excel file. Further, the HTML you generate for even a single page could cause Excel to choke on certain machines as it does the conversion when the file is loaded. We've seen a number of low powered machines take upwards of 5 minutes to show a HTML file in excel (simple table with rows/columns, nothing fancy) depending on size.

Better Answer: Use a third party product like ClosedXML or FileHelpers to generate a proper xlsx file.

like image 131
NotMe Avatar answered Oct 27 '22 01:10

NotMe