0

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?

1

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Simple way, forget the code snippets, just bind a gridview and apply Big Fat Pig's codes... Gridview must be table layoutted

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.