# write

Source: /xlsx-format/api-reference/functions/write

Write a WorkBook to an in-memory representation.

Supports XLSX (default), CSV, TSV, and HTML output formats via opts.bookType.

```ts
write(wb: WorkBook, opts?: BinaryWriteOptions | SpreadsheetWriteOptions): Promise<Uint8Array>
write(wb: WorkBook, opts: Base64WriteOptions | TextWriteOptions): Promise<string>
write(wb: WorkBook, opts?: WriteOptions): Promise<WriteResult>
```

## Overload

```ts
write(wb: WorkBook, opts?: BinaryWriteOptions | SpreadsheetWriteOptions): Promise<Uint8Array>
```

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| ` wb ` | [` WorkBook `](</xlsx-format/api-reference/interfaces/workbook/>) | Yes | WorkBook object to serialize |
| ` opts ` | ` BinaryWriteOptions \| SpreadsheetWriteOptions ` | No | Write options controlling output format and behavior |

### Returns

` Promise<Uint8Array> `

A string for base64 or text output; otherwise a portable Uint8Array

## Overload

```ts
write(wb: WorkBook, opts: Base64WriteOptions | TextWriteOptions): Promise<string>
```

### Parameters

| Name | Type | Required |
| --- | --- | --- |
| ` wb ` | [` WorkBook `](</xlsx-format/api-reference/interfaces/workbook/>) | Yes |
| ` opts ` | ` Base64WriteOptions \| TextWriteOptions ` | Yes |

### Returns

` Promise<string> `

## Overload

```ts
write(wb: WorkBook, opts?: WriteOptions): Promise<WriteResult>
```

### Parameters

| Name | Type | Required |
| --- | --- | --- |
| ` wb ` | [` WorkBook `](</xlsx-format/api-reference/interfaces/workbook/>) | Yes |
| ` opts ` | [` WriteOptions `](</xlsx-format/api-reference/interfaces/writeoptions/>) | No |

### Returns

` Promise< `[` WriteResult `](</xlsx-format/api-reference/types/writeresult/>)` > `
