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; }
What version are you using? Build 2041 of what version?
Can you post more information, such as the call stack of the exception?
Without any more information, by best guess is that your parent band has a formula in it which is referencing the child band, and since the child band does not exist in the exported document, it's failing to resolve the formula properly. To test my theory, you could set the ExportFormulas property on the UltraGridExcelExporter and see if the exception goes away.
NetAdvantage_WinForms_20103.2041_SR is the version.
I tried setting the following but it didn't work.
DataExcelExporter.ExportFormulas = false;//didn't work
Stack trace below...It seems to me that even though I have hidden the child band it is still trying to access the childband columns with there given keys. Then it throws up because it can't do that since I have set Hidden to true. Just a thought.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Infragistics.Win.UltraWinGrid.GridExportCache.GetDocumentBandInfo(UltraGridBand band, PlaceholderType placeHolderType) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.ExportColumnHeaderCells(UltraGridExporterHelper exportHelper, UltraGridRow row, UltraGridBand band, Boolean setRowHeights) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.ProcessHeaderRows(UltraGridExporterHelper exportHelper, UltraGridRow row, UltraGridBand band) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.ProcessGridRowInternal(UltraGridExporterHelper exportHelper, UltraGridRow row, ProcessRowParams processRowParams) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExporterHelper.ProcessRow(UltraGridRow row, ProcessRowParams processRowParams) at Infragistics.Win.UltraWinGrid.RowsCollection.InternalTraverseRowsHelper(IUltraGridExporter exporter) at Infragistics.Win.UltraWinGrid.UltraGrid.Export(IUltraGridExporter exporter) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, Worksheet worksheet, Int32 startRow, Int32 startColumn) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, WorkbookFormat workbookFormat) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, String fileName, WorkbookFormat workbookFormat) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, String fileName)
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?
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?
Hi,
Have you been able to resolve your issue ? If you have any questions do not hesitate to ask
Regards
Not resolved yet...I will try your suggestion but in either case it would seem there is a bug here. I will also try it with 2067 and see how that works out.
-Ken
It worked for removing band[1] but it still doesn't explain why it is exporting that band.
It started adding an extra cell at the beginning of the row. Only for the first row though, weird.
Thanks for the help....working through all the little problems but I think I can get there.
Hi again,
If you need any additional assistance with your issue free to contact me.
I already make some tests and I`m sure that this suggestion working. Please try and if you have any questions do not hesitate to ask RegardsGeorgi