Any one can help me I want that "Data grid data export in Excelsheet when button is clicked" in C#

Recommended Answers

All 3 Replies

Search DaniWeb, Google, example Click Here

This will export a GridView to Excel

   protected void btnExport_Click(object sender, EventArgs e)
        Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
        Response.Charset = string.Empty;

        // If you want the option to open the Excel file without saving then
        // comment out the line below
        // Response.Cache.SetCacheability(HttpCacheability.NoCache);

        Response.ContentType = "application/vnd.xls";
        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);


Great. And exactly what is Response?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.