workview.export
Runs a workview with the given title elements and exports the results as an Excel file.
js
workview.export(workview, titleDimensions, titleElements, format)Parameters
| Parameter | Type | Description |
|---|---|---|
workview | string | The workview's name or id. |
titleDimensions | string[] | The title dimensions' ids. Use dimension.getId to get one from a name. |
titleElements | string[] | The element to select for each title dimension, in the same order. |
format | string | Returned in the result as it is. The file is always .xlsx. |
Returns
stringThe file, as a JSON string. Use JSON.parse() to read it. It has:
name: the file name, such asMonthly_PL.xlsx.data: the file, base64-encoded.content-type: the file's data URI prefix.format: theformatyou passed.result:1when the export worked.
Returns a string starting with "Error:" when the workview can't be found.
Examples
js
const yearId = dimension.getId("Year");
const file = JSON.parse(workview.export("Monthly P&L", [yearId], ["2026"], "xlsx"));
new EmailBuilder()
.to("user@example.com")
.subject("Monthly P&L")
.body("The report is attached.")
.attachBase64(file.name, file.data)
.send();