This is a migrated thread and some comments may be shown as answers.

Excel export of RadGrid not working when grouped by a column

6 Answers 509 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prasanth
Top achievements
Rank 1
Prasanth asked on 09 Apr 2015, 07:19 AM

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

 

 

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 10 Apr 2015, 04:16 PM
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.

 
0
Prasanth
Top achievements
Rank 1
answered on 13 Apr 2015, 06:17 AM

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>

0
Daniel
Telerik team
answered on 13 Apr 2015, 03:22 PM
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.

 
0
Prasanth
Top achievements
Rank 1
answered on 17 Apr 2015, 07:05 AM

This is working. Thanks Daniel.

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

Thanks

Prasanth

 

0
Daniel
Telerik team
answered on 21 Apr 2015, 11:34 AM
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.

 
0
Jaya
Top achievements
Rank 1
answered on 22 Apr 2015, 06:14 AM

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.

 

Tags
Grid
Asked by
Prasanth
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Prasanth
Top achievements
Rank 1
Jaya
Top achievements
Rank 1
Share this question
or