# Troubleshooting

> Fix Excel Engine license warnings, keys that do not reach workers, dates that read as numbers or shift by a day, files that will not open and console warnings about skipped input.

The Excel Engine has no user interface, so it never shows a watermark. Everything it has to say goes to the console: license messages start with `[Birch UI]` and input problems start with `[@birchui/excel]`.

| Symptom | Jump to |
| --- | --- |
| `[Birch UI] No license key is set for Birch UI Excel Engine…` | [A license warning is logged](#a-license-warning-is-logged) |
| The warning appears only in a worker or in Node | [The key does not reach a worker or Node](#the-key-does-not-reach-a-worker-or-node) |
| The key is set but the engine still warns | [Two copies of @birchui/license are installed](#two-copies-of-birchuilicense-are-installed) |
| Dates come back as numbers such as `46301` | [Dates read as numbers](#dates-read-as-numbers) |
| Dates are one day early or late | [Dates shift by a day](#dates-shift-by-a-day) |
| Formula cells read as `null` | [Formula cells are empty](#formula-cells-are-empty) |
| `Invalid zip archive` or `Not an xlsx file` | [A file cannot be read](#a-file-cannot-be-read) |
| `[@birchui/excel] Ignored invalid color…` | [Input is skipped with a warning](#input-is-skipped-with-a-warning) |
| `RangeError` when writing | [Writing throws a RangeError](#writing-throws-a-rangeerror) |
| `downloadXlsx` fails in a worker or Node | [downloadXlsx fails outside a page](#downloadxlsx-fails-outside-a-page) |
| The page freezes during a large export | [Large files freeze the page](#large-files-freeze-the-page) |

## A license warning is logged

**Cause.** The engine checks its key offline the first time you write or read a workbook. Without a key that covers it, every function keeps working and one warning is logged per page or process:

```text
[Birch UI] No license key is set for Birch UI Excel Engine. All features keep working. Purchase a license at https://birchui.com/pricing
```

Other reasons replace the first sentence: `The license key for Birch UI Excel Engine is not a valid Birch UI key.`, `… has an invalid signature; it was altered or not issued by Birch UI.`, `The license for <licensee> does not include Birch UI Excel Engine.` or a trial expiry date.

**Fix.** Set the key once with `setLicenseKey` from `@birchui/license`, or pass it to each call:

```ts title="export-invoices.ts"
import { downloadXlsx, type XlsxWorkbook } from '@birchui/excel';

export function exportInvoices(workbook: XlsxWorkbook) {
  return downloadXlsx(workbook, 'invoices-2026-11.xlsx', { licenseKey: import.meta.env.VITE_BIRCHUI_LICENSE_KEY });
}
```

A key for `excel`, Grid Pro, Pivot Studio, Spreadsheet or all products activates the engine. Grid Pro's Excel export passes the grid's key for you. See [The Excel Engine](https://docs.birchui.com/getting-started/licensing.md#the-excel-engine).

## The key does not reach a worker or Node

**Cause.** A Web Worker and a Node process each load their own copy of `@birchui/license`. A key set with `setLicenseKey` on the main page does not exist there. In a server-rendered app, a key read from a private environment variable is also `undefined` in browser code.

**Fix.** Call `setLicenseKey` inside the worker or Node entry point, or pass `licenseKey` to `writeXlsx`, `writeXlsxSync` and `readXlsx` there. Expose the key to browser code through a public variable such as `VITE_BIRCHUI_LICENSE_KEY` or `NEXT_PUBLIC_BIRCHUI_LICENSE_KEY`. See [License keys in workers](https://docs.birchui.com/excel/workers.md#license-keys-in-workers).

## Two copies of @birchui/license are installed

**Cause.** `setLicenseKey` stores the key in the module that runs it. If your app and `@birchui/excel` resolve to different copies of `@birchui/license`, the engine reads an empty store.

**Fix.** Run `npm ls @birchui/license`. Upgrade all `@birchui/*` packages to the same version and run `npm dedupe`, or add an `overrides` entry in `package.json`. Passing `licenseKey` per call works regardless.

## Dates read as numbers

**Cause.** Spreadsheets store dates as serial numbers. `readXlsx` returns a `Date` only when the cell's number format shows a date or time. A column of serials with the General format, or a CSV exported to xlsx by another tool, reads as numbers.

**Fix.** Convert the serials yourself:

```ts
import { serialToDate } from '@birchui/excel';

const shipments = rows.map((row) => ({ ...row, shippedOn: serialToDate(Number(row.shippedOn)) }));
```

When you write, pass `Date` values, or a serial from `dateToSerial` with a date `numFmt`, so Excel shows a date. See [Dates](https://docs.birchui.com/excel/utilities.md#dates) and [Date and time formats](https://docs.birchui.com/excel/styles.md#date-and-time-formats).

## Dates shift by a day

**Cause.** The writer and reader work in UTC. A cell that shows `2026-10-06` reads as `2026-10-06T00:00:00.000Z`, which formats as 5 October in time zones west of UTC.

**Fix.** Format with `timeZone: 'UTC'`, or build a local date from the UTC parts:

```ts
const asCalendarDate = (value: Date) => new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate());
```

For raw serials from a workbook that uses the 1904 date system, add 1,462 days before calling `serialToDate`; `readXlsx` handles 1904 files itself. See [Dates](https://docs.birchui.com/excel/reading.md#dates).

## Formula cells are empty

**Cause.** The reader does not evaluate formulas. It returns the result the authoring application saved. Files produced by tools that save formulas without results read as `null`.

**Fix.** Open and save the file in a spreadsheet application, compute the values in your code, or load the workbook into the [Spreadsheet](https://docs.birchui.com/spreadsheet/overview.md), which has a formula engine.

## A file cannot be read

**Cause.** `readXlsx` rejects when the input is not an xlsx workbook. `Invalid zip archive: …` means a legacy `.xls`, a CSV renamed to `.xlsx`, a truncated download or a password-protected workbook. `Not an xlsx file: the workbook part is missing` means a different Office file such as `.docx`. `DEFLATE entries require DecompressionStream…` means the runtime lacks `DecompressionStream`.

**Fix.** Catch the error and ask the user to save the file as `.xlsx`. Use a current browser or Node 20 or later. See [Errors](https://docs.birchui.com/excel/reading.md#errors).

## A file is rejected for its size

**Cause.** `readXlsx` and `unzip` reject with a `ZipLimitError` when a file expands beyond the reader's size limits. The limits stop a small file that was built to expand into gigabytes from exhausting memory. The message names the limit, for example:

```text
Zip entry "xl/media/image1.bmp" expands 812:1, over the limit of 200:1. Pass limits.maxRatio to allow it.
```

A workbook of real data rarely reaches the defaults. The usual legitimate cause is a large picture stored without compression, which trips `maxRatio`. A single sheet needs well over ten million cells to reach `maxEntryBytes`.

**Fix.** Check `error.code` and `error.entryName` to see which limit and which part of the file. If you trust the source of the file, raise that limit with the `limits` option. If you do not, tell the user the file is too large. See [Size limits](https://docs.birchui.com/excel/reading.md#size-limits).

## Input is skipped with a warning

**Cause.** Values Excel would reject are fixed or skipped, and collected into one `console.warn` per file, for example:

```text
[@birchui/excel] Ignored invalid color "teal"; expected "#RRGGBB".
Ignored merge range "A1:C2" on sheet "Invoices": it overlaps A2:B3.
Truncated text longer than 32767 characters, the Excel cell limit.
```

**Fix.** Use six-digit hex colours such as `#0F766E`, keep merge ranges from overlapping, use valid ranges for `autoFilter`, and keep cell text under 32,767 characters.

## Writing throws a RangeError

**Cause.** A sheet with more than 1,048,576 rows or 16,384 columns, or a file over 4 GiB, cannot be opened by Excel, so the writer throws instead of producing it.

**Fix.** Split the data across several sheets or files. See [Limits](https://docs.birchui.com/excel/writing.md#limits).

## downloadXlsx fails outside a page

**Cause.** `downloadXlsx` needs `document` to trigger a download, which workers and Node do not have.

**Fix.** Call `writeXlsx` in the worker or on the server, then download the returned bytes on the main thread or send them in an HTTP response. See [Where it runs](https://docs.birchui.com/excel/overview.md#where-it-runs).

## Large files freeze the page

**Cause.** Reading and writing run on the thread that calls them. A workbook with hundreds of thousands of cells blocks the page while it is built or parsed, and `writeXlsxSync` always blocks.

**Fix.** Use the async functions in a Web Worker. See [Writing in a worker](https://docs.birchui.com/excel/workers.md#writing-in-a-worker) and [Reading in a worker](https://docs.birchui.com/excel/workers.md#reading-in-a-worker). The package is side-effect free, so a worker bundle includes only the functions it imports.

## Related

- [API reference: @birchui/excel](https://docs.birchui.com/api/excel.md)
- [Licensing and activation](https://docs.birchui.com/getting-started/licensing.md)
