Export HTML Table to Excel using ASP.NET

前端 未结 5 1586
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 13:39

I have an html table (Not Gridview) and that has no proper Header and rows. Instead it has customized structure and data. I want to export this table to Excel. How can I do

5条回答
  •  青春惊慌失措
    2020-11-28 14:33

    There's no automated way. But you could use the same code to create the table and write it to the output instead. If you write it as a simple CSV file, then the user can load it into Excel by simply clicking the downloaded file.

    By setting the correct headers, you can direct the browser to treat the content as a download instead of a web page. I posted the code to do this in this article.

提交回复
热议问题