---
url: /process-functions/workview-export.md
description: Runs a workview and exports it as an Excel file.
---

# 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](/process-functions/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

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();
```

## Related

* [workview.execute](/process-functions/workview-execute)
