Click or drag to resize

Defining Formulas in Excel spreadsheets with ExpertXls Library for Excel

The ExpertXls Excel Spreadsheet Library for .NET offers the possibility of assigning formulas to cells and ranges of cells either in A1 or R1C1 notation. The library offers support both for ordinary formulas and for the array formulas.

A formula string can be assigned to a cell or range using the Formula property of the ExcelRange class.

An array formula string can be assigned to a cell or range using the FormulaArray property of the ExcelRange class.

The the Formula and FormulaArray properties assume the formulas are expressed in A1 notation. For assigning a formula in R1C1 notation the corresponding FormulaR1C1 and FormulaArrayR1C1 can be used.

Code Samples

The sample code below shows how to assign various formulas to the cells of a worksheet:

// the excel viewer will calculate the sum of the numbers in the range C7:G7
// and will assign the result to C9 cell
worksheet["C9"].Formula = "=SUM(C7:G7)";

// the excel viewer will calculate the minimum value in the range C7:G7
// and will assign the result to C9 cell
worksheet["C9"].Formula = "=MIN(C7:G7)";