I tried thisbriefly and it doesn't work as intended
Infragistics.Excel.Workbook workbook = new Workbook(); workbook.Worksheets.Add("test"); Infragistics.Excel.Worksheet sheet = workbook.Worksheets[0]; sheet.Rows[0].Cells[0].Value = 5.05; sheet.Rows[1].Cells[0].Value = "=A1+1";
when I wxport it to excel, A2 shows =A1+1, and I have to go into the cell and press enter again for it to update to 6.05, and pressing F9 doesn't update the cell. How can I do this properly? Thank you
Support for adding formulas to workbooks was not added until version 7.2. That is when this class was added.
H Andre, thank you, what build is this? I tried to find the Formula function in build 6.2 and 7.1 but can't find it. Thank you.
You can also use the following code:
Infragistics.Excel.Workbook workbook = new Workbook();
workbook.Worksheets.Add("test");Infragistics.Excel.Worksheet sheet = workbook.Worksheets[0];sheet.Rows[0].Cells[0].Value = 5.05;sheet.Rows[1].Cells[0].ApplyFormula("=A1+1");
Hi,
you need to parse the formula like this (untested!):
Infragistics.Excel.Formula formula = Infragistics.Excel.Formula.Parse("=A1+1", Infragistics.Excel.CellReferenceMode.A1);
Infragistics.Excel.WorksheetRegion region = new Infragistics.Excel.WorksheetRegion(sheet, 2,2,2,2); // check the parameters, I'm not sure about those!
formula.ApplyTo(region);
Hope that helps!