# setArrayFormula

Source: /xlsx-format/api-reference/functions/setarrayformula

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.

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

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| ` ws ` | [` WorkSheet `](</xlsx-format/api-reference/interfaces/worksheet/>) | Yes | The worksheet to modify |
| ` range ` | ` string \| { s: { r: number; c: number }; e: { r: number; c: number } } ` | Yes | The target range as a string (e.g. "A1:C3") or range object |
| ` formula ` | ` string ` | Yes | The array formula expression (without surrounding braces) |
| ` dynamic ` | ` boolean ` | No | If true, mark as a dynamic array formula (spill) |

## Returns

[` WorkSheet `](</xlsx-format/api-reference/interfaces/worksheet/>)

The modified worksheet
