I have data like below
AAAAAA
BBBBBB
CCCCCC
DDDDDD
EEEEEE
Now there is a button on the page, and when I click the button, the browser would download an Excel file with the data above, and stay on the current page. Is there any simple way to do it? The data is very simple. Only one column, and not huge.
Best Regards,
You can write out the data directly to the response stream. Set the mime type to excel and write the data out as :
If you want to use OOXML there are libraries such as Simple OOXML. Note this is the .xlsx format.
The following code sets the headers required for a .xls file