Skip to content

setArrayFormula

On this page

Set an array formula across a rectangular range of cells.

The formula is stored on the top-left cell of the range (cell.f), and every cell in the range receives the cell.F property indicating the array formula extent. Optionally marks the formula as a dynamic array formula.

setArrayFormula(ws: WorkSheet, range: string | {
    s: {
        r: number;
        c: number;
    };
    e: {
        r: number;
        c: number;
    };
}, formula: string, dynamic?: boolean): WorkSheet

Parameters

NameTypeRequiredDescription
wsWorkSheetYesThe worksheet to modify
rangestring | { s: { r: number; c: number }; e: { r: number; c: number } }YesThe target range as a string (e.g. "A1:C3") or range object
formulastringYesThe array formula expression (without surrounding braces)
dynamicbooleanNoIf true, mark as a dynamic array formula (spill)

Returns

WorkSheet

The modified worksheet