Excel Export has blank row between data row in both parent and child grid. ASP.Net grid does not has blank row. Is there anyway to remove blank row when export to excel from Win.Grid.
Hi,
Can you post a screen shot or something? Where exactly is the blank row?
I am experiencing the same problem. Also, data from nested levels appear shifted to the right in Excel - they no longer appear in their original columns. I enclosed two screenshots (attached file) - a part of the gird and the corresponding part of the Excel spreadsheet (the red lines are added to indicate where things should appear). As you can see, 5 columns in the grid were converted to 7 columns in the spreadsheet. Also, there are two extra blank lines.
Best regards,
Adam
The child rows of the grid are indented on the screen, so the child rows are indented one column in Excel. The extra spaces appear to be intentionally put there to separate the child rows from the parent rows, just like they are separated by a space on-screen.
If you wanted to remove the indentation of the band in the on-screen grid, you would set the Indentation on the bands. Something like this:
private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e) { foreach (UltraGridBand band in e.Layout.Bands) band.Indentation = 0; }
But you probably don't want this to affect the on-screen grid, only the export, so you could use the export layout. Like so:
private void ultraGridExcelExporter1_BeginExport(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.BeginExportEventArgs e) { foreach (UltraGridBand band in e.Layout.Bands) band.Indentation = 0; }
This will eliminate the indentation of the export layout and thus the exported excel file.
To remove the row spacing is a little trickier. It looks like you have set up your grid to not have spaces between islands but you on;y have one set of column headers. There are a couple of different ways you could have done this, and I can't tell just by looking at the screen shot. Maybe this is OutlookGroupBy or maybe it's using a combination of the ColHeaderVisible on the Band and the HeaderPlacement properties. On my machine when I set this up in the latter way, the extra spaces are not there.
These extra lines could also be caused by a RowLayout that has extra Spans in it, but that would only happen in an older version of the grid, as this was fixed a while ago.
In any case, you probably just need to adjust the CurrentRowIndex when these spaces are occurring. Something like this:
private void ultraGridExcelExporter1_RowExporting(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.RowExportingEventArgs e) { // Don't do anything for root-level rows if (e.GridRow.Band.Index != 0) { // Is this the first row in the island. if (e.GridRow.HasPrevSibling() == false) { e.CurrentRowIndex -= 1; } } }
I am using UltraGrid version 10.3 in my application. I have showing a hierarchy grid with Parent Child relationship and I am showing only one header at top. Child Band header are set to visibility false. I can see Childnodes for each Parent nodes. I have also used the band.indentation=0 for ChildBands. But wil exporting to excel It is showing emply row between Parent and Child rows .
Example:
Header1 Header 2 Header2
parent1 parent1 Parent1
empty row
child1 child1 child1
Empty row
parent2 parent 2 parent2
child2 child2 child2
Please can you help to resolve this issue. Data Displyed in UI is fine. I am facing this problem on exporting to excel.
I'm confused about what you are asking. Your question appears to already be answered in this thread, above, where I posted code to handle the RowExporting event and change the CurrentRowIndex.