Reputation: 11
In my web application i want to download data directly from a SQL database to MS Excel with customize heading. In the web page there will be one textbox, user only choose the date from that textbox(this contain the pop up calender) and when user clicks on download button, it will directly download data into Excel. How can i achieve this?
Upvotes: 0
Views: 838
Reputation: 1066
You build a dataset from the sql query and conert the dataset to excel file using the code snippet shown in THIS link.
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment;filename=MyFiles.xls");
Now turn off caching, or some browser may unable to download and open the file.
Hope it works for you.
Upvotes: 1