Hi,
This is a somewhat unusual problem... We have developed an application that presents data in grids to the user and allows them to slice and dice and send the results to an excel workbook. In particular one thing the users can do is to hide columns and also add formula columns.
So the problem arises when a column involved in a formula is hidden, in this case the excel exporter creates an additional hidden sheet in the workbook called 'Calc_Helper' that contains the values of the hidden column, and the excel formula references that sheet. That is fine when we export a single worksheet but we run into problems when we export a second grid to the same workbook as a sheet called 'Calc_Helper' already exists and an error message is inserted into the formula cell.
I understand that we are using a v old version of infragistics, so my real question is whether this has been fixed in the current version?
As an aside it seems unnecessary to create a hidden sheet with the values of the hidden columns in, an alternative would have been to embed the value directly in the formula instead of the column reference and use a specific formula for each formula cell in the sheet. Alternatively reusing (an unused section of) the existing Calc_Helper sheet would work, as would creating a seperate helper sheet for it.
This illustrates the problem:
// Create a datatable with two double columns a and b var dt = new DataTable(); dt.Columns.Add("a", typeof(double)); dt.Columns.Add("b", typeof(double)); dt.Rows.Add(new object[] { 1.0, 2.0 }); // bind to grid, create formula column c = a + b var grid = new UltraGrid() { Name = "grid" }; grid.CalcManager = new UltraCalcManager(); grid.DataSource = dt; var col = grid.Rows.Band.Columns.Add("c", "c"); col.Formula = "[a] + [b]"; // Export to a workbook creates a single sheet as expected var exporter = new Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter(); var workbook = new Workbook(); exporter.Export(grid, workbook); Debug.Assert(workbook.Worksheets.Count == 1); // Hide a source column, exporting the grid creates a second hidden worksheet called 'Calc_Helper' grid.Rows.Band.Columns[0].Hidden = true; exporter.Export(grid, workbook); Debug.Assert(workbook.Worksheets.Count == 2); Debug.Assert(workbook.Worksheets[1].Name == "Calc_Helper"); // Add a worksheet and export to it, the calculated cell will have an error var ws = workbook.Worksheets.Add("Grid2"); exporter.Export(grid, ws); Debug.Assert(ws.GetCell("B2").Value == "A worksheet with the name \"Calc_Helper\" already exists in the workbook.\r\nParameter name: name");
Cheers
Martin
Hello ,
It seems that this was a bug and current is created separate “Calc_Helper[0]” for each grid that need this sheet. So my suggestion is to upgrade to the latest service release of the version which you are using, hoping that this was fixed there (since you didn’t mentioned which version you are using I cannot verify this in this version). Or you could download latest volume for a 30 days trail period in order to evaluate this. Also don’t forget to add the grid to the control collection of the owner form, otherwise your grid won’t be populated with data since component won’t have Bindingmamnger
Please let me know if you have any further questions.
Thanks for the prompt response. I was coy about the version as we are still using 2008.3.1009!, although it is a big job converting our project to the latest version this at least gives me some more leverage to persuade the powers that be.
Also you are right about the BindingManager, I developed the sample with the grid added to the form but added the declaration before pasting for the purposes of the sample. Wel spotted tho.
Hello,
Is there anything else that I could do for you regarding this matter.
Thank you for using Infragistics Components.
Actually it is really trivial to rename the Calc_Helper worksheet to Calc_HelperN after exporting each grid, this automatically adjusts the formula references too so it is a 1 line fix!
Thanks for your help.
Yes, this is another resolution of this issue J
Thank you for using Infragistics components.