# @salmonui/export/xlsx API reference

> 9 exported symbols of @salmonui/export/xlsx: 2 functions, 6 interfaces and 1 constant.

Canonical: https://salmonui.dev/docs/reference/export/xlsx

```ts
import { … } from '@salmonui/export/xlsx';
```

## Functions

### exportXlsx

Kind: function

Page: https://salmonui.dev/docs/reference/export/xlsx/exportXlsx

```ts
function exportXlsx<Row>(source: ExportSource<Row> | readonly ExportSource<Row>[], options?: XlsxExportOptions<Row>, handlers?: ExportHandlers<Row>): Promise<ExportFile | null>;
```

Exports one grid, or several into one workbook (`layout`), as XLSX.
Resolves to `{ fileName, mimeType, data }`, or null when `onBeforeExport`
prevents it. The writer module is loaded on first use.

### writeXlsx

Kind: function

Page: https://salmonui.dev/docs/reference/export/xlsx/writeXlsx

```ts
function writeXlsx<Row>(models: ExportModel<Row> | readonly ExportModel<Row>[], options?: XlsxOptions): Promise<Uint8Array>;
```

Writes one or more export models (or engines with the `export` module) as an XLSX workbook.

## Interfaces

### ExportStyles

Kind: interface

Page: https://salmonui.dev/docs/reference/export/xlsx/ExportStyles

```ts
interface ExportStyles {
    readonly header?: ExportCellStyle;
    readonly row?: ExportCellStyle;
    readonly groupCaption?: ExportCellStyle;
    readonly aggregate?: ExportCellStyle;
}
```

Styles of the exported row kinds, merged under per-cell styles.

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `header` | `readonly header?: ExportCellStyle;` | optional |  |
| `row` | `readonly row?: ExportCellStyle;` | optional |  |
| `groupCaption` | `readonly groupCaption?: ExportCellStyle;` | optional |  |
| `aggregate` | `readonly aggregate?: ExportCellStyle;` | optional |  |

### ExportWriterOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/export/xlsx/ExportWriterOptions

```ts
interface ExportWriterOptions {
    readonly styles?: ExportStyles;
    readonly sliceMs?: number;
    readonly yield?: YieldFn;
}
```

Writer options shared by every format.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `styles` | `readonly styles?: ExportStyles;` | optional |  |
| `sliceMs` | `readonly sliceMs?: number;` | optional | Time slice in ms before the writer yields to the event loop. Default 25. |
| `yield` | `readonly yield?: YieldFn;` | optional | Awaited between slices. Default: a macrotask. |

### XlsxContent

Kind: interface

Page: https://salmonui.dev/docs/reference/export/xlsx/XlsxContent

```ts
interface XlsxContent {
    readonly gap?: number;
    readonly rows: readonly {
        readonly cells: readonly XlsxContentCell[];
    }[];
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `gap` | `readonly gap?: number;` | optional |  |
| `rows` | `readonly rows: readonly {     readonly cells: readonly XlsxContentCell[]; }[];` |  |  |

### XlsxContentCell

Kind: interface

Page: https://salmonui.dev/docs/reference/export/xlsx/XlsxContentCell

```ts
interface XlsxContentCell {
    readonly column?: number;
    readonly value?: string | number | boolean | Date | null;
    readonly colSpan?: number;
    readonly rowSpan?: number;
    readonly style?: ExportCellStyle;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `column` | `readonly column?: number;` | optional | 0-based column. Default: after the previous cell. |
| `value` | `readonly value?: string \| number \| boolean \| Date \| null;` | optional |  |
| `colSpan` | `readonly colSpan?: number;` | optional |  |
| `rowSpan` | `readonly rowSpan?: number;` | optional |  |
| `style` | `readonly style?: ExportCellStyle;` | optional |  |

### XlsxExportOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/export/xlsx/XlsxExportOptions

```ts
interface XlsxExportOptions<Row> extends ExportOptions<Row>, XlsxOptions {
}
```

Members (22):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `pages` | `pages?: "all" \| "current";` | optional, inherited | `all` (default): every page of the current query. `current`: the current page as shown. |
| `includeHiddenColumns` | `includeHiddenColumns?: boolean;` | optional, inherited | Include hidden columns. Default false. |
| `rows` | `rows?: readonly Row[];` | optional, inherited | Rows to export instead of the grid rows (for example the selected rows), with the grid's columns. |
| `columns` | `columns?: readonly ExportColumnOption[];` | optional, inherited | Export-only columns, in order. |
| `fileName` | `fileName?: string;` | optional, inherited | Download name; the format extension is added when missing. Default `export`. |
| `hierarchy` | `hierarchy?: "all" \| "expanded" \| "none";` | optional, inherited | Detail and child-grid rows: `expanded` (default), `all`, or `none`. |
| `tree` | `tree?: "all" \| "expanded";` | optional, inherited | Tree mode rows: `expanded` (default) exports the visible rows in pre-order; `all` exports every kept row regardless of expansion (XLSX `outlineCollapsed` then keeps the collapsed state). |
| `styles` | `styles?: ExportStyles;` | optional, inherited |  |
| `sliceMs` | `sliceMs?: number;` | optional, inherited | Time slice in ms before the writer yields to the event loop. Default 25. |
| `yield` | `yield?: YieldFn;` | optional, inherited | Awaited between slices. Default: a macrotask. |
| `sheetName` | `sheetName?: string;` | optional, inherited | Sheet name of a single-sheet workbook (default `Sheet1`). |
| `sheetNames` | `sheetNames?: readonly string[];` | optional, inherited | Sheet names per grid with `layout: 'sheets'`. |
| `layout` | `layout?: "sheets" \| "stacked";` | optional, inherited | Several grids in one workbook: one sheet each (`sheets`, default) or stacked on one sheet (`stacked`). |
| `gap` | `gap?: number;` | optional, inherited | Empty rows between stacked grids. Default 5. |
| `values` | `values?: "text" \| "typed";` | optional, inherited | `typed` (default): numbers, booleans, and dates as Excel values with number formats. `text`: the display text. |
| `includeHeaders` | `includeHeaders?: boolean;` | optional, inherited | Header rows. Default true. |
| `freezeHeader` | `freezeHeader?: boolean;` | optional, inherited | Freeze the header rows (in addition to pinned columns). Default false. |
| `outlineCollapsed` | `outlineCollapsed?: boolean;` | optional, inherited | Tree mode: with `tree: 'all'`, rows under a parent collapsed in the grid are written hidden and the parent row carries the outline's collapsed flag, so Excel opens with the grid's expansion. Default false (every outline open). |
| `mergeRepeatedValues` | `mergeRepeatedValues?: boolean;` | optional, inherited | Merge repeated values in consecutive data rows. Default false. |
| `compress` | `compress?: boolean;` | optional, inherited | Deflate entries (when the platform has `CompressionStream`). Default true. |
| `header` | `header?: XlsxContent;` | optional, inherited | Rows above the grid, then `gap` empty rows. |
| `footer` | `footer?: XlsxContent;` | optional, inherited | `gap` empty rows, then rows below the grid. |

### XlsxOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/export/xlsx/XlsxOptions

```ts
interface XlsxOptions extends ExportWriterOptions {
    readonly sheetName?: string;
    readonly sheetNames?: readonly string[];
    readonly layout?: 'sheets' | 'stacked';
    readonly gap?: number;
    readonly values?: 'typed' | 'text';
    readonly includeHeaders?: boolean;
    readonly freezeHeader?: boolean;
    readonly outlineCollapsed?: boolean;
    readonly mergeRepeatedValues?: boolean;
    readonly compress?: boolean;
    readonly header?: XlsxContent;
    readonly footer?: XlsxContent;
}
```

XLSX writer options.

Members (15):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `styles` | `styles?: ExportStyles;` | optional, inherited |  |
| `sliceMs` | `sliceMs?: number;` | optional, inherited | Time slice in ms before the writer yields to the event loop. Default 25. |
| `yield` | `yield?: YieldFn;` | optional, inherited | Awaited between slices. Default: a macrotask. |
| `sheetName` | `readonly sheetName?: string;` | optional | Sheet name of a single-sheet workbook (default `Sheet1`). |
| `sheetNames` | `readonly sheetNames?: readonly string[];` | optional | Sheet names per grid with `layout: 'sheets'`. |
| `layout` | `readonly layout?: 'sheets' \| 'stacked';` | optional | Several grids in one workbook: one sheet each (`sheets`, default) or stacked on one sheet (`stacked`). |
| `gap` | `readonly gap?: number;` | optional | Empty rows between stacked grids. Default 5. |
| `values` | `readonly values?: 'typed' \| 'text';` | optional | `typed` (default): numbers, booleans, and dates as Excel values with number formats. `text`: the display text. |
| `includeHeaders` | `readonly includeHeaders?: boolean;` | optional | Header rows. Default true. |
| `freezeHeader` | `readonly freezeHeader?: boolean;` | optional | Freeze the header rows (in addition to pinned columns). Default false. |
| `outlineCollapsed` | `readonly outlineCollapsed?: boolean;` | optional | Tree mode: with `tree: 'all'`, rows under a parent collapsed in the grid are written hidden and the parent row carries the outline's collapsed flag, so Excel opens with the grid's expansion. Default false (every outline open). |
| `mergeRepeatedValues` | `readonly mergeRepeatedValues?: boolean;` | optional | Merge repeated values in consecutive data rows. Default false. |
| `compress` | `readonly compress?: boolean;` | optional | Deflate entries (when the platform has `CompressionStream`). Default true. |
| `header` | `readonly header?: XlsxContent;` | optional | Rows above the grid, then `gap` empty rows. |
| `footer` | `readonly footer?: XlsxContent;` | optional | `gap` empty rows, then rows below the grid. |

## Constants

### XLSX_MIME_TYPE

Kind: const

Page: https://salmonui.dev/docs/reference/export/xlsx/XLSX_MIME_TYPE

```ts
const XLSX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
```
