Datagrid to Excel Export Problem while adding summation values

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Datagrid to Excel Export Problem while adding summation values

    We are getting a strange problem in exporting data grid to excel.

    We have a data grid in hand with basic data bounded to it and adding some summary data as DataGridItems rows at particular levels in datagrid (summation values)

    When we export the grid to excel using the following code

    Response.ContentType = "application/vnd.ms-excel";
    Response.AppendHeader("content-disposition", "attachment; filename=ProductVersionSummaryReport.xls");
    Response.Charset = "";
    System.IO.StringWriter tw = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(tw);
    hw.RenderBeginTag(System.Web.UI.HtmlTextWriterTag. Html);
    reportGrid.RenderControl(hw);
    hw.RenderEndTag();
    Response.Write(tw);
    Response.End();

    This code is able to export the grid successfully to excel format except the summation rows….
    It is able to create rows, columns (cells at exact location) but not able to display data in those cells.

    What could be the mistake in this code?

    Sudhakar Guest

  2. Similar Questions and Discussions

    1. DataGrid data Export to Excel
      I know we all have users asking "Can I Export/Import to Excel?". Apparently Excel is the best thing to come along to the user community since large...
    2. Export Datagrid to excel
      Hi, I have written the code to export my datagrid to excel. it is working fine. But i have one issue, when ever i click on export button, it...
    3. Display a Datagrid & Export a Datagrid to Excel
      I have a page displaying a datagrid and the user wants to have two options: 1. Export the current "Displayed" datagrid to Excel 2. Export another...
    4. DataGrid export to excel
      I've asked this question once before, but am still having problems. When I try to export this grid to excel i get the error message i've seen...
    5. Embedded Datagrid Export to Excel...
      I have a Datagrid within a Datagrid within a Datagrid. I have successfully exported a single datagrid to excel, but when I use the same approach on...
  3. #2

    Default Re: Datagrid to Excel Export Problem while adding summation values

    typically, your summary rows occur in a footer which you build out in
    itemdatabound. Is this the case? If it is, when you export it, it will not
    be present in the dataset unless you manually add this final row to the
    dataset.

    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
    Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
    "Sudhakar" <sudhakarATgmail.com_nospam> wrote in message
    news:6F21E1FC-B8D5-4C15-99A4-9426B7995875@microsoft.com...
    > We are getting a strange problem in exporting data grid to excel.
    >
    > We have a data grid in hand with basic data bounded to it and adding some
    > summary data as DataGridItems rows at particular levels in datagrid
    > (summation values)
    >
    > When we export the grid to excel using the following code
    >
    > Response.ContentType = "application/vnd.ms-excel";
    > Response.AppendHeader("content-disposition", "attachment;
    > filename=ProductVersionSummaryReport.xls");
    > Response.Charset = "";
    > System.IO.StringWriter tw = new System.IO.StringWriter();
    > System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(tw);
    > hw.RenderBeginTag(System.Web.UI.HtmlTextWriterTag. Html);
    > reportGrid.RenderControl(hw);
    > hw.RenderEndTag();
    > Response.Write(tw);
    > Response.End();
    >
    > This code is able to export the grid successfully to excel format except
    > the summation rows..
    > It is able to create rows, columns (cells at exact location) but not able
    > to display data in those cells.
    >
    > What could be the mistake in this code?
    >

    Alvin Bruney [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139