Click here to Skip to main content
12,763,337 members (29,181 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hello everyone,

I have made an application in in which on click of gridview template field a javascript is called and from that javascript a new popup window is opened(not modal popup window), i have button in that popup window on click of which i have a function of exporting data to excel..everything works fine but the excel is not viewed as downloaded...

Please help here is my code..

protected void btmExport_Click(object sender, EventArgs e)
        DataSet ds = (DataSet)ViewState["ComplaintDataSet"];
 public void ExportDetails(DataTable dt)
        string fileName = "Complaints-" + DateTime.Today.Day.ToString() + "" + DateTime.Today.Month.ToString() + "" + DateTime.Today.Year.ToString();
        HttpResponse response = HttpContext.Current.Response;
        response.ContentType = "application/";
        response.AddHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\".xls");
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        DataGrid dg = new DataGrid();
        dg.DataSource = dt;

Please help..

Posted 28-Sep-12 2:12am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

try this
check out[^]
may be help this.
chetan virkar 1-Oct-12 0:15am
hi krunal,
its good na
that solution is working
then for what problem
you need help...
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hello,you can find something useful in below article:
9 Solutions to Export Data to Excel for ASP.NET[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Was not working in Popup so i have opened the page in new tab.. and started working..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170217.1 | Last Updated 29 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100