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
855
HierarchicalDataGrid Child Band Export
posted

Hi,

I would like to know if it's possible to export the current (which ever it is) expanded child band, without exporting the parent or any other child bands to Excel.

  • 20120
    Offline posted

    Hello,

    Currently the exporter has two modes in which to export data - DataInGridOnly and AllDataInDataSource. My recommendation is to use DataInGridOnly mode and handle RowExporting server event. From there you can access the row which is being exported and cancel this action. From the event args you can check if the row is with level 0 (parent row) or level 1 (child row).

    Code snippet:

    protected void Button2_Click(object sender, EventArgs e)
        {
            this.excelExporter2.DisableCellValueFormatting = true;
            this.excelExporter2.DataExportMode = DataExportMode.DataInGridOnly;
            this.excelExporter2.WorkbookFormat = Infragistics.Documents.Excel.WorkbookFormat.Excel2007;
            this.excelExporter2.ExportMode = ExportMode.Download;
    
            Infragistics.Documents.Excel.Workbook wb = new Infragistics.Documents.Excel.Workbook();
            wb.Worksheets.Add(WebHierarchicalDataGrid1.ID);
    
            this.excelExporter2.Export(WebHierarchicalDataGrid1, wb.Worksheets[WebHierarchicalDataGrid1.ID], 0, 0);
    
            Response.Clear();
            Response.AppendHeader("content-disposition", "attachment; filename= file.xls");
    
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
    
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.Charset = "";
    
            wb.Save(Response.OutputStream);
        }
    
        protected void excelExporter2_RowExporting(object sender, ExcelRowExportingEventArgs e)
        {
            int i = 0;
        }