Excel export of RadGrid not working when grouped by a column

7 posts, 0 answers
  1. Prasanth
    Prasanth avatar
    5 posts
    Member since:
    Apr 2015

    Posted 09 Apr 2015 Link to this post

    Hi,

    I am using a Radgrid which have footer and groupfooter. But the excel export of the Radgrid is not working properly when it is grouped.

    The code which I used to export to Excel is below.

    private void lnkExport_Click(object sender, System.EventArgs e)
      {
     
                uwgAllocationCount.ExportSettings.FileName = "CountSummary " ;         
                uwgAllocationCount.ExportSettings.IgnorePaging = true;
                uwgAllocationCount.ExportSettings.OpenInNewWindow = true;
                uwgAllocationCount.MasterTableView.UseAllDataFields = true;
                uwgAllocationCount.ExportSettings.ExportOnlyData = true;
                uwgAllocationCount.ExportSettings.Excel.Format = GridExcelExportFormat.Biff;
                uwgAllocationCount.ExportSettings.HideStructureColumns = false;
                uwgAllocationCount.MasterTableView.HierarchyDefaultExpanded = true;                            
                uwgAllocationCount.ExportSettings.SuppressColumnDataFormatStrings = false;
                uwgAllocationCount.MasterTableView.ExportToExcel();
      }

    I have even tried GridExcelExportFormat.HTML, insted of GridExcelExportFormat.Biff, but it is showing only the grouped headers. It is not exporting the grouped data.

    Please help.

    Thanks

    Prasanth

     

     

  2. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 10 Apr 2015 Link to this post

    Hello Prasanth,

    What do you mean by "not working properly"? I don't see any screenshots, nor relevant code.
    Please note that grouping will be shown best in HTML format. Biff is not supported.

    Regards,
    Daniel
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Prasanth
    Prasanth avatar
    5 posts
    Member since:
    Apr 2015

    Posted 13 Apr 2015 in reply to Daniel Link to this post

    Hi Daniel,

    My problem is when i group the RadGrid with a column and then export it to excel, the data is not appearing in the excel sheet. I have tried both Biff and HTML export styles. The code used to export is already given above.

    Below is my Radgrid HTML code

    <telerik:RadGrid id="rgAllocationCount" runat ="server" AllowPaging="false" AllowSorting="True" OnItemDataBound="rgAllocationCount_ItemDataBound"
    GridLines="None" ShowGroupPanel="True" OnNeedDataSource="rgAllocationCount_NeedDataSource" height="550px" MasterTableView-AllowSorting="true" OnBiffExporting="rgAllocationCount_BiffExporting">
    <GroupHeaderItemStyle BackColor="navy" ForeColor="white" />
    <GroupPanel PanelItemsStyle-Font-Bold="true" PanelItemsStyle-ForeColor="White"></GroupPanel>
    <ClientSettings AllowDragToGroup="True" Scrolling-AllowScroll="true"></ClientSettings>
    <MasterTableView AutoGenerateColumns ="false" HeaderStyle-ForeColor="White"
    ItemStyle-CssClass="Row1" AlternatingItemStyle-CssClass="Row2" GroupsDefaultExpanded="false" Width="100%" ShowFooter="true" FooterStyle-CssClass="FtrRow" ShowGroupFooter="true">
    <FooterStyle BorderStyle="Solid" BorderColor="White" BackColor="LightGray" />
    <ItemStyle BackColor="#FAF0E6" Font-Names="Tahoma,Verdana" Font-Size="8pt" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px"/>
    <HeaderStyle Font-Bold="true" BackColor="Navy" ForeColor="White" />
    <AlternatingItemStyle BackColor="#C5CADB" Font-Names="Tahoma,Verdana" Font-Size="8pt" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px"/>
    <Columns>
    <telerik:GridBoundColumn UniqueName="Instrument" HeaderText="Instrument" SortExpression="Instrument" DataField="Instrument">
    <HeaderStyle Width="100px" />
    <ItemStyle BorderStyle="Solid" BorderWidth="1px"/>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn UniqueName="SubInstrument" HeaderText="Sub-Instrument" SortExpression="SubInstrument" DataField="SubInstrument">
    <HeaderStyle Width="100px" />
    <ItemStyle BorderStyle="Solid" BorderWidth="1px"/>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn UniqueName="Status" HeaderText="Status" SortExpression="Status" DataField="Status" EmptyDataText="-">
    <HeaderStyle Width="130px" />
    <ItemStyle BorderStyle="Solid" BorderWidth="1px"/>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn UniqueName="Type" HeaderText="Type" SortExpression="Type" DataField="Type" EmptyDataText="-">
    <HeaderStyle Width="80px" />
    <ItemStyle BorderStyle="Solid" BorderWidth="1px"/>
    </telerik:GridBoundColumn>
    <telerik:GridNumericColumn Aggregate="Sum" DataField="NumTrans" HeaderText="Num. Trans." DataFormatString="{0:###,###,##0.00}"
    SortExpression="NumTrans" UniqueName="NumTrans" FooterText ="Total:= " EmptyDataText="-">
    <FooterStyle ForeColor="White" Font-Size="8pt" Font-Bold="true" Font-Names="Tahoma" />
    <ItemStyle BorderStyle="Solid" BorderWidth="1px"/>
    </telerik:GridNumericColumn>
    <telerik:GridNumericColumn Aggregate="Sum" DataField="NumAlloc" HeaderText="Num. Alloc" DataFormatString="{0:###,###,##0.00}"
    SortExpression="NumAlloc" UniqueName="NumAlloc" FooterText ="Total:= " EmptyDataText="-">
    <ItemStyle BorderStyle="Solid" BorderWidth="1px"/>
    <FooterStyle ForeColor="White" Font-Size="8pt" Font-Bold="true" Font-Names="Tahoma" />
    </telerik:GridNumericColumn>

    </Columns>
    </MasterTableView>
    </telerik:RadGrid>

  5. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 13 Apr 2015 Link to this post

    Hello Prasanth,

    I have created a runnable demo for you. It is attached to this forum post. Please test it at your side and then let me know whether it behaves as expected when you run it.
    The only obvious change I made compared to your code is the following line (added):
    protected void lnkExport_Click(object sender, System.EventArgs e)
    {
        rgAllocationCount.ExportSettings.FileName = "CountSummary ";
        rgAllocationCount.ExportSettings.IgnorePaging = true;
        rgAllocationCount.ExportSettings.OpenInNewWindow = true;
        rgAllocationCount.MasterTableView.UseAllDataFields = true;
        rgAllocationCount.ExportSettings.ExportOnlyData = true;
        rgAllocationCount.ExportSettings.Excel.Format = GridExcelExportFormat.Html;
        rgAllocationCount.ExportSettings.HideStructureColumns = false;
        rgAllocationCount.MasterTableView.HierarchyDefaultExpanded = true;
        rgAllocationCount.ExportSettings.SuppressColumnDataFormatStrings = false;
        rgAllocationCount.MasterTableView.GroupsDefaultExpanded = true;
        rgAllocationCount.MasterTableView.ExportToExcel();
    }

    Regards,
    Daniel
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. Prasanth
    Prasanth avatar
    5 posts
    Member since:
    Apr 2015

    Posted 17 Apr 2015 in reply to Daniel Link to this post

    This is working. Thanks Daniel.

    Can we expand/collapse the grouped data in the exported HTML excel ?

    Thanks

    Prasanth

     

  7. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 21 Apr 2015 Link to this post

    Hello Prasanth,

    I'm afraid this is not possible. Our data grouping is different from the grouping functionality in Microsoft Excel.

    Regards,
    Daniel
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  8. Jaya
    Jaya avatar
    81 posts
    Member since:
    Mar 2011

    Posted 22 Apr 2015 in reply to Daniel Link to this post

    Hi

    Admin

    Can you solve this url most urgent

     http://www.telerik.com/forums/how-to-designed-the-aspx-page-and-open-rad-window

     

    How to Design one aspx page in following field Name,Empno,amount,Bs in row wise using Bootstrap Css then how to open this aspx page using radwindow? I have to need design aspx page using Bootstrap and when i click hyperlink open the aspx page using radwindow.

     

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017