# @birchui/excel API reference

> Birch UI Excel Engine: xlsx writer and reader for the browser and Node

```bash
npm install @birchui/excel
```

## @birchui/excel

### cellRef

Kind: function. Import from `@birchui/excel`.

```ts
function cellRef(rowIndex: number, colIndex: number): string
```

| Parameter | Type | Description |
| --- | --- | --- |
| `rowIndex` | `number` |  |
| `colIndex` | `number` |  |

### columnLetter

Kind: function. Import from `@birchui/excel`.

```ts
function columnLetter(index: number): string
```

| Parameter | Type | Description |
| --- | --- | --- |
| `index` | `number` |  |

### dateToSerial

Kind: function. Import from `@birchui/excel`.

```ts
function dateToSerial(date: Date): number
```

| Parameter | Type | Description |
| --- | --- | --- |
| `date` | `Date` |  |

### downloadXlsx

Kind: function. Import from `@birchui/excel`.

```ts
function downloadXlsx(workbook: XlsxWorkbook, fileName: string, options: XlsxWriteOptions = {}): Promise<void>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `workbook` | `XlsxWorkbook` |  |
| `fileName` | `string` |  |
| `options?` | `XlsxWriteOptions` |  |

### parseCellRef

Kind: function. Import from `@birchui/excel`.

```ts
function parseCellRef(ref: string): CellPosition
```

| Parameter | Type | Description |
| --- | --- | --- |
| `ref` | `string` |  |

### readXlsx

Kind: function. Import from `@birchui/excel`.

```ts
function readXlsx(data: Uint8Array | ArrayBuffer | Blob, options: XlsxReadOptions = {}): Promise<XlsxReadResult>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `data` | `Uint8Array \| ArrayBuffer \| Blob` |  |
| `options?` | `XlsxReadOptions` |  |

### serialToDate

Kind: function. Import from `@birchui/excel`.

```ts
function serialToDate(serial: number): Date
```

| Parameter | Type | Description |
| --- | --- | --- |
| `serial` | `number` |  |

### sheetToObjects

Kind: function. Import from `@birchui/excel`.

```ts
function sheetToObjects(sheet: XlsxReadSheet, options: { headerRow?: number } = {}): Record<string, XlsxPrimitive>[]
```

| Parameter | Type | Description |
| --- | --- | --- |
| `sheet` | `XlsxReadSheet` |  |
| `options?` | `{ headerRow?: number }` |  |

### unzip

Kind: function. Import from `@birchui/excel`.

```ts
function unzip(data: Uint8Array, options: UnzipOptions = {}): Promise<Map<string, Uint8Array>>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `data` | `Uint8Array` |  |
| `options?` | `UnzipOptions` |  |

### writeXlsx

Kind: function. Import from `@birchui/excel`.

```ts
function writeXlsx(workbook: XlsxWorkbook, options: XlsxWriteOptions = {}): Promise<Uint8Array>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `workbook` | `XlsxWorkbook` |  |
| `options?` | `XlsxWriteOptions` |  |

### writeXlsxSync

Kind: function. Import from `@birchui/excel`.

```ts
function writeXlsxSync(workbook: XlsxWorkbook, options: Pick<XlsxWriteOptions, 'licenseKey'> = {}): Uint8Array
```

| Parameter | Type | Description |
| --- | --- | --- |
| `workbook` | `XlsxWorkbook` |  |
| `options?` | `Pick<XlsxWriteOptions, 'licenseKey'>` |  |

### zip

Kind: function. Import from `@birchui/excel`.

```ts
function zip(files: ZipInputFile[], options: { compress?: boolean } = {}): Promise<Uint8Array>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `files` | `ZipInputFile[]` |  |
| `options?` | `{ compress?: boolean }` |  |

### zipSync

Kind: function. Import from `@birchui/excel`.

```ts
function zipSync(files: ZipInputFile[]): Uint8Array
```

| Parameter | Type | Description |
| --- | --- | --- |
| `files` | `ZipInputFile[]` |  |

### ZipLimitError

Kind: class. Import from `@birchui/excel`.

```ts
class ZipLimitError extends Error
new ZipLimitError(code: ZipLimitCode, message: string, detail: { limit: number; actual: number; entryName?: string })
```

| Property | Type | Description |
| --- | --- | --- |
| `readonly code` | `ZipLimitCode` |  |
| `readonly limit` | `number` |  |
| `readonly actual` | `number` |  |
| `readonly entryName` | `string \| undefined` |  |

### DEFAULT_ZIP_LIMITS

Kind: const. Import from `@birchui/excel`.

```ts
const DEFAULT_ZIP_LIMITS: Readonly<ZipLimits>
```

### UnzipOptions

Kind: interface. Import from `@birchui/excel`.

```ts
interface UnzipOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `limits?` | `Partial<ZipLimits>` |  |

### XlsxBorderSide

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxBorderSide
```

| Property | Type | Description |
| --- | --- | --- |
| `style` | `'thin' \| 'medium' \| 'thick' \| 'dashed' \| 'dotted' \| 'double'` |  |
| `color?` | `string` |  |

### XlsxBorderSides

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxBorderSides
```

| Property | Type | Description |
| --- | --- | --- |
| `top?` | `XlsxBorderSide` |  |
| `right?` | `XlsxBorderSide` |  |
| `bottom?` | `XlsxBorderSide` |  |
| `left?` | `XlsxBorderSide` |  |

### XlsxCell

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxCell
```

| Property | Type | Description |
| --- | --- | --- |
| `value` | `XlsxPrimitive \| XlsxFormula` |  |
| `style?` | `XlsxCellStyle` |  |

### XlsxCellStyle

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxCellStyle
```

| Property | Type | Description |
| --- | --- | --- |
| `font?` | `XlsxFont` |  |
| `bold?` | `boolean` |  |
| `italic?` | `boolean` |  |
| `color?` | `string` |  |
| `fill?` | `string` |  |
| `numFmt?` | `string` |  |
| `align?` | `'left' \| 'center' \| 'right'` |  |
| `valign?` | `'top' \| 'center' \| 'bottom'` |  |
| `wrap?` | `boolean` |  |
| `indent?` | `number` |  |
| `border?` | `XlsxBorderSide \| XlsxBorderSides` |  |

### XlsxColumn

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxColumn
```

| Property | Type | Description |
| --- | --- | --- |
| `width?` | `number` |  |
| `hidden?` | `boolean` |  |
| `outlineLevel?` | `number` |  |
| `style?` | `XlsxCellStyle` |  |

### XlsxFont

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxFont
```

| Property | Type | Description |
| --- | --- | --- |
| `bold?` | `boolean` |  |
| `italic?` | `boolean` |  |
| `underline?` | `boolean` |  |
| `color?` | `string` |  |
| `size?` | `number` |  |
| `name?` | `string` |  |

### XlsxFormula

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxFormula
```

| Property | Type | Description |
| --- | --- | --- |
| `formula` | `string` |  |
| `value?` | `XlsxPrimitive` |  |

### XlsxReadOptions

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxReadOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `licenseKey?` | `string` |  |
| `limits?` | `Partial<ZipLimits>` |  |

### XlsxReadResult

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxReadResult
```

| Property | Type | Description |
| --- | --- | --- |
| `sheets` | `XlsxReadSheet[]` |  |

### XlsxReadSheet

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxReadSheet
```

| Property | Type | Description |
| --- | --- | --- |
| `name` | `string` |  |
| `rows` | `XlsxPrimitive[][]` |  |
| `merges` | `string[]` |  |

### XlsxRow

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxRow
```

| Property | Type | Description |
| --- | --- | --- |
| `cells` | `XlsxCellInput[]` |  |
| `outlineLevel?` | `number` |  |
| `collapsed?` | `boolean` |  |
| `hidden?` | `boolean` |  |
| `height?` | `number` |  |
| `style?` | `XlsxCellStyle` |  |

### XlsxSheet

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxSheet
```

| Property | Type | Description |
| --- | --- | --- |
| `name` | `string` |  |
| `columns?` | `XlsxColumn[]` |  |
| `rows` | `(XlsxRow \| XlsxCellInput[])[]` |  |
| `freeze?` | `{ rows?: number; columns?: number }` |  |
| `autoFilter?` | `boolean \| string` |  |
| `merges?` | `string[]` |  |
| `outlineSummaryBelow?` | `boolean` |  |
| `rightToLeft?` | `boolean` |  |
| `tabColor?` | `string` |  |

### XlsxWorkbook

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxWorkbook
```

| Property | Type | Description |
| --- | --- | --- |
| `sheets` | `XlsxSheet[]` |  |
| `creator?` | `string` |  |
| `created?` | `Date` |  |
| `title?` | `string` |  |

### XlsxWriteOptions

Kind: interface. Import from `@birchui/excel`.

```ts
interface XlsxWriteOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `compress?` | `boolean` |  |
| `licenseKey?` | `string` |  |

### ZipInputFile

Kind: interface. Import from `@birchui/excel`.

```ts
interface ZipInputFile
```

| Property | Type | Description |
| --- | --- | --- |
| `name` | `string` |  |
| `data` | `Uint8Array` |  |

### ZipLimits

Kind: interface. Import from `@birchui/excel`.

```ts
interface ZipLimits
```

| Property | Type | Description |
| --- | --- | --- |
| `maxEntries` | `number` |  |
| `maxEntryBytes` | `number` |  |
| `maxTotalBytes` | `number` |  |
| `maxRatio` | `number` |  |

### XlsxCellInput

Kind: type. Import from `@birchui/excel`.

```ts
type XlsxCellInput = XlsxCell | XlsxPrimitive;
```

### XlsxPrimitive

Kind: type. Import from `@birchui/excel`.

```ts
type XlsxPrimitive = string | number | boolean | Date | null | undefined;
```

### ZipLimitCode

Kind: type. Import from `@birchui/excel`.

```ts
type ZipLimitCode = 'too-many-entries' | 'entry-too-large' | 'archive-too-large' | 'ratio-too-high';
```
