This following code causes the excel export to fail with "Key not found in Dictionary". I am using build 2041.
private void OnGridBeginExport(object sender, BeginExportEventArgs e) {
e.Layout.Bands[1].Hidden=true; }
HeaderPlacement may resolve differently based on other settings like ViewStyle. So this seems like it's probably a bug, but I cannot reproduce it.
If you can post a sample demonstrating this, I'd be happy to take a look.
Also, I think there is a newer service release than the one you are using. Build 2067 was posted a couple of weeks ago. You might want to try getting that one and see if the issue is already fixed.
How to get the latest service release - Infragistics Community
Hi,
May be one possible suggestion is to cancel HeaderRowExporting in the event HeaderRowExporting. For example:
void ultraGridExcelExporter1_HeaderRowExporting(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.HeaderRowExportingEventArgs e) { if(e.Band.Index == 0) e.Cancel = true; or if (e.CurrentColumnIndex == 1) e.Cancel = true; }
{ if(e.Band.Index == 0) e.Cancel = true; or if (e.CurrentColumnIndex == 1) e.Cancel = true; }
Please try this suggestion and send me a feedback.
Regards
Actually, it is the whole call stack with the exception of one line that show our proprietary method call. I have looked and I am not using the HeaderPlacement property for that grid. I will see if it is actually set when I debug the Layout for the export.
What your saying makes sense though because the Band[1] column header keeps showing up in the excel even though I have SingleBand property set to true. The grid is only displaying Band[0] with all its header and all columns. The exported excel looks like this:
The second header (row 2) is from Band[1] and shouldn't be showing. I have been trying get rid of that header and ran into the bug we are talking about.
I guess I could set SingleBand = false and then set the Band[1].Hidden = true and see if that works for exporting? Hopefully it still works for display of the grid.
thoughts?
It's hard to tell since you only listed a portion of the call stack and not the whole thing. But this could be a bug.
In order to export more efficiently, the grid caches some information about the grid layout up front. This call stack indicates that the grid is trying to export the column headers for a band and failing to find those headers in the cache. That should never happen, so something is clearly wrong here.
But there's no much we can do about this without knowing exactly what circumstances it occurs.
My best guess is that this might be related to a recent change which was made regarding the HeaderPlacement property. Are you setting this property in your code?
Could you please look at the attached project. Please modify my sample to reproduce your issue. Please keep us in touch.