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.
You could attach your sample here if you like. When you post a reply, just go to the Options tab and you can attach a file. Be sure to zip up the project.
Or, if you prefer, you can Submit an incident to Infragistics Developer Support and include your sample there.
Here is my sample. I hope I just have a setting that is incorrect.
I ran your sample, and there are no rows in the grid to export. So the sample doesn't really work to demonstrate the problem as is. So I added some rows and then in the button click event I checked the number of rows in the grid and it returns the correct number. So the grid itself is binding and getting the data correctly, it's just the export that is failing for some reason. So that's why setting the BindingContext doesn't work - that was never the problem.
Also... the first grid doesn't seem to have anything to do with the issue. I can remove the first grid from the sample entirely and the same problem occurs. So there must be something going on here with the grid on the DockPane that only affects exporting.
So I'm going to forward this thread over to Infragistics Developer Support so they can check this out and get it fixed.
Thanks for all your help.
Hi
This issue has been fixed and was applied to version 2009 Vol. 2 and newer since version 2009 Vol. 1 has been retired.
The latest service release for 9.2 is 9.2.20092.2083.