Convert DataGrid to Excel

Discussion in 'ASP .Net' started by =?Utf-8?B?UGF0cmljayBTLg==?=, May 5, 2004.

  1. Hi,
    I wrote a small function, thaht converts a DataGrid to Excel from a Web-Application (C#).
    Running the function with 100-200 rows it just works fine.
    Starting a "special" Report produces a DataDrid with about 13650 Rows. Now the conversion to Excel does not work.
    Are there any known restrictions?
    The code looks like this:
    <---->
    private void btnExcel_Click(object sender, System.EventArgs e)
    {
    Response.ContentType = "application/vnd.ms-excel";
    Response.Charset = "";
    this.EnableViewState = false;
    System.IO.StringWriter tw = new System.IO.StringWriter(System.Globalization.CultureInfo.CurrentCulture);
    System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
    ReportGrid.RenderControl(hw);
    Response.Write(makeHTMLcode(tw.ToString()));
    Response.End();
    }
    <---->
    Thanks in advance
    Patrick
     
    =?Utf-8?B?UGF0cmljayBTLg==?=, May 5, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?UGF0cmljayBTLg==?=

    Rick Spiewak Guest

    Turn off the viewstate on the datagrid before you complete the download. The
    extra data kills the ability of Excel to load it. That will fix this
    problem.

    "Patrick S." <> wrote in message
    news:...
    > Hi,
    > I wrote a small function, thaht converts a DataGrid to Excel from a

    Web-Application (C#).
    > Running the function with 100-200 rows it just works fine.
    > Starting a "special" Report produces a DataDrid with about 13650 Rows. Now

    the conversion to Excel does not work.
    > Are there any known restrictions?
    > The code looks like this:
    > <---->
    > private void btnExcel_Click(object sender, System.EventArgs e)
    > {
    > Response.ContentType = "application/vnd.ms-excel";
    > Response.Charset = "";
    > this.EnableViewState = false;
    > System.IO.StringWriter tw = new

    System.IO.StringWriter(System.Globalization.CultureInfo.CurrentCulture);
    > System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
    > ReportGrid.RenderControl(hw);
    > Response.Write(makeHTMLcode(tw.ToString()));
    > Response.End();
    > }
    > <---->
    > Thanks in advance
    > Patrick
     
    Rick Spiewak, May 5, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmltIEhlYXZleQ==?=

    Excel _WorkBook vs. Excel.Workbook

    =?Utf-8?B?SmltIEhlYXZleQ==?=, Sep 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,647
    Steve C. Orr [MVP, MCSD]
    Sep 29, 2004
  2. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,526
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  3. Sean

    Exceeds Excel Limits to convert datagrid

    Sean, Feb 20, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    115
    Alvin Bruney [MVP]
    Mar 2, 2004
  4. Paul D. Fox

    Display a Datagrid & Export a Datagrid to Excel

    Paul D. Fox, Jul 21, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    227
    Elton Wang
    Jul 21, 2005
  5. DOKOM

    Convert DataGrid to Excel

    DOKOM, May 5, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    113
    DOKOM
    May 6, 2004
Loading...

Share This Page