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
65
KeyNotFoundException when exporting empty grid
posted

Hi,

I'm trying to use the UltraGridExcelExporter to export a grid to excel. It works if there's data in the grid, but if it is empty, it fails with this error:

System.Collections.Generic.KeyNotFoundException was caught
  Message="The given key was not present in the dictionary."
  Source="mscorlib"
  StackTrace:
       at System.ThrowHelper.ThrowKeyNotFoundException()
       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.SetCurrentGridObjectSpan(UltraGridExporterHelper exportHelper, UltraGridBand band, UltraGridRow row, PlaceholderType placeHolderType)
       at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.BeginExportInternal(UltraGridExporterHelper exportHelper, UltraGridLayout exportLayout, RowsCollection rows)
       at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExporterHelper.BeginExport(UltraGridLayout exportLayout, RowsCollection rows)
       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)
InnerException:

Is it possible to at least export the column headers even though there are no rows in the grid?

Parents
No Data
Reply Children