Using NetAdvantage 2007 vol 3 with HotFix 1053 in a Windows application.
This is my first attempt at using the UltraGridExcelExporter, based on the sample code given in the online help.
I added the component to my window and added a context menu item. The code called by the menu item gets a file name from the user and then the following:
this.ultraGridExcelExporter1.Export(this.dgQueryResult, strFileName); // dgQueryResult is the UltraGrid, strFileName is a string containing the file name.
When I run this code, I get the following exception:
System.NullReferenceException: Object reference not set to an instance of an object. at Infragistics.Win.UltraWinGrid.UltraGrid.FireInitializeRow(InitializeRowEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGridLayout.get_RowScrollRegions() at Infragistics.Win.UltraWinGrid.UltraGridLayout.DirtyGridElement(Boolean primaryMetricsDirty, Boolean fInvalidate, Boolean dirtyColMetrics) at Infragistics.Win.UltraWinGrid.UltraGridLayout.ClearViewStyle(Boolean groupByAffected) at Infragistics.Win.UltraWinGrid.UltraGridLayout.InitGrid(UltraGridBase grid) 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) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, String fileName)
This implies a problem with the InitializeRow event on the UltraGrid. I do have code there so I was suspicious of that code, but I put a breakpoint there and that code does not get executed either before or after the exception hits .
I'm looking for suggestions on how to debug this issue. I don't have the UltraGrid source code, so I can't tell what object is not instantiated.
Problem solved.
I am using build 1053 (Hotfix) of Infragistics 2007 vol 3. When I added the reference for UltraGridExcelExporter, I inadvertently referenced an older build of that version.
Once I changed the reference to the hotfix build, all works fine.
The answer is yes to all questions. This is an existing application.
In my test, I had the grid displaying multiple rows of data and I did check the string for a valid file name.
Did you check all the obvious places already?
- Does the grid contain rows?
- Does the grid have a datasource?
- Your filename string contains a value too? (even though it doesn't seem as this is related to your problem)
I did testing on my own to see if I could reproduce this problem with the version I'm currently using (2008.2), and couldn't get an exception even with trying to using different scenerios.