I would like to export data from a SQL Server pull (usually I use SqlDataReader, but am open to suggestions) into an Excel/CSV file and have the user of the web app get it as a download.
I’d like to do this AJAX style, so that the click on download won’t cause a reload/postback.
Anyone done this before or have an idea on how?
I think this mechanism would work.
Have an HTML button that calls a javascript function when clicked.
Function would look something like this:
In the serverside, “datamaker.aspx” should connect to the SQL Server, and create the CSV file. Creating a CSV file is as easy as creating any other file using streamwriter, and writiing “comma” between fields. At the end of this page, output the filename either in a response xml or json.