Skip to content

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 ​

ParameterTypeDescription
workviewstringThe workview's name or id.
titleDimensionsstring[]The title dimensions' ids. Use dimension.getId to get one from a name.
titleElementsstring[]The element to select for each title dimension, in the same order.
formatstringReturned in the result as it is. The file is always .xlsx.

Returns ​

string

The file, as a JSON string. Use JSON.parse() to read it. It has:

  • name: the file name, such as Monthly_PL.xlsx.
  • data: the file, base64-encoded.
  • content-type: the file's data URI prefix.
  • format: the format you passed.
  • result: 1 when 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();