Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/PARITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,30 @@ field to either interface fails `tsc` until it is registered — as a probe
that round-trips, or as a one-way entry with its reason. That register,
not this list, is the thing that stays current.

### Newer functions read back with their `_xlfn.` prefix

Functions added after Excel 2007 are stored under a prefixed name —
`_xlfn.XLOOKUP`, `_xlfn.IFS`, `_xlfn._xlws.FILTER` — that Excel hides in
the formula bar. The writer adds the prefix to cell, conditional
formatting, data validation, table total and defined name formulas, and
the reader keeps formula text as the file has it. So a formula written as
`XLOOKUP(…)` reads back as `_xlfn.XLOOKUP(…)`: the same formula, but a
strict equality check on a round trip sees the difference. Writing the
prefixed form again does not prefix it twice (#597).

The names LET and LAMBDA bind get theirs too: `LET(x,2,x*3)` is written
`_xlfn.LET(_xlpm.x,2,_xlpm.x*3)`, and an optional `[b]` is bound as
`_xlop.b`. A use of a bound name is written in the spelling of its
binding, as Excel writes it, so `LET(Ab,2,aB)` reads back as
`_xlfn.LET(_xlpm.Ab,2,_xlpm.Ab)`.

One prefix is not added: a function passed as an argument rather than
called, as in `GROUPBY(A2:A3,B2:B3,SUM)`, is stored `_xleta.SUM`. hucre
writes it as given, and Excel computes `#NAME?` for it. Telling such a
name from a defined name of the same spelling needs Excel's whole
function list. Pass a LAMBDA instead — `GROUPBY(A2:A3,B2:B3,LAMBDA(x,SUM(x)))`
— which is written in its stored form.

### Styles read out of a file are shared, not copied

`readXlsx(…, { readStyles: true })` gives every cell its own `CellStyle`
Expand Down
17 changes: 16 additions & 1 deletion src/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ export interface Cell {
* raw `TRUE`/`FALSE` value.
*/
checkbox?: boolean
/**
* Formula text in the form the file stores it. Functions newer than
* Excel 2007 are stored with a prefix (`_xlfn.XLOOKUP`,
* `_xlfn._xlws.FILTER`) that Excel hides in the formula bar. The writer
* adds it, so `XLOOKUP(…)` and `_xlfn.XLOOKUP(…)` write the same file,
* and a read hands back the prefixed form (#597). Conditional
* formatting, data validation, table total and defined name formulas
* are treated the same way, and so are the names LET and LAMBDA bind,
* stored as `_xlpm.x` (`_xlop.x` for an optional `[x]` parameter).
*/
formula?: string
formulaResult?: CellValue
/** Formula type: "shared" | "array". Undefined means normal formula. */
Expand Down Expand Up @@ -407,7 +417,12 @@ export interface SplitPane {

export interface NamedRange {
name: string
/** Cell range reference (e.g. "Sheet1!$A$1:$D$10") */
/**
* Cell range reference (e.g. "Sheet1!$A$1:$D$10"), or any formula a
* defined name can hold. Newer functions get their `_xlfn.` prefix on
* write, and a named LAMBDA's parameters their `_xlpm.`, as in
* `Cell.formula` (#597).
*/
range: string
/** Scope: undefined = workbook level, string = sheet name */
scope?: string
Expand Down
Loading