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
335
UltraGridExcelExporter throws object reference error in ExcelExporter.Export method
posted

 

Hi

In Ultragrid i have issue  when i click on export excel,

there are 2 Events 

1) Button click event for Export to Excel

2) Begin Export to make some columns visible after Exporting.

so here is my detailed scenario:

when i make my all columns hidden false in Begin_Export method throws object reference error in 

  ExcelExporter.Export(ugMappingGrid, location);,in the btnExportoExcel_Click.

If i comment these two lines 

 

     // e.Layout.Bands[0].Columns["MyColumn1"].Hidden = false;

      // e.Layout.Bands[0].Columns["MyColumn2"].Hidden = false;

in Begin_Export it works fine.

 

 

private void ExcelExporter_BeginExport(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.BeginExportEventArgs e)

        {

                e.Layout.Bands[0].Columns["MyColumn1"].Hidden = false;

                e.Layout.Bands[0].Columns["MyColumn2"].Hidden = false;

         }

private void btnExportoExcel_Click(object sender, EventArgs e)

        {

              string location = string.Empty;

                SaveFileDialog saveDialog = new SaveFileDialog();

                saveDialog.Filter = "(*.xls)|*.xls";

                saveDialog.DefaultExt = ".xls";

                saveDialog.ShowDialog();

 

                location = saveDialog.FileName;

                if (saveDialog.FileName != "")

                    ExcelExporter.Export(ugMappingGrid, location);  // Object reference error thows at this place

        }

Please help me to solve this issue ASAP, We are Using Infragistics version v9.2
Thanks
Srivasta s