Richard Branham
Top achievements
Rank 1
Richard Branham
asked on 22 Feb 2010, 05:33 PM
I have a grid which I export to Excel, but the Excel file contains a button for each of the groupings. It also contains extra rows for a command item template. I have as yet been unable to remove these before export. Can anyone offer a suggestion as to how I can remove these? A screen shot is attached.
4 Answers, 1 is accepted
0
Hello Richard,
Please examine the following links:
RadGrid export overview
Word/Excel export (HTML-based)
Sample code:
Let me know if the problem still persists.
Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Please examine the following links:
RadGrid export overview
Word/Excel export (HTML-based)
Sample code:
<ExportSettings ExportOnlyData="true" HideStructureColumns="true" />Let me know if the problem still persists.
Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Richard Branham
Top achievements
Rank 1
answered on 22 Feb 2010, 09:58 PM
With the ExportSettings attributes set as requested, I get the same output.
0
Richard Branham
Top achievements
Rank 1
answered on 23 Feb 2010, 03:46 PM
I was able to hide the extraneous items in the export by including the following code in grid_PreRender. It's somewhat of a brute-force approach but it works. (The _isExporting flag is set in the event handler for the button which initiates the export.)
if (_isExporting)
{
GridItem[] groupHeader = grid.MasterTableView.GetItems(GridItemType.GroupHeader);
foreach (GridGroupHeaderItem ghi in groupHeader)
{
ghi.Cells[0].Text = "";
}
GridItem[] items = grid.MasterTableView.GetItems(GridItemType.CommandItem);
foreach (GridCommandItem gci in items)
{
gci.Visible = false;
}
}
if (_isExporting)
{
GridItem[] groupHeader = grid.MasterTableView.GetItems(GridItemType.GroupHeader);
foreach (GridGroupHeaderItem ghi in groupHeader)
{
ghi.Cells[0].Text = "";
}
GridItem[] items = grid.MasterTableView.GetItems(GridItemType.CommandItem);
foreach (GridCommandItem gci in items)
{
gci.Visible = false;
}
}
0
Sunny
Top achievements
Rank 1
answered on 25 Feb 2010, 07:35 AM
Richard,
I was able to fix the same problem with the below solution:
In the button click event set the value of the RadGrid property (GroupingEnabled) to false.
grid.GroupingEnabled = false;
-Ravi