Write Excel Cell
Write Excel Cell
Section titled “Write Excel Cell”Type: excel-write-cell · Package: Excel Activities v1.0.6 · Output: —
Writes a value to a specific cell. Use it to place a single value: a total in B10, a processing date in A1, a status in a fixed cell. It creates the file if it doesn’t exist.
How it works
Section titled “How it works”It writes value to the given cell of the sheet, replacing whatever was there and keeping the cell’s formatting. Accepts session or path — see the two modes.
- Value type: a number (
int,double,decimal), a date (DateTime) or a boolean is stored with its type, so Excel can calculate with it. Any other value is stored as text, including text that looks like a number ("1500"): to write a number, use an expression that returns a number (1500,toNumber(x)). - Null value: if
valueisnull, the cell is not modified. To empty a cell, use Clear Excel Range withrange = "B3". - If the file or the sheet don’t exist, they are created.
- In fast mode it saves the file on every call; in session mode, on Excel Save or Excel Close.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
cell | string | — | Cell address, e.g. "B3". |
value | object | — | The value or expression to write. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanExcelSession | — | Excel Open session (instead of path). |
path | string | — | Path to the .xlsx (created if it doesn’t exist; required if there is no session). |
sheet | string | int | — | Sheet name or index; created if it doesn’t exist. If omitted, the first sheet (or "Sheet1" in a new workbook). |
Output
Section titled “Output”This activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'cell' is required. | cell is missing. |
'session' or 'path' is required. | Neither session nor path is set. |
'…' is not A1 address or workbook named range. | cell is not a valid address (e.g. "1A"). Use the form "B3". |
The process cannot access the file '…' because it is being used by another process. | The file is open in another program when saving. Close it or retry with Retry. |
Example
Section titled “Example”Write Excel Cell path = "C:/output/control.xlsx" sheet = "Log" cell = "A1" value = "Processed"Write Excel Cell path = "C:/output/control.xlsx" sheet = "Log" cell = "B1" value = now()Write Excel Cell path = "C:/output/control.xlsx" sheet = "Log" cell = "C1" value = rowCount(invoices)now() is stored as a date and rowCount(...) as a number, so Excel can format them and calculate with them.
Related activities
Section titled “Related activities”- Read Excel Cell — read a cell.
- Write Excel Range — write several cells at once.