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
875
Export Hierarchical grid to excel - remove indentation?
posted

I have a hierarchical grid that I am exporting to Excel.  In the final exported version I would like to remove all the additional empty columns that show up on child bands which is causing the child bands to be indented.  I have read that setting the IndentationType to Flat should do this, but it doesn't seem to be working.  I would like to remove the indentation but keep the hierarchical expand/collapse capability.

The output of the export looks like this:

 +UserName 1
     +User 1 Data Line 1
            User 1 Data Line 2
+UserName 2
     +User 2 Data Line 1
            User 2 Data Line 2

When I want it to look like this:

+UserName 1
+User 1 Data Line 1
User 1 Data Line 2
+UserName 2
+User 2 Data Line 1
User 2 Data Line 2

Where the '+' sign indicates that expand/collapse functionality in Excel/the grid.

I read in the WinGrid forum that I can handle the BeginExport event and modify the bands in the Layout, but this doesn't seem to work for WebGrid (or I'm doing it wrong).  This is what I have:

       Private Sub ExcelExporter_BeginExport(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.ExcelExport.BeginExportEventArgs) Handles ExcelExporter.BeginExport

            For Each band As Infragistics.WebUI.UltraWebGrid.UltraGridBand In e.Layout.Bands
                band.Indentation = 0
                band.IndentationType = IndentationType.Flat
                band.HeaderStyle.Font.Bold = True
            Next
        End Sub

What am I missing?  Is this even possible to do?  If not, looks like I'll have to manually dump the grid to Excel and I really would rather not do that!

Parents Reply Children
No Data