Other API Samples

Live SpreadsheetGear API Samples

Range Samples Values and Formulas Create Array Formula

Creates Array Formulas on both a single cell and range of cells.

// Open workbook with sample data and create some local variables.
SpreadsheetGear.IWorkbook workbook = 
SpreadsheetGear.IWorksheet worksheet = workbook.ActiveWorksheet;
SpreadsheetGear.IRange cells = worksheet.Cells;

// Use IRange.ArrayFormula to enter a formula array, in this case on the range
// C2:C6, which provides a total (cost * quantity) for each line item.
cells["C2:C6"].FormulaArray = "=A2:A6*B2:B6";

// Enter a single-cell array formula to sum the total of all line items.
cells["C8"].FormulaArray = "=SUM($A$2:$A$6*$B$2:$B$6)";
Run This Sample
Download File

Download an Excel Open XML Workbook (*.xlsx) file with the results of this sample.

Supporting Files

The following files are utilized by this sample:

Related Samples