Hi,
Thanks for the screen shots.
Well, as per your screen shot, you are doing calculating formulas for a worksheet/range of cells by using VBA codes in MS Excel.
Well, we have further evaluated and I think we already provide this feature (Calculate Formulas for a Worksheet only), please check this overloaded method of Worksheet.CalculateFormula(), here is the complete description:
public void CalculateFormula(
bool recursive ,
bool ignoreError ,
ICustomFunction customFunction
);
Parameters
-
recursive
- True means if the worksheet' cells depend on the cells of other worksheets,
the dependent cells in other worksheets will be calculated too. False means all
the formulas in the worksheet have been calculated and the values are right.
-
ignoreError
- Indicates if hide the error in calculating formulas. The error may be
unsupported function, external links, etc.
-
customFunction
- The custom formula calculation functions to extend the calculation
engine.
I have written a simple example for you here too. Please put null for the last parameter if you do not have any custom function.
Sample code:
//Create a workbook
Workbook workbook = new Workbook();
//Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Put 20 in cell A1
Cell cellA1 = worksheet.Cells["A1"];
cellA1.PutValue(20);
//Put 30 in cell A2
Cell cellA2 = worksheet.Cells["A2"];
cellA2.PutValue(30);
//Specify formula on A3
Cell cellA3 = worksheet.Cells["A3"];
cellA3.Formula = "=Sum(A1:A2)";
worksheet.CalculateFormula(true,false, null);
int val = cellA3.IntValue;
MessageBox.Show("Calculated Value: " + val.ToString()); //50 - OK
workbook.Save("e:\\test2\\output.xls");
Please try this overload and let me know how it goes related to performance.
If you still have any performance issue, kindly give us more details, e.g sample project, Excel files, screen shots etc. We will check your issue soon.
Thank you.