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 1User 1 Data Line 2+UserName 2+User 2 Data Line 1User 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!
Hi,
I did that for the header, child and summary rows, but it's still not hiding the group summary rows. Is this a known bug that has been fixed with a later version? (I'm using v7.3)===========================================================What it looks like without e.CurrentColumnIndex = 0;
Header1
+SubHeader1
++Row1
++Row2
++SubHeaderSummary1
+SubHeader2
++SubHeaderSummary2
++HeaderSummary
===========================================================What it looks like with e.CurrentColumnIndex = 0;
SubHeader1
Row1
Row2
SubHeaderSummary1
SubHeader2
SubHeaderSummary2
++HeaderSummary===========================================================What I expect with e.CurrentColumnIndex = 0;
HeaderSummary
Regards,Stephanie
Hello,
To prevent the Child Band Indentation when exporting a Hierarchical WebGrid to EXCEL, check for the Child Band Key in the UltraWebGridExcelExporter HeaderRowExporting and RowExporting events and set the CurrentColumnIndex to 0. The following code example demonstrates how:protected void UltraWebGridExcelExporter1_HeaderRowExporting(object sender, Infragistics.WebUI.UltraWebGrid.ExcelExport.HeaderRowExportingEventArgs e){ // Check for the Child Band Key from the Band // to set CurrentColumnIndex Indentation to 0 if (e.Band.Key == "[Child Band Key]") { e.CurrentColumnIndex = 0; }}protected void UltraWebGridExcelExporter1_RowExporting(object sender, Infragistics.WebUI.UltraWebGrid.ExcelExport.RowExportingEventArgs e){ // Check for the Child Band Key from the GridRow // to set CurrentColumnIndex Indentation to 0 if (e.GridRow.Band.Key == "[Child Band Key]") { e.CurrentColumnIndex = 0; }}Please let me know if this helps or if you have any questions.Sincerely,Mike D.Developer Support EngineerInfragistics, Inc.
Good to know I'm not the only one having the same problem! As you can see, nobody has offered any assistance yet.
I resorted to manually exporting the grid and not using the Excel Exporter or the .Export method of the grid. That way I could just export the cells I wanted to export, and skipped the cells and rows that I didn't need to export.
*very frustrating*
Same exact problem here.
"IndentationType.Flat" seems to be "useless".
Is anyone able to help me out with this??