This is the logic I am using to create a workbook and then I save the workbook.
Infragistics.Excel.Workbook workBook = new Infragistics.Excel.Workbook();
ultraGridExcelExporter.Export(this.ultraGrid1, workBook.Worksheets.Add("Orders"));
ultraGridExcelExporter.Export(this.ultraGrid2, workBook.Worksheets.Add("POS Payment Totals"));
SaveFileDialog saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
saveFileDialog1.DefaultExt = "xls";
saveFileDialog1.FileName = "Order Inquire Export on " + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Year;
saveFileDialog1.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
workBook.Save(saveFileDialog1.FileName);
}
saveFileDialog1.Dispose();
saveFileDialog1 = null;
workBook.Worksheets.Clear();
The issue I an having is ultraGrid2 is in a dock manager and is set to auto hide. If the flyout comes out the grid is initialized and the export works great. However if I never open up the grid then nothing is ever exported to the worksheet.
Any suggestions on how I can make this work with or without showing the grid?
Hi,
My guess is that your second grid is not parented to any form or other container control, so it therefore has no BindingContext. Once you expand the DockPane, it gets parented to the pane and has a BindingContext at that point.
The easiest way to fix this is to set the grid's BindingContext to the BindingContext of the form. I'd try doing this in Form_Load, or possibly right after you create the grid if you are creating it in code.
this.ultraGrid2.BindingContext = this.BindingContext.
I tried to set the BindingContext but that did not fix the issue. I guess I will explain what I did and maybe that will help.
I added a DockManager
I added a second ultraGrid.
I docked the ultraGrid to the right in the DockManager.
I set the ultraGrid to fill.
The DockPane is set to AutoHide.
I did all of this through the designer. Currently I only have the Grid docked in the DockManager. When I docked the control it added two items dockableWindow1 which contains ultraGrid and windowDockingArea1.
I have never used a DockManager before so it could be a setting.