1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Asp.NET Datagrid to Excel using c#

Discussion in 'C#' started by technoguy, Jan 29, 2007.

Thread Status:
Not open for further replies.
  1. #1
    How can I use Excel to display a ASP.NET Datagrid? I have a fairly large datagrid that would look better using excel so the headers stay stationary so is it possible I can call excel from the ASP.NET application to display my datagrid data? Any suggestions?
     
    technoguy, Jan 29, 2007 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    ccoonen, Jan 30, 2007 IP
  3. heck0045

    heck0045 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you want to do this easily, you can build a table <table></table> in html and send the contents in a session variable to a new page with a load handler like this:

    protected void Page_Load(object sender, EventArgs e)
    {
    Response.Clear();
    Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
    Response.Charset = "";
    Response.ContentType = "application/vnd.xls";
    Response.Write(Session["ExcelContents"].ToString());
    Session.Clear();
    Response.End();
    }
     
    heck0045, Jan 30, 2007 IP
Thread Status:
Not open for further replies.