Click here to Skip to main content
Rate this: bad
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 at 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
0 DamithSL 320
1 OriginalGriff 275
2 Sergey Alexandrovich Kryukov 187
3 Afzaal Ahmad Zeeshan 154
4 Peter Leow 115
0 OriginalGriff 7,510
1 DamithSL 5,494
2 Sergey Alexandrovich Kryukov 4,954
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514

Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 29 Sep 2012
Copyright © CodeProject, 1999-2014
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