Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
30
Export to Excel Group Summary Without Details
posted

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):

GridGroup

 

When I export to excel, I get the following result in the excel file:

 

ExportedResult

 

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:

DesiredResult

 

Parents
  • 469350
    Verified Answer
    Offline posted

    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;
            }

Reply Children