Hi, in the following example I have a sample grid which has two columns. The first column is grouped, and the second column is summarized (using SUM and summary.DisplayFormat = "{0}" so that it won't show the 'Sum =' text):
When I export to excel, I get the following result in the excel file:
My question is: is there a way to NOT export the detail rows/outline tree and only show the top group summary row? I've used the following: Cancel on the RowExporting event, and it does remove the detail rows:
private void mygrid_RowExporting(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.RowExportingEventArgs e){ if (e.CurrentOutlineLevel.Equals(0)) e.Cancel = false; else e.Cancel = true;}
but I am unable to figure out how to remove the rows highlighted in red. The layout of the export that I am trying to obtain is:
Hi,
It looks like you are cancelling the child rows, but no the headers. So you could handle the HeaderRowExporting event and do the same thing you are doing in the RowExporting. But this won't realyl work well, because you will still get the outlining.
If you know you are only going to have one level of grouping, then here's a better solution:
private void ultraGridExcelExporter1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportInitializeRowEventArgs e) { if (e.Row.IsGroupByRow) e.SkipDescendants = true; }
Hi Mike,
I am also having the same requirement as him and this works great. Except that the column headers are not included in the exported xls. How can I put the column headers along with the data for this type of scenario?
Thanks,
Andro
Hi Andro,
I do not undestand what you mean. The code I posted here will not have any effect on the column headers at the root level. Are you saying you want to display column headers for the child bands without any child rows? That doesn't seem to make sense, so I don't think I am understanding the question.
Let me cite an example. If I have a grid displaying this way:
+ Group1 SumFirstColumn SumSecondColumn KeyColumn FirstColumn SecondColumn Child1 Data1 Data2 Child2 Data3 Data4
If we export using the code provided. We will have this result:
Group1 SumFirstColum SumSecondColumn
I was hoping to get this result set:
FirstColumn SecondColumn Group1 SumFirstColumn SumSecondColumn
Please let me know if this is still not clear.
Thanks in advance.
Best Regards,
Oh, I see. I think you will probably need to change the layout you are exporting. Try handling the BeginExport event. This event passes you a clone of the grid's layout so you can modify this layout and it will only affect the export and not the grid on-screen. You can set the HeaderPlacement property and maybe get the headers to appear above the GroupByRows.
You might want to try this in the on-screen grid first so you can see if it's possible to get the headers to appear above the groupby rows.
Hi Mike
I've trying with HeaderPlacement:
e.Layout.Bands(0).Override.HeaderPlacement = Infragistics.Win.UltraWinGrid.HeaderPlacement.FixedOnTop
or
e.Layout.Override.HeaderPlacement = Infragistics.Win.UltraWinGrid.HeaderPlacement.FixedOnTop
But nothings happens, the headers shows for each group