@office-kit/xlsx 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -4
- package/dist/cell/cell.d.ts +12 -19
- package/dist/{cell-Df3cKRIl.mjs → cell-B5OUUdfI.mjs} +13 -7
- package/dist/cell-B5OUUdfI.mjs.map +1 -0
- package/dist/{cell-style-CNsET6WU.mjs → cell-style-CbB4nXTY.mjs} +11 -4
- package/dist/cell-style-CbB4nXTY.mjs.map +1 -0
- package/dist/cell.mjs +1 -1
- package/dist/{coordinate-Bt5Gni2I.mjs → coordinate-CxC88uBk.mjs} +31 -2
- package/dist/coordinate-CxC88uBk.mjs.map +1 -0
- package/dist/{defined-names-Ctu3F6ls.mjs → defined-names-Cmp8rbvI.mjs} +2 -2
- package/dist/{defined-names-Ctu3F6ls.mjs.map → defined-names-Cmp8rbvI.mjs.map} +1 -1
- package/dist/{differential-BPKa7wXi.mjs → differential-QLaKEiBk.mjs} +2 -2
- package/dist/{differential-BPKa7wXi.mjs.map → differential-QLaKEiBk.mjs.map} +1 -1
- package/dist/{drawing-ZJ3h4VHD.mjs → drawing-Cv6UtInY.mjs} +2 -2
- package/dist/{drawing-ZJ3h4VHD.mjs.map → drawing-Cv6UtInY.mjs.map} +1 -1
- package/dist/drawing.mjs +1 -1
- package/dist/{escape-rnWSPpWY.mjs → escape-rA5UpibT.mjs} +26 -3
- package/dist/escape-rA5UpibT.mjs.map +1 -0
- package/dist/io/load.d.ts +30 -0
- package/dist/io.mjs +2 -2
- package/dist/{iterparse-DZE0zy2M.mjs → iterparse-CZoRXvZW.mjs} +2 -2
- package/dist/{iterparse-DZE0zy2M.mjs.map → iterparse-CZoRXvZW.mjs.map} +1 -1
- package/dist/{load-B1sK-LjT.mjs → load-BpnCPv1S.mjs} +84 -45
- package/dist/load-BpnCPv1S.mjs.map +1 -0
- package/dist/{manifest-pLmx7KYh.mjs → manifest-9p0ccqmR.mjs} +10 -11
- package/dist/manifest-9p0ccqmR.mjs.map +1 -0
- package/dist/node.mjs +1 -1
- package/dist/packaging.mjs +1 -1
- package/dist/{parser-By6RWZVW.mjs → parser-B1tB9YaE.mjs} +15 -5
- package/dist/parser-B1tB9YaE.mjs.map +1 -0
- package/dist/{reader-DHMxLBQV.mjs → reader-pC7bxYAs.mjs} +30 -7
- package/dist/reader-pC7bxYAs.mjs.map +1 -0
- package/dist/{save-DmdWwxmw.mjs → save-1Z3344nz.mjs} +8 -8
- package/dist/{save-DmdWwxmw.mjs.map → save-1Z3344nz.mjs.map} +1 -1
- package/dist/schema.mjs +1 -1
- package/dist/{serialize-BC2Wu3bR.mjs → serialize-BtxgssFK.mjs} +24 -7
- package/dist/serialize-BtxgssFK.mjs.map +1 -0
- package/dist/{serializer-C6nm0mRJ.mjs → serializer-N6XIwsgp.mjs} +3 -3
- package/dist/{serializer-C6nm0mRJ.mjs.map → serializer-N6XIwsgp.mjs.map} +1 -1
- package/dist/streaming.mjs +129 -77
- package/dist/streaming.mjs.map +1 -1
- package/dist/styles/display-text.d.ts +95 -0
- package/dist/styles/format-code.d.ts +125 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/numbers.d.ts +7 -0
- package/dist/styles.mjs +1161 -4
- package/dist/styles.mjs.map +1 -0
- package/dist/{stylesheet-writer-oXSuGnJy.mjs → stylesheet-writer-BEn-0P0x.mjs} +480 -173
- package/dist/stylesheet-writer-BEn-0P0x.mjs.map +1 -0
- package/dist/{table-BrP0RwUd.mjs → table-BxOLUZs3.mjs} +2 -2
- package/dist/{table-BrP0RwUd.mjs.map → table-BxOLUZs3.mjs.map} +1 -1
- package/dist/{tree-BX-sRRVp.mjs → tree-CspNjuYl.mjs} +12 -2
- package/dist/tree-CspNjuYl.mjs.map +1 -0
- package/dist/utils/cell-number.d.ts +10 -0
- package/dist/utils/coordinate.d.ts +11 -0
- package/dist/utils/escape.d.ts +17 -0
- package/dist/utils/xsd-boolean.d.ts +9 -0
- package/dist/utils.mjs +2 -2
- package/dist/workbook/index.d.ts +1 -1
- package/dist/workbook/workbook.d.ts +9 -46
- package/dist/{workbook-DOTFzCpz.mjs → workbook-tG9oYtzU.mjs} +50 -13
- package/dist/workbook-tG9oYtzU.mjs.map +1 -0
- package/dist/workbook.mjs +3 -3
- package/dist/worksheet/index.d.ts +1 -1
- package/dist/worksheet/worksheet.d.ts +55 -14
- package/dist/{worksheet-B2NOQ6dM.mjs → worksheet-DLMyDD7W.mjs} +87 -22
- package/dist/worksheet-DLMyDD7W.mjs.map +1 -0
- package/dist/worksheet.mjs +3 -3
- package/dist/xml/namespaces.d.ts +7 -0
- package/dist/xml/parser.d.ts +12 -0
- package/dist/xml/strict-package.d.ts +14 -0
- package/dist/xml.mjs +5 -5
- package/dist/zip.mjs +1 -1
- package/package.json +1 -1
- package/dist/cell-Df3cKRIl.mjs.map +0 -1
- package/dist/cell-style-CNsET6WU.mjs.map +0 -1
- package/dist/coordinate-Bt5Gni2I.mjs.map +0 -1
- package/dist/escape-rnWSPpWY.mjs.map +0 -1
- package/dist/load-B1sK-LjT.mjs.map +0 -1
- package/dist/manifest-pLmx7KYh.mjs.map +0 -1
- package/dist/parser-By6RWZVW.mjs.map +0 -1
- package/dist/reader-DHMxLBQV.mjs.map +0 -1
- package/dist/serialize-BC2Wu3bR.mjs.map +0 -1
- package/dist/stylesheet-writer-oXSuGnJy.mjs.map +0 -1
- package/dist/tree-BX-sRRVp.mjs.map +0 -1
- package/dist/workbook-DOTFzCpz.mjs.map +0 -1
- package/dist/worksheet-B2NOQ6dM.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cell-Df3cKRIl.mjs","names":[],"sources":["../src/cell/rich-text.ts","../src/cell/cell.ts"],"sourcesContent":["// Inline rich-text runs.\n//\n// A rich-text cell value is `{ kind: 'rich-text', runs }`. Each run is\n// a string segment with an optional InlineFont describing the in-line\n// formatting (font name, size, bold / italic / underline, colour, …).\n// Run-level fields use OOXML's short attribute names (`sz`, `b`, `i`,\n// `u`) so the writer can splice them into `<rPr>` directly without\n// renaming.\n\nimport type { Color } from '../styles/colors.js';\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\n\n/** Underline styles per openpyxl's cell-level NestedNoneSet. */\nexport type InlineUnderline = 'single' | 'double' | 'singleAccounting' | 'doubleAccounting';\n\nexport type InlineVertAlign = 'baseline' | 'superscript' | 'subscript';\n\nexport interface InlineFont {\n readonly name?: string;\n readonly sz?: number;\n readonly b?: boolean;\n readonly i?: boolean;\n readonly u?: InlineUnderline;\n readonly strike?: boolean;\n readonly outline?: boolean;\n readonly shadow?: boolean;\n readonly condense?: boolean;\n readonly extend?: boolean;\n readonly vertAlign?: InlineVertAlign;\n readonly color?: Color;\n readonly family?: number;\n readonly charset?: number;\n readonly scheme?: 'major' | 'minor';\n}\n\nexport interface TextRun {\n readonly text: string;\n readonly font?: InlineFont;\n}\n\n/** A frozen array of TextRuns. The shared cell value shape under `kind: 'rich-text'`. */\nexport type RichText = ReadonlyArray<TextRun>;\n\nexport function makeTextRun(text: string, font?: InlineFont): TextRun {\n if (typeof text !== 'string') {\n throw new OpenXmlSchemaError('makeTextRun: text must be a string');\n }\n return Object.freeze(font !== undefined ? { text, font } : { text });\n}\n\nexport function makeRichText(runs: ReadonlyArray<TextRun | { text: string; font?: InlineFont }>): RichText {\n const out = runs.map((r) => (Object.isFrozen(r) ? (r as TextRun) : makeTextRun(r.text, r.font)));\n return Object.freeze(out);\n}\n\n/**\n * Concatenate the plain-text content of a rich-text value (rich-text\n * read paths often want the raw text without formatting).\n */\nexport function richTextToString(rt: RichText): string {\n let out = '';\n for (const r of rt) out += r.text;\n return out;\n}\n","// Cell value model. Mirrors openpyxl/openpyxl/cell/cell.py.\n//\n// A Cell is a plain mutable object: the worksheet stores millions of these, so\n// per-cell freezes / spreads aren't viable on the hot path. The public surface\n// stays small — makeCell + getCoordinate + targeted setters — and uses\n// discriminated unions for the special CellValue shapes (formula, rich text,\n// duration, error).\n\nimport { columnLetterFromIndex, MAX_COL, MAX_ROW } from '../utils/coordinate.js';\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\nimport { normalizeFormulaText, startsWithEquals } from '../utils/formula-text.js';\nimport { ERROR_CODES } from '../utils/inference.js';\nimport { type RichText, richTextToString } from './rich-text.js';\n\n/** Excel error tokens. */\nexport type ExcelErrorCode = '#NULL!' | '#DIV/0!' | '#VALUE!' | '#REF!' | '#NAME?' | '#NUM!' | '#N/A' | '#GETTING_DATA';\n\n/** Formula sub-kind — drives the OOXML `<f t=\"…\">` attribute. */\nexport type FormulaKind = 'normal' | 'array' | 'shared' | 'dataTable';\n\nexport interface FormulaValue {\n readonly kind: 'formula';\n readonly formula: string;\n readonly t: FormulaKind;\n /** Cached value Excel last computed for the cell, used when `data_only` reads it back. */\n readonly cachedValue?: number | string | boolean;\n /** Range string (`\"A1:A10\"`) for array / shared / dataTable formulas. */\n readonly ref?: string;\n /** Shared-formula index. */\n readonly si?: number;\n /** Data-table specific fields (mirrors openpyxl DataTableFormula). */\n readonly r1?: string;\n readonly r2?: string;\n readonly dt2D?: boolean;\n readonly dtr?: boolean;\n readonly del1?: boolean;\n readonly del2?: boolean;\n readonly aca?: boolean;\n readonly ca?: boolean;\n}\n\nexport type CellValue =\n | number\n | string\n | boolean\n | Date\n | { kind: 'duration'; ms: number }\n | { kind: 'error'; code: ExcelErrorCode }\n | { kind: 'rich-text'; runs: RichText }\n | FormulaValue\n | null;\n\nexport interface Cell {\n /** 1-based row index. */\n row: number;\n /** 1-based column index. */\n col: number;\n /** Effective cell value. `null` represents an empty cell. */\n value: CellValue;\n /** Index into Workbook.styles.cellXfs. 0 = default. */\n styleId: number;\n /** Optional reference to a Hyperlink registered on the worksheet. */\n hyperlinkId?: number;\n /** Optional reference to a Comment registered on the worksheet. */\n commentId?: number;\n}\n\n/** Marker subtype for the placeholder cells inside a merged range (top-left holds the value). */\nexport interface MergedCell extends Cell {\n merged: true;\n}\n\nconst validateCoord = (row: number, col: number): void => {\n if (!Number.isInteger(row) || row < 1 || row > MAX_ROW) {\n throw new OpenXmlSchemaError(`Cell row ${row} out of range [1, ${MAX_ROW}]`);\n }\n if (!Number.isInteger(col) || col < 1 || col > MAX_COL) {\n throw new OpenXmlSchemaError(`Cell col ${col} out of range [1, ${MAX_COL}]`);\n }\n};\n\n/** Build a fresh Cell. Validates coordinates against the OOXML grid bounds. */\nexport function makeCell(row: number, col: number, value: CellValue = null, styleId = 0): Cell {\n validateCoord(row, col);\n return { row, col, value, styleId };\n}\n\n/** Format a Cell's coordinate as the canonical \"A1\" string. */\nexport function getCoordinate(c: Cell): string {\n return `${columnLetterFromIndex(c.col)}${c.row}`;\n}\n\n/**\n * Direct value setter. No type inference, no validation beyond the union — the\n * caller is in charge. Use {@link bindValue} for the \"do what I mean\" path.\n */\nexport function setCellValue(c: Cell, value: CellValue): void {\n c.value = value;\n}\n\n/**\n * \"Smart\" setter: infers the cell value from a JS runtime value.\n * - `string` starting with `=` → formula\n * - `string` matching an Excel error token → error variant\n * - other primitives / Date / null pass through verbatim\n *\n * Intentionally not the default — explicit is clearer for typed code, and\n * inferring on every write costs measurable time on the worksheet write hot\n * path.\n */\nexport function bindValue(c: Cell, value: number | string | boolean | Date | null): void {\n if (typeof value === 'string') {\n if (startsWithEquals(value)) {\n setFormula(c, value);\n return;\n }\n if (ERROR_CODES.has(value)) {\n c.value = { kind: 'error', code: value as ExcelErrorCode };\n return;\n }\n c.value = value;\n return;\n }\n c.value = value;\n}\n\n// ---- formula values --------------------------------------------------------\n\n// A `<f>` with no text is the shape Excel reports as damaged, and `'='` on its\n// own normalises to exactly that, so the kinds whose text is required reject it\n// here rather than at save time.\nconst requireFormulaText = (fn: string, formula: string): string => {\n const text = normalizeFormulaText(formula);\n if (text.length === 0) {\n throw new OpenXmlSchemaError(`${fn}: formula text must not be empty (got ${JSON.stringify(formula)})`);\n }\n return text;\n};\n\n/**\n * Build a formula cell value. Hand it to `setCell` when the write already\n * carries a style id, so placing a formatted formula stays a single call;\n * {@link setFormula} is the same thing applied to a cell you already hold.\n *\n * A leading `=` is stripped, so `'=SUM(A1:A3)'` and `'SUM(A1:A3)'` are\n * interchangeable.\n *\n * A cached value is optional. Without one, Excel, LibreOffice and Google\n * Sheets compute the result on open, but viewers that never calculate (Quick\n * Look, Outlook and SharePoint previews, most thumbnailers) render the cell\n * empty. Supply one whenever the producer can compute it.\n */\nexport function makeFormula(\n formula: string,\n opts?: { cachedValue?: FormulaValue['cachedValue'] },\n): FormulaValue {\n return Object.freeze({\n kind: 'formula',\n t: 'normal',\n formula: requireFormulaText('makeFormula', formula),\n ...(opts?.cachedValue !== undefined ? { cachedValue: opts.cachedValue } : {}),\n });\n}\n\n/**\n * Build an array (CSE) formula value spanning `ref`. Belongs on the top-left\n * cell of the range, since Excel reads `ref` to know how far the result\n * spreads.\n */\nexport function makeArrayFormula(\n ref: string,\n formula: string,\n opts?: { cachedValue?: FormulaValue['cachedValue'] },\n): FormulaValue {\n return Object.freeze({\n kind: 'formula',\n t: 'array',\n formula: requireFormulaText('makeArrayFormula', formula),\n ref,\n ...(opts?.cachedValue !== undefined ? { cachedValue: opts.cachedValue } : {}),\n });\n}\n\n/**\n * Build a shared-formula value. The first cell in the group carries the\n * formula text + `ref`; subsequent cells with the same `si` carry only the\n * index, and Excel reconstructs their text by shifting the references, so\n * their `formula` is legitimately empty.\n */\nexport function makeSharedFormula(\n si: number,\n formula?: string,\n ref?: string,\n opts?: { cachedValue?: FormulaValue['cachedValue'] },\n): FormulaValue {\n if (!Number.isInteger(si) || si < 0) {\n throw new OpenXmlSchemaError(`makeSharedFormula: si must be a non-negative integer; got ${si}`);\n }\n return Object.freeze({\n kind: 'formula',\n t: 'shared',\n formula: formula === undefined ? '' : normalizeFormulaText(formula),\n si,\n ...(ref !== undefined ? { ref } : {}),\n ...(opts?.cachedValue !== undefined ? { cachedValue: opts.cachedValue } : {}),\n });\n}\n\n/**\n * Plain `A1+B1` style formula, applied in place. Same value as\n * {@link makeFormula}, for a cell you already hold.\n */\nexport function setFormula(c: Cell, formula: string, opts?: { cachedValue?: FormulaValue['cachedValue'] }): void {\n c.value = makeFormula(formula, opts);\n}\n\n/** Array (CSE) formula spanning a `ref` range, applied in place. */\nexport function setArrayFormula(\n c: Cell,\n ref: string,\n formula: string,\n opts?: { cachedValue?: FormulaValue['cachedValue'] },\n): void {\n c.value = makeArrayFormula(ref, formula, opts);\n}\n\n/** Shared formula, applied in place. See {@link makeSharedFormula}. */\nexport function setSharedFormula(\n c: Cell,\n si: number,\n formula?: string,\n ref?: string,\n opts?: { cachedValue?: FormulaValue['cachedValue'] },\n): void {\n c.value = makeSharedFormula(si, formula, ref, opts);\n}\n\n/**\n * Excel data-table formula (`<f t=\"dataTable\">`). These appear as the \"What-if\n * Analysis → Data Table\" feature output: a 1- or 2-variable sensitivity grid\n * where the formula references one or two input cells. The wire format mirrors\n * openpyxl's `DataTableFormula`:\n *\n * - `ref` — inclusive cell range the formula spans.\n * - `r1`, `r2`— input cell coordinates (\"$A$1\" etc.).\n * - `dt2D` — true for two-variable tables (uses both r1 and r2).\n * - `dtr` — row-direction flag (true) vs column-direction (false).\n * - `del1`/`del2` — Excel marks one of these true when the\n * corresponding input cell has been deleted; the formula keeps round-tripping\n * so Excel can show the warning state.\n * - `aca`/`ca` — alwaysCalculate / calculate flags.\n */\nexport interface DataTableFormulaOpts {\n ref: string;\n r1?: string;\n r2?: string;\n dt2D?: boolean;\n dtr?: boolean;\n del1?: boolean;\n del2?: boolean;\n aca?: boolean;\n ca?: boolean;\n cachedValue?: FormulaValue['cachedValue'];\n}\n\n/**\n * Build a data-table formula value. Preserves all the dt-specific attributes\n * so the writer can re-emit `<f t=\"dataTable\" r1=\"...\" />` verbatim and Excel\n * keeps treating the cell as a Data Table cell. Excel writes these with no\n * formula text at all, so `formula` may be empty.\n */\nexport function makeDataTableFormula(formula: string, opts: DataTableFormulaOpts): FormulaValue {\n return Object.freeze({\n kind: 'formula',\n t: 'dataTable',\n formula: normalizeFormulaText(formula),\n ref: opts.ref,\n ...(opts.r1 !== undefined ? { r1: opts.r1 } : {}),\n ...(opts.r2 !== undefined ? { r2: opts.r2 } : {}),\n ...(opts.dt2D !== undefined ? { dt2D: opts.dt2D } : {}),\n ...(opts.dtr !== undefined ? { dtr: opts.dtr } : {}),\n ...(opts.del1 !== undefined ? { del1: opts.del1 } : {}),\n ...(opts.del2 !== undefined ? { del2: opts.del2 } : {}),\n ...(opts.aca !== undefined ? { aca: opts.aca } : {}),\n ...(opts.ca !== undefined ? { ca: opts.ca } : {}),\n ...(opts.cachedValue !== undefined ? { cachedValue: opts.cachedValue } : {}),\n });\n}\n\n/** Data-table formula, applied in place. See {@link makeDataTableFormula}. */\nexport function setDataTableFormula(c: Cell, formula: string, opts: DataTableFormulaOpts): void {\n c.value = makeDataTableFormula(formula, opts);\n}\n\n// ---- value-shape helpers ---------------------------------------------------\n\n/** Build a `{ kind: 'error', code }` cell value. */\nexport function makeErrorValue(code: ExcelErrorCode): { kind: 'error'; code: ExcelErrorCode } {\n if (!ERROR_CODES.has(code)) {\n throw new OpenXmlSchemaError(`makeErrorValue: unknown error code \"${code}\"`);\n }\n return Object.freeze({ kind: 'error', code });\n}\n\n/** Build a `{ kind: 'duration', ms }` cell value. */\nexport function makeDurationValue(ms: number): { kind: 'duration'; ms: number } {\n if (!Number.isFinite(ms)) {\n throw new OpenXmlSchemaError(`makeDurationValue: ms \"${ms}\" is not finite`);\n }\n return Object.freeze({ kind: 'duration', ms });\n}\n\n/** True iff `c.value` is the formula variant. */\nexport function isFormulaCell(c: Cell): boolean {\n return isFormulaValue(c.value);\n}\n\n/** True iff `c.value` is the rich-text variant. */\nexport function isRichTextCell(c: Cell): boolean {\n return isRichTextValue(c.value);\n}\n\n/** Returns true iff the cell has no content. */\nexport function isEmptyCell(c: Cell): boolean {\n return c.value === null;\n}\n\n/**\n * Type guard for `MergedCell` — true iff the cell is a placeholder for a\n * merged-range covered cell (the top-left of a merged range holds the value;\n * the rest are `MergedCell`). Use this to filter merge-placeholders out of\n * value-walking loops.\n */\nexport function isMergedCell(c: Cell): c is MergedCell {\n return (c as MergedCell).merged === true;\n}\n\n/** Returns true iff the cell holds an Excel error value (`#REF!`, `#NAME?`, …). */\nexport function isErrorCell(c: Cell): boolean {\n return isErrorValue(c.value);\n}\n\n/**\n * Get the formula text from a formula-bearing cell, or `undefined` for\n * non-formula cells. Equivalent to: isFormulaValue(c.value) ? c.value.formula :\n * undefined but spares callers the type-narrow + member access.\n */\nexport function getFormulaText(c: Cell): string | undefined {\n return isFormulaValue(c.value) ? c.value.formula : undefined;\n}\n\n/**\n * Get the cached value Excel last computed for a formula cell, or `undefined`\n * for non-formula / uncached cells. Useful for `data_only` read paths that want\n * the displayed result without re-evaluating.\n */\nexport function getCachedFormulaValue(c: Cell): number | string | boolean | undefined {\n return isFormulaValue(c.value) ? c.value.cachedValue : undefined;\n}\n\n// ---- value-level type guards + coercion ----------------------------------\n\n/** True iff `v` is the formula variant. */\nexport function isFormulaValue(v: CellValue): v is FormulaValue {\n return typeof v === 'object' && v !== null && (v as { kind?: string }).kind === 'formula';\n}\n\n/** True iff `v` is the rich-text variant. */\nexport function isRichTextValue(v: CellValue): v is { kind: 'rich-text'; runs: RichText } {\n return typeof v === 'object' && v !== null && (v as { kind?: string }).kind === 'rich-text';\n}\n\n/** True iff `v` is the error variant. */\nexport function isErrorValue(v: CellValue): v is { kind: 'error'; code: ExcelErrorCode } {\n return typeof v === 'object' && v !== null && (v as { kind?: string }).kind === 'error';\n}\n\n/** True iff `v` is the duration variant. */\nexport function isDurationValue(v: CellValue): v is { kind: 'duration'; ms: number } {\n return typeof v === 'object' && v !== null && (v as { kind?: string }).kind === 'duration';\n}\n\nexport interface CellValueAsStringOptions {\n /** Renderer for `Date` cells. Defaults to `d => d.toISOString()`. */\n dateFormat?: (value: Date) => string;\n /** Replacement for the `null` cell value. Defaults to `''`. */\n emptyText?: string;\n}\n\n/**\n * Coerce a CellValue to its plain-string display form. Numbers / booleans\n * convert via `String`; rich text concatenates run text; formulas yield the\n * cached value (or empty string when uncached); errors yield their Excel token;\n * durations yield `\"<ms> ms\"` with no formatting; Dates yield\n * `Date.toISOString()`; `null` yields `\"\"`.\n *\n * Pass `opts.dateFormat` to override the Date renderer (e.g. a locale-specific\n * format) and `opts.emptyText` to substitute a different placeholder for\n * `null` cells.\n */\nexport function cellValueAsString(v: CellValue, opts?: CellValueAsStringOptions): string {\n const emptyText = opts?.emptyText ?? '';\n if (v === null) return emptyText;\n if (typeof v === 'string') return v;\n if (typeof v === 'number' || typeof v === 'boolean') return String(v);\n if (v instanceof Date) return opts?.dateFormat ? opts.dateFormat(v) : v.toISOString();\n if (isRichTextValue(v)) return richTextToString(v.runs);\n if (isFormulaValue(v)) {\n if (v.cachedValue === undefined) return '';\n return typeof v.cachedValue === 'string' ? v.cachedValue : String(v.cachedValue);\n }\n if (isErrorValue(v)) return v.code;\n if (isDurationValue(v)) return `${v.ms} ms`;\n return '';\n}\n\n/**\n * Coerce a CellValue to `boolean | undefined`. Booleans pass through; `'TRUE'`\n * / `'true'` and `'FALSE'` / `'false'` (case-insensitive) parse to true /\n * false; numbers yield `false` for 0 and `true` for any other finite value\n * (matching Excel's truthy-number coercion); formula cells return their cached\n * boolean if any. Everything else (null, Date, error, duration, rich-text,\n * non-bool strings) yields `undefined`.\n */\nexport function cellValueAsBoolean(v: CellValue): boolean | undefined {\n if (typeof v === 'boolean') return v;\n if (typeof v === 'number') {\n if (!Number.isFinite(v)) return undefined;\n return v !== 0;\n }\n if (typeof v === 'string') {\n const lc = v.toLowerCase();\n if (lc === 'true') return true;\n if (lc === 'false') return false;\n return undefined;\n }\n if (isFormulaValue(v) && typeof v.cachedValue === 'boolean') return v.cachedValue;\n return undefined;\n}\n\n/**\n * Coerce a CellValue to a `Date` when one is meaningful. Pass-through for\n * `Date`-typed values; ISO-8601 strings (anything `new Date(s)` parses to a\n * finite time) round-trip; durations are interpreted as `new Date(ms)`.\n * Numbers, booleans, formulas, errors, rich text, and null all return\n * `undefined` — this helper does **not** apply the Excel-serial-to-Date\n * conversion (use `excelToDate` for that).\n */\nexport function cellValueAsDate(v: CellValue): Date | undefined {\n if (v instanceof Date) return v;\n if (typeof v === 'string') {\n if (v === '') return undefined;\n const t = Date.parse(v);\n if (!Number.isFinite(t)) return undefined;\n return new Date(t);\n }\n if (isDurationValue(v)) return new Date(v.ms);\n return undefined;\n}\n\n/**\n * Coerce a CellValue to a number when one is meaningful. Booleans yield 0/1;\n * numeric strings parse via `Number(s)`; rich-text concats then parses;\n * formulas with a numeric cached value pass through. Returns `undefined` when\n * there's no sensible numeric reading (text strings, errors, dates, durations,\n * null, empty).\n */\nexport function cellValueAsNumber(v: CellValue): number | undefined {\n if (v === null) return undefined;\n if (typeof v === 'number') return Number.isFinite(v) ? v : undefined;\n if (typeof v === 'boolean') return v ? 1 : 0;\n if (typeof v === 'string') {\n if (v === '') return undefined;\n const n = Number(v);\n return Number.isFinite(n) ? n : undefined;\n }\n if (isFormulaValue(v) && typeof v.cachedValue === 'number') return v.cachedValue;\n return undefined;\n}\n\n/**\n * Map a CellValue to the most natural JS primitive for display / export.\n * Unlike `cellValueAsString`/`cellValueAsNumber`/etc., which each force a\n * single target type and return `undefined` when the value can't be coerced,\n * this returns whatever primitive best represents the union variant:\n *\n * - `null` → `null`\n * - `string` / `number` / `boolean` / `Date` → passthrough\n * - rich text → joined run text (`string`)\n * - formula → recursive on `cachedValue` (`null` when uncached)\n * - error → error code (`string`)\n * - duration → `ms` (`number`)\n */\nexport function cellValueAsPrimitive(v: CellValue): string | number | boolean | Date | null {\n if (v === null) return null;\n if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean') return v;\n if (v instanceof Date) return v;\n if (isRichTextValue(v)) return richTextToString(v.runs);\n if (isFormulaValue(v)) {\n return v.cachedValue === undefined ? null : v.cachedValue;\n }\n if (isErrorValue(v)) return v.code;\n if (isDurationValue(v)) return v.ms;\n return null;\n}\n"],"mappings":";;;;AA2C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I,OAAO,MAAM,UAAU,OAAO,OAAO,SAAS,CAAC,IAAI,IAAI,KAAA;CAC3D,IAAI,OAAO,MAAM,WAAW,OAAO,IAAI,IAAI;CAC3C,IAAI,OAAO,MAAM,UAAU;EACzB,IAAI,MAAM,IAAI,OAAO,KAAA;EACrB,MAAM,IAAI,OAAO,CAAC;EAClB,OAAO,OAAO,SAAS,CAAC,IAAI,IAAI,KAAA;CAClC;CACA,IAAI,eAAe,CAAC,KAAK,OAAO,EAAE,gBAAgB,UAAU,OAAO,EAAE;AAEvE;;;;;;;;;;;;;;AAeA,SAAgB,qBAAqB,GAAuD;CAC1F,IAAI,MAAM,MAAM,OAAO;CACvB,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,OAAO,MAAM,WAAW,OAAO;CACrF,IAAI,aAAa,MAAM,OAAO;CAC9B,IAAI,gBAAgB,CAAC,GAAG,OAAO,iBAAiB,EAAE,IAAI;CACtD,IAAI,eAAe,CAAC,GAClB,OAAO,EAAE,gBAAgB,KAAA,IAAY,OAAO,EAAE;CAEhD,IAAI,aAAa,CAAC,GAAG,OAAO,EAAE;CAC9B,IAAI,gBAAgB,CAAC,GAAG,OAAO,EAAE;CACjC,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cell-style-CNsET6WU.mjs","names":[],"sources":["../src/utils/stable-stringify.ts","../src/styles/alignment.ts","../src/styles/borders.ts","../src/styles/fills.ts","../src/styles/fonts.ts","../src/styles/numbers.ts","../src/styles/stylesheet.ts","../src/styles/named-styles.ts","../src/styles/protection.ts","../src/styles/cell-style.ts"],"sourcesContent":["// Deterministic JSON serialiser. Used by the Stylesheet pool to dedupe\n// value-object entries (Font / Fill / Border / CellXf …) by structural\n// equality regardless of property insertion order.\n//\n// Implemented as a JSON.stringify replacer that returns a key-sorted\n// shallow copy of every plain object it encounters; arrays keep their\n// element order. Circular references propagate as JSON.stringify's\n// native RangeError (\"Maximum call stack size exceeded\").\n\nconst sortKeysReplacer = (_key: string, value: unknown): unknown => {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return value;\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj).sort();\n const out: Record<string, unknown> = {};\n for (const k of keys) out[k] = obj[k];\n return out;\n};\n\n/**\n * Stringify `value` with object keys sorted recursively. Equal logical\n * values produce the same string regardless of insertion order; arrays\n * preserve their element order. Circular references throw (the error\n * comes straight from JSON.stringify's stack-overflow check).\n */\nexport function stableStringify(value: unknown): string {\n return JSON.stringify(value, sortKeysReplacer);\n}\n","// Cell alignment value object. Mirrors openpyxl/openpyxl/styles/alignment.py.\n\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\n\nexport type HorizontalAlignment =\n | 'general'\n | 'left'\n | 'center'\n | 'right'\n | 'fill'\n | 'justify'\n | 'centerContinuous'\n | 'distributed';\n\nexport type VerticalAlignment = 'top' | 'center' | 'bottom' | 'justify' | 'distributed';\n\nexport const HORIZONTAL_ALIGNMENTS: ReadonlyArray<HorizontalAlignment> = Object.freeze([\n 'general',\n 'left',\n 'center',\n 'right',\n 'fill',\n 'justify',\n 'centerContinuous',\n 'distributed',\n]);\nexport const VERTICAL_ALIGNMENTS: ReadonlyArray<VerticalAlignment> = Object.freeze([\n 'top',\n 'center',\n 'bottom',\n 'justify',\n 'distributed',\n]);\n\nconst HORIZONTAL_SET: ReadonlySet<string> = new Set(HORIZONTAL_ALIGNMENTS);\nconst VERTICAL_SET: ReadonlySet<string> = new Set(VERTICAL_ALIGNMENTS);\n\nexport interface Alignment {\n readonly horizontal?: HorizontalAlignment;\n readonly vertical?: VerticalAlignment;\n /** 0..180 (degrees) OR 255 (vertical stacked text). */\n readonly textRotation?: number;\n readonly wrapText?: boolean;\n readonly shrinkToFit?: boolean;\n /** 0..255 indent levels. */\n readonly indent?: number;\n /** -255..255 relative indent. */\n readonly relativeIndent?: number;\n readonly justifyLastLine?: boolean;\n /** 0 = context-dependent, 1 = LTR, 2 = RTL. */\n readonly readingOrder?: number;\n}\n\nexport function makeAlignment(opts: Partial<Alignment> = {}): Alignment {\n const out: { -readonly [K in keyof Alignment]: Alignment[K] } = {};\n if (opts.horizontal !== undefined) {\n if (!HORIZONTAL_SET.has(opts.horizontal)) {\n throw new OpenXmlSchemaError(\n `Alignment horizontal must be one of [${HORIZONTAL_ALIGNMENTS.join(', ')}]; got \"${opts.horizontal}\"`,\n );\n }\n out.horizontal = opts.horizontal;\n }\n if (opts.vertical !== undefined) {\n if (!VERTICAL_SET.has(opts.vertical)) {\n throw new OpenXmlSchemaError(\n `Alignment vertical must be one of [${VERTICAL_ALIGNMENTS.join(', ')}]; got \"${opts.vertical}\"`,\n );\n }\n out.vertical = opts.vertical;\n }\n if (opts.textRotation !== undefined) {\n const r = opts.textRotation;\n if (!Number.isInteger(r) || r < 0 || (r > 180 && r !== 255)) {\n throw new OpenXmlSchemaError(`Alignment textRotation must be 0..180 or 255; got ${r}`);\n }\n out.textRotation = r;\n }\n if (opts.wrapText !== undefined) out.wrapText = opts.wrapText;\n if (opts.shrinkToFit !== undefined) out.shrinkToFit = opts.shrinkToFit;\n if (opts.indent !== undefined) {\n if (!Number.isFinite(opts.indent) || opts.indent < 0 || opts.indent > 255) {\n throw new OpenXmlSchemaError(`Alignment indent must be 0..255; got ${opts.indent}`);\n }\n out.indent = opts.indent;\n }\n if (opts.relativeIndent !== undefined) {\n const r = opts.relativeIndent;\n if (!Number.isFinite(r) || r < -255 || r > 255) {\n throw new OpenXmlSchemaError(`Alignment relativeIndent must be -255..255; got ${r}`);\n }\n out.relativeIndent = r;\n }\n if (opts.justifyLastLine !== undefined) out.justifyLastLine = opts.justifyLastLine;\n if (opts.readingOrder !== undefined) {\n if (!Number.isFinite(opts.readingOrder) || opts.readingOrder < 0) {\n throw new OpenXmlSchemaError(`Alignment readingOrder must be >= 0; got ${opts.readingOrder}`);\n }\n out.readingOrder = opts.readingOrder;\n }\n return Object.freeze(out);\n}\n\nexport const DEFAULT_ALIGNMENT: Alignment = makeAlignment();\n\nconst HORIZONTAL_TO_TEXT_ALIGN: Record<HorizontalAlignment, string | undefined> = {\n general: undefined, // Excel: numbers right, text left — caller decides per cell type.\n left: 'left',\n center: 'center',\n right: 'right',\n fill: 'left', // CSS has no fill; left is the closest non-stretched approximation.\n justify: 'justify',\n centerContinuous: 'center',\n distributed: 'justify',\n};\n\nconst VERTICAL_TO_VERTICAL_ALIGN: Record<VerticalAlignment, string | undefined> = {\n top: 'top',\n center: 'middle',\n bottom: 'bottom',\n justify: 'middle',\n distributed: 'middle',\n};\n\n/**\n * Translate an {@link Alignment} to a CSS-property record suitable for\n * HTML preview. `horizontal` → `text-align`, `vertical` →\n * `vertical-align` (table-cell semantics), `wrapText` → `white-space:\n * pre-wrap`, `textRotation` → `transform: rotate(<-deg>)` (Excel rotates\n * counter-clockwise relative to CSS) plus `transform-origin` to keep\n * the text anchored, and `indent` → `padding-left: <n>em`. `255`\n * stacked-text rotation maps to a 180° flip with `writing-mode`.\n *\n * Empty / undefined Alignment returns `{}`.\n */\nexport function alignmentToCss(alignment: Alignment | undefined): Record<string, string> {\n const css: Record<string, string> = {};\n if (!alignment) return css;\n if (alignment.horizontal !== undefined) {\n const ta = HORIZONTAL_TO_TEXT_ALIGN[alignment.horizontal];\n if (ta !== undefined) css['text-align'] = ta;\n }\n if (alignment.vertical !== undefined) {\n const va = VERTICAL_TO_VERTICAL_ALIGN[alignment.vertical];\n if (va !== undefined) css['vertical-align'] = va;\n }\n if (alignment.wrapText) css['white-space'] = 'pre-wrap';\n if (alignment.textRotation !== undefined) {\n if (alignment.textRotation === 255) {\n css['writing-mode'] = 'vertical-rl';\n } else if (alignment.textRotation !== 0) {\n // Excel: positive degrees rotate counter-clockwise; CSS rotate() is clockwise → negate.\n css['transform'] = `rotate(-${alignment.textRotation}deg)`;\n css['transform-origin'] = 'center center';\n }\n }\n if (alignment.indent !== undefined && alignment.indent > 0) {\n css['padding-left'] = `${alignment.indent}em`;\n }\n return css;\n}\n","// Border / Side value objects. Mirrors openpyxl/openpyxl/styles/borders.py.\n//\n// A `Border` describes the edges drawn around a cell. Each edge is a `Side`\n// carrying a stroke style and an optional `Color`. These are plain readonly\n// objects; the `make*` constructors freeze their results so the Stylesheet pool\n// can dedupe by reference identity once we wire it up.\n\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\nimport { type Color, colorToHex, makeColor } from './colors.js';\n\nexport type SideStyle =\n // ECMA-376 §18.18.3 ST_BorderStyle lists `none` (no stroke) as a first-class\n // value; Excel omits the side element for it, but OnlyOffice writes it out\n // explicitly, so we must accept and round-trip it (issue #99).\n | 'none'\n | 'thin'\n | 'medium'\n | 'thick'\n | 'double'\n | 'hair'\n | 'dotted'\n | 'dashed'\n | 'dashDot'\n | 'dashDotDot'\n | 'mediumDashed'\n | 'mediumDashDot'\n | 'mediumDashDotDot'\n | 'slantDashDot';\n\nexport const SIDE_STYLES: ReadonlyArray<SideStyle> = Object.freeze([\n 'none',\n 'thin',\n 'medium',\n 'thick',\n 'double',\n 'hair',\n 'dotted',\n 'dashed',\n 'dashDot',\n 'dashDotDot',\n 'mediumDashed',\n 'mediumDashDot',\n 'mediumDashDotDot',\n 'slantDashDot',\n]);\n\nconst SIDE_STYLE_SET: ReadonlySet<string> = new Set(SIDE_STYLES);\n\nexport interface Side {\n readonly style?: SideStyle;\n readonly color?: Color;\n}\n\n/** Build an immutable {@link Side}. */\nexport function makeSide(opts: Partial<Side> = {}): Side {\n const out: { -readonly [K in keyof Side]: Side[K] } = {};\n if (opts.style !== undefined) {\n if (!SIDE_STYLE_SET.has(opts.style)) {\n throw new OpenXmlSchemaError(`Side style must be one of [${SIDE_STYLES.join(', ')}]; got \"${opts.style}\"`);\n }\n out.style = opts.style;\n }\n if (opts.color !== undefined) {\n // Funnel through makeColor so we re-use its validation + freezing.\n out.color = Object.isFrozen(opts.color) ? opts.color : makeColor(opts.color);\n }\n return Object.freeze(out);\n}\n\nexport interface Border {\n /** Left edge. */\n readonly left?: Side;\n readonly right?: Side;\n readonly top?: Side;\n readonly bottom?: Side;\n /** Diagonal stroke (governed together with diagonalUp / diagonalDown). */\n readonly diagonal?: Side;\n /** Vertical stroke between cells of a merged range. */\n readonly vertical?: Side;\n /** Horizontal stroke between cells of a merged range. */\n readonly horizontal?: Side;\n readonly diagonalUp?: boolean;\n readonly diagonalDown?: boolean;\n /** Outline-only flag; defaults to true. */\n readonly outline?: boolean;\n}\n\n/** Build an immutable {@link Border}. */\nexport function makeBorder(opts: Partial<Border> = {}): Border {\n const out: { -readonly [K in keyof Border]: Border[K] } = {};\n if (opts.left !== undefined) out.left = freezeSide(opts.left);\n if (opts.right !== undefined) out.right = freezeSide(opts.right);\n if (opts.top !== undefined) out.top = freezeSide(opts.top);\n if (opts.bottom !== undefined) out.bottom = freezeSide(opts.bottom);\n if (opts.diagonal !== undefined) out.diagonal = freezeSide(opts.diagonal);\n if (opts.vertical !== undefined) out.vertical = freezeSide(opts.vertical);\n if (opts.horizontal !== undefined) out.horizontal = freezeSide(opts.horizontal);\n if (opts.diagonalUp !== undefined) out.diagonalUp = opts.diagonalUp;\n if (opts.diagonalDown !== undefined) out.diagonalDown = opts.diagonalDown;\n if (opts.outline !== undefined) out.outline = opts.outline;\n return Object.freeze(out);\n}\n\nconst freezeSide = (s: Side): Side => (Object.isFrozen(s) ? s : makeSide(s));\n\n/** Default empty side — convenient sentinel for `no edge stroke`. */\nexport const EMPTY_SIDE: Side = makeSide();\n/** Default empty border — every cell starts here until styled otherwise. */\nexport const DEFAULT_BORDER: Border = makeBorder();\n\n/**\n * Map an Excel {@link SideStyle} to a CSS `border` shorthand fragment (`<width>\n * <style>`). Returns `undefined` for unmappable styles or a missing/no-style\n * side. Colour is appended by the caller.\n */\nfunction sideStyleToCss(style: SideStyle | undefined): string | undefined {\n switch (style) {\n case 'thin':\n case 'hair':\n return '1px solid';\n case 'medium':\n return '2px solid';\n case 'thick':\n return '3px solid';\n case 'double':\n return '3px double';\n case 'dotted':\n return '1px dotted';\n case 'dashed':\n case 'dashDot':\n case 'dashDotDot':\n return '1px dashed';\n case 'mediumDashed':\n case 'mediumDashDot':\n case 'mediumDashDotDot':\n case 'slantDashDot':\n return '2px dashed';\n default:\n return undefined;\n }\n}\n\n/**\n * Translate a {@link Border} to a CSS-property record suitable for HTML\n * preview. Each present side becomes `border-<edge>: <width> <style> <#color>`.\n * Theme/auto/missing colours fall back to `currentColor`. Diagonal / vertical /\n * horizontal sides are skipped (CSS has no native equivalent for in-cell\n * strokes). Empty Border returns `{}`.\n */\nexport function borderToCss(border: Border | undefined): Record<string, string> {\n const css: Record<string, string> = {};\n if (!border) return css;\n const sides: Array<['top' | 'right' | 'bottom' | 'left', Side | undefined]> = [\n ['top', border.top],\n ['right', border.right],\n ['bottom', border.bottom],\n ['left', border.left],\n ];\n for (const [edge, side] of sides) {\n if (!side) continue;\n const stroke = sideStyleToCss(side.style);\n if (stroke === undefined) continue;\n const argb = colorToHex(side.color);\n const colour = argb !== undefined ? `#${argb.slice(2)}` : 'currentColor';\n css[`border-${edge}`] = `${stroke} ${colour}`;\n }\n return css;\n}\n","// Pattern + gradient fill value objects. Mirrors\n// openpyxl/openpyxl/styles/fills.py.\n//\n// In OOXML the cell `<fill>` element wraps exactly one of:\n// * <patternFill patternType=\"…\">[<fgColor>, <bgColor>]</patternFill>\n// * <gradientFill type=\"linear|path\" …>[<stop>, …]</gradientFill>\n//\n// The TS port models the inner variants as a discriminated union via a `kind`\n// tag; the wrapper is reconstructed during XML round-trip (see\n// fills.schema.ts). All values are plain readonly + frozen so the Stylesheet\n// pool can dedupe.\n\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\nimport { type Color, colorToHex, makeColor } from './colors.js';\n\n// ---- pattern fills ---------------------------------------------------------\n\n/** Predefined Excel pattern types. `'none'` lives here too as an explicit value. */\nexport type PatternType =\n | 'none'\n | 'solid'\n | 'darkDown'\n | 'darkGray'\n | 'darkGrid'\n | 'darkHorizontal'\n | 'darkTrellis'\n | 'darkUp'\n | 'darkVertical'\n | 'gray0625'\n | 'gray125'\n | 'lightDown'\n | 'lightGray'\n | 'lightGrid'\n | 'lightHorizontal'\n | 'lightTrellis'\n | 'lightUp'\n | 'lightVertical'\n | 'mediumGray';\n\nexport const PATTERN_TYPES: ReadonlyArray<PatternType> = Object.freeze([\n 'none',\n 'solid',\n 'darkDown',\n 'darkGray',\n 'darkGrid',\n 'darkHorizontal',\n 'darkTrellis',\n 'darkUp',\n 'darkVertical',\n 'gray0625',\n 'gray125',\n 'lightDown',\n 'lightGray',\n 'lightGrid',\n 'lightHorizontal',\n 'lightTrellis',\n 'lightUp',\n 'lightVertical',\n 'mediumGray',\n]);\n\nconst PATTERN_TYPE_SET: ReadonlySet<string> = new Set(PATTERN_TYPES);\n\nexport interface PatternFill {\n readonly kind: 'pattern';\n readonly patternType?: PatternType;\n readonly fgColor?: Color;\n readonly bgColor?: Color;\n}\n\nexport function makePatternFill(opts: Partial<Omit<PatternFill, 'kind'>> = {}): PatternFill {\n const out: { -readonly [K in keyof PatternFill]: PatternFill[K] } = { kind: 'pattern' };\n if (opts.patternType !== undefined) {\n if (!PATTERN_TYPE_SET.has(opts.patternType)) {\n throw new OpenXmlSchemaError(\n `PatternFill patternType must be one of [${PATTERN_TYPES.join(', ')}]; got \"${opts.patternType}\"`,\n );\n }\n out.patternType = opts.patternType;\n }\n if (opts.fgColor !== undefined) out.fgColor = freezeColor(opts.fgColor);\n if (opts.bgColor !== undefined) out.bgColor = freezeColor(opts.bgColor);\n return Object.freeze(out);\n}\n\n// ---- gradient fills --------------------------------------------------------\n\nexport interface GradientStop {\n /** 0..1 ratio along the gradient. */\n readonly position: number;\n readonly color: Color;\n}\n\nexport type GradientFillType = 'linear' | 'path';\n\nexport interface GradientFill {\n readonly kind: 'gradient';\n readonly type: GradientFillType;\n /** Rotation angle (degrees). Ignored when `type === 'path'`. */\n readonly degree?: number;\n /** path-mode insets (0..1 from each edge). */\n readonly left?: number;\n readonly right?: number;\n readonly top?: number;\n readonly bottom?: number;\n /** Colour stops along the gradient. */\n readonly stops: ReadonlyArray<GradientStop>;\n}\n\nexport function makeGradientStop(position: number, color: Color | Partial<Color>): GradientStop {\n if (!Number.isFinite(position) || position < 0 || position > 1) {\n throw new OpenXmlSchemaError(`GradientStop position must be in [0, 1]; got ${position}`);\n }\n return Object.freeze({ position, color: freezeColor(color) });\n}\n\nexport function makeGradientFill(opts: Partial<Omit<GradientFill, 'kind'>> = {}): GradientFill {\n const out: { -readonly [K in keyof GradientFill]: GradientFill[K] } = {\n kind: 'gradient',\n type: opts.type ?? 'linear',\n stops: opts.stops?.map((s) => freezeStop(s)) ?? [],\n };\n if (out.type !== 'linear' && out.type !== 'path') {\n throw new OpenXmlSchemaError(`GradientFill type must be \"linear\" or \"path\"; got \"${String(out.type)}\"`);\n }\n if (opts.degree !== undefined) out.degree = opts.degree;\n if (opts.left !== undefined) out.left = opts.left;\n if (opts.right !== undefined) out.right = opts.right;\n if (opts.top !== undefined) out.top = opts.top;\n if (opts.bottom !== undefined) out.bottom = opts.bottom;\n Object.freeze(out.stops);\n return Object.freeze(out);\n}\n\n// ---- Fill = PatternFill | GradientFill -------------------------------------\n\nexport type Fill = PatternFill | GradientFill;\n\n/**\n * Single-arg constructor that defers to the variant-specific maker based on\n * `kind`. Useful when the caller has a plain object in hand and wants the\n * freeze invariant applied uniformly.\n */\nexport function makeFill(opts: Partial<PatternFill> | Partial<GradientFill>): Fill {\n if (opts.kind === 'gradient') return makeGradientFill(opts as Partial<Omit<GradientFill, 'kind'>>);\n return makePatternFill(opts as Partial<Omit<PatternFill, 'kind'>>);\n}\n\n/** The empty PatternFill — Excel's default cellXf[0] points here. */\nexport const DEFAULT_EMPTY_FILL: Fill = makePatternFill();\n/** The 'gray125' PatternFill — Excel's default cellXf[1]. */\nexport const DEFAULT_GRAY_FILL: Fill = makePatternFill({ patternType: 'gray125' });\n\n// ---- internal helpers ------------------------------------------------------\n\nconst freezeColor = (c: Color | Partial<Color>): Color => (Object.isFrozen(c) ? (c as Color) : makeColor(c));\nconst freezeStop = (s: GradientStop): GradientStop => (Object.isFrozen(s) ? s : makeGradientStop(s.position, s.color));\n\nconst argbToCssHex = (color: Color | undefined): string | undefined => {\n const argb = colorToHex(color);\n return argb ? `#${argb.slice(2)}` : undefined;\n};\n\n/**\n * Translate a {@link Fill} to a CSS-property record suitable for HTML preview.\n * `'solid'` PatternFill renders as `background-color`, other pattern types\n * collapse to bgColor (CSS has no built-in equivalent of Excel hatch patterns).\n * GradientFill emits a CSS `background-image` with `linear-gradient(<angle>,\n * …)` for `type='linear'` or `radial-gradient(circle, …)` for `type='path'`.\n *\n * theme/auto colours and unresolvable inputs are skipped (returns `{}`) so\n * callers can spread without overwriting upstream defaults.\n */\nexport function fillToCss(fill: Fill | undefined): Record<string, string> {\n const css: Record<string, string> = {};\n if (!fill) return css;\n if (fill.kind === 'pattern') {\n if (fill.patternType === 'none' || fill.patternType === undefined) return css;\n if (fill.patternType === 'solid') {\n const fg = argbToCssHex(fill.fgColor);\n if (fg !== undefined) css['background-color'] = fg;\n return css;\n }\n // Non-solid patterns collapse to the bg colour as a coarse approximation;\n // CSS has no native Excel hatch equivalent.\n const bg = argbToCssHex(fill.bgColor) ?? argbToCssHex(fill.fgColor);\n if (bg !== undefined) css['background-color'] = bg;\n return css;\n }\n // Gradient fill — need at least one resolvable stop to emit anything.\n const stopParts: string[] = [];\n for (const s of fill.stops) {\n const hex = argbToCssHex(s.color);\n if (hex === undefined) continue;\n stopParts.push(`${hex} ${(s.position * 100).toFixed(2)}%`);\n }\n if (stopParts.length === 0) return css;\n if (fill.type === 'linear') {\n const angle = fill.degree ?? 0;\n css['background-image'] = `linear-gradient(${angle}deg, ${stopParts.join(', ')})`;\n } else {\n css['background-image'] = `radial-gradient(circle, ${stopParts.join(', ')})`;\n }\n return css;\n}\n","// Cell font value object. Mirrors openpyxl/openpyxl/styles/fonts.py.\n//\n// Font is the most varied of the styles slots — most fields are nested\n// elements with a single `val` attribute (`<sz val=\"11\"/>`), the boolean\n// toggles (`<b/>`, `<i/>`, ...) are presence-only marker tags, and\n// `<color>` is a fully nested object element. The schema layer carries\n// each pattern as its own ElementDef kind.\n\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\nimport { type Color, colorToHex, makeColor } from './colors.js';\n\n/** Underline styles per openpyxl's NestedNoneSet. */\nexport type UnderlineStyle = 'single' | 'double' | 'singleAccounting' | 'doubleAccounting';\nexport const UNDERLINE_STYLES: ReadonlyArray<UnderlineStyle> = Object.freeze([\n 'single',\n 'double',\n 'singleAccounting',\n 'doubleAccounting',\n]);\n\nexport type VertAlign = 'baseline' | 'superscript' | 'subscript';\nexport const VERT_ALIGNS: ReadonlyArray<VertAlign> = Object.freeze(['baseline', 'superscript', 'subscript']);\n\nexport type FontScheme = 'major' | 'minor';\nexport const FONT_SCHEMES: ReadonlyArray<FontScheme> = Object.freeze(['major', 'minor']);\n\nconst UNDERLINE_SET: ReadonlySet<string> = new Set(UNDERLINE_STYLES);\nconst VERT_SET: ReadonlySet<string> = new Set(VERT_ALIGNS);\nconst SCHEME_SET: ReadonlySet<string> = new Set(FONT_SCHEMES);\n\nexport interface Font {\n readonly name?: string;\n readonly charset?: number;\n /** Font family code (0..14). */\n readonly family?: number;\n /** Point size; openpyxl name = `sz`. */\n readonly size?: number;\n readonly color?: Color;\n readonly bold?: boolean;\n readonly italic?: boolean;\n readonly strike?: boolean;\n readonly outline?: boolean;\n readonly shadow?: boolean;\n readonly condense?: boolean;\n readonly extend?: boolean;\n readonly underline?: UnderlineStyle;\n readonly vertAlign?: VertAlign;\n readonly scheme?: FontScheme;\n}\n\n/**\n * Input shape for building a Font. Wider than `Partial<Font>` under\n * `exactOptionalPropertyTypes`: a field may be present and `undefined`, which\n * {@link makeFont} drops the same way it drops an absent one. That is what lets\n * a caller merging two fonts express \"this field goes away\".\n */\nexport type FontPatch = { [K in keyof Font]?: Font[K] | undefined };\n\nexport function makeFont(opts: FontPatch = {}): Font {\n const out: { -readonly [K in keyof Font]: Font[K] } = {};\n if (opts.name !== undefined) {\n if (typeof opts.name !== 'string') {\n throw new OpenXmlSchemaError(`Font name must be a string; got ${typeof opts.name}`);\n }\n out.name = opts.name;\n }\n if (opts.charset !== undefined) {\n if (!Number.isInteger(opts.charset)) {\n throw new OpenXmlSchemaError(`Font charset must be an integer; got ${opts.charset}`);\n }\n out.charset = opts.charset;\n }\n if (opts.family !== undefined) {\n if (!Number.isInteger(opts.family) || opts.family < 0 || opts.family > 14) {\n throw new OpenXmlSchemaError(`Font family must be 0..14; got ${opts.family}`);\n }\n out.family = opts.family;\n }\n if (opts.size !== undefined) {\n if (!Number.isFinite(opts.size) || opts.size <= 0) {\n throw new OpenXmlSchemaError(`Font size must be positive; got ${opts.size}`);\n }\n out.size = opts.size;\n }\n if (opts.color !== undefined) {\n out.color = Object.isFrozen(opts.color) ? opts.color : makeColor(opts.color);\n }\n if (opts.bold !== undefined) out.bold = opts.bold;\n if (opts.italic !== undefined) out.italic = opts.italic;\n if (opts.strike !== undefined) out.strike = opts.strike;\n if (opts.outline !== undefined) out.outline = opts.outline;\n if (opts.shadow !== undefined) out.shadow = opts.shadow;\n if (opts.condense !== undefined) out.condense = opts.condense;\n if (opts.extend !== undefined) out.extend = opts.extend;\n if (opts.underline !== undefined) {\n if (!UNDERLINE_SET.has(opts.underline)) {\n throw new OpenXmlSchemaError(\n `Font underline must be one of [${UNDERLINE_STYLES.join(', ')}]; got \"${opts.underline}\"`,\n );\n }\n out.underline = opts.underline;\n }\n if (opts.vertAlign !== undefined) {\n if (!VERT_SET.has(opts.vertAlign)) {\n throw new OpenXmlSchemaError(\n `Font vertAlign must be one of [${VERT_ALIGNS.join(', ')}]; got \"${opts.vertAlign}\"`,\n );\n }\n out.vertAlign = opts.vertAlign;\n }\n if (opts.scheme !== undefined) {\n if (!SCHEME_SET.has(opts.scheme)) {\n throw new OpenXmlSchemaError(`Font scheme must be one of [${FONT_SCHEMES.join(', ')}]; got \"${opts.scheme}\"`);\n }\n out.scheme = opts.scheme;\n }\n return Object.freeze(out);\n}\n\n/** Excel's default cell font: Calibri 11, minor scheme, theme=1 colour. */\nexport const DEFAULT_FONT: Font = makeFont({\n name: 'Calibri',\n size: 11,\n family: 2,\n scheme: 'minor',\n color: makeColor({ theme: 1 }),\n});\n\n/**\n * Translate a {@link Font} to a CSS-property record suitable for HTML\n * rendering / preview. Boolean toggles map to weight/style/decoration,\n * `size` becomes `font-size: <n>pt`, and an explicit rgb/indexed\n * `color` is rendered as `#RRGGBB` (alpha dropped). theme/auto colours\n * are skipped — callers without a theme can't resolve them.\n *\n * `vertAlign='superscript'|'subscript'` lowers `font-size` to 0.83em\n * (W3C convention) and sets `vertical-align`.\n *\n * Returns `{}` for an empty Font so callers can spread it without\n * overwriting upstream defaults.\n */\nexport function fontToCss(font: Font | undefined): Record<string, string> {\n const css: Record<string, string> = {};\n if (!font) return css;\n if (font.name !== undefined) {\n // CSS expects quoted family names that contain spaces; quote unconditionally\n // to keep the generator simple.\n css['font-family'] = `'${font.name.replace(/'/g, \"\\\\'\")}'`;\n }\n if (font.size !== undefined) css['font-size'] = `${font.size}pt`;\n if (font.bold) css['font-weight'] = 'bold';\n if (font.italic) css['font-style'] = 'italic';\n const decorations: string[] = [];\n if (font.underline !== undefined) decorations.push('underline');\n if (font.strike) decorations.push('line-through');\n if (decorations.length > 0) css['text-decoration'] = decorations.join(' ');\n if (font.color !== undefined) {\n const argb = colorToHex(font.color);\n if (argb !== undefined) {\n // Drop alpha (CSS hex with alpha is poorly-supported in Excel-style preview).\n css['color'] = `#${argb.slice(2)}`;\n }\n }\n if (font.vertAlign === 'superscript' || font.vertAlign === 'subscript') {\n css['vertical-align'] = font.vertAlign;\n // Match W3C-recommended scaling for sup/sub when font-size is not explicit.\n if (css['font-size'] === undefined) css['font-size'] = '0.83em';\n }\n return css;\n}\n","// Number-format value object + the OOXML built-in format catalogue.\n// Mirrors openpyxl/openpyxl/styles/numbers.py.\n//\n// Excel keeps two parallel namespaces for number formats:\n// * IDs 0–163 are reserved for the built-in catalogue (sparsely\n// populated; only 38 of them are actually defined).\n// * IDs ≥ 164 are user-defined / locale-specific. The Stylesheet\n// pool allocates these on demand (phase 2 §3.4).\n\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\n\n/** Canonical OOXML built-in number formats — verbatim from openpyxl. */\nexport const BUILTIN_FORMATS: Readonly<Record<number, string>> = Object.freeze({\n 0: 'General',\n 1: '0',\n 2: '0.00',\n 3: '#,##0',\n 4: '#,##0.00',\n 5: '\"$\"#,##0_);(\"$\"#,##0)',\n 6: '\"$\"#,##0_);[Red](\"$\"#,##0)',\n 7: '\"$\"#,##0.00_);(\"$\"#,##0.00)',\n 8: '\"$\"#,##0.00_);[Red](\"$\"#,##0.00)',\n 9: '0%',\n 10: '0.00%',\n 11: '0.00E+00',\n 12: '# ?/?',\n 13: '# ??/??',\n 14: 'mm-dd-yy',\n 15: 'd-mmm-yy',\n 16: 'd-mmm',\n 17: 'mmm-yy',\n 18: 'h:mm AM/PM',\n 19: 'h:mm:ss AM/PM',\n 20: 'h:mm',\n 21: 'h:mm:ss',\n 22: 'm/d/yy h:mm',\n 37: '#,##0_);(#,##0)',\n 38: '#,##0_);[Red](#,##0)',\n 39: '#,##0.00_);(#,##0.00)',\n 40: '#,##0.00_);[Red](#,##0.00)',\n 41: '_(* #,##0_);_(* \\\\(#,##0\\\\);_(* \"-\"_);_(@_)',\n 42: '_(\"$\"* #,##0_);_(\"$\"* \\\\(#,##0\\\\);_(\"$\"* \"-\"_);_(@_)',\n 43: '_(* #,##0.00_);_(* \\\\(#,##0.00\\\\);_(* \"-\"??_);_(@_)',\n 44: '_(\"$\"* #,##0.00_)_(\"$\"* \\\\(#,##0.00\\\\)_(\"$\"* \"-\"??_)_(@_)',\n 45: 'mm:ss',\n 46: '[h]:mm:ss',\n 47: 'mmss.0',\n 48: '##0.0E+0',\n 49: '@',\n});\n\n/** First numFmtId Excel reserves for user-defined formats. */\nexport const BUILTIN_FORMATS_MAX_SIZE = 164;\n\nconst REVERSE: ReadonlyMap<string, number> = new Map(Object.entries(BUILTIN_FORMATS).map(([k, v]) => [v, Number(k)]));\n\n// ---- well-known format codes (named exports for ergonomics) ---------------\n//\n// Inlined rather than indexed off BUILTIN_FORMATS to keep TS' tuple\n// lookup from widening to `string | undefined`.\n\nexport const FORMAT_GENERAL = 'General';\nexport const FORMAT_TEXT = '@';\nexport const FORMAT_NUMBER = '0';\nexport const FORMAT_NUMBER_00 = '0.00';\nexport const FORMAT_PERCENTAGE = '0%';\nexport const FORMAT_PERCENTAGE_00 = '0.00%';\nexport const FORMAT_DATE_DATETIME = 'yyyy-mm-dd h:mm:ss';\nexport const FORMAT_DATE_TIMEDELTA = '[hh]:mm:ss';\nexport const FORMAT_DATE_YYYYMMDD2 = 'yyyy-mm-dd';\n\n// ---- helpers ---------------------------------------------------------------\n\n/** Look up the format code for a given numFmtId, or `undefined` if unknown. */\nexport function builtinFormatCode(id: number): string | undefined {\n return Object.hasOwn(BUILTIN_FORMATS, id) ? BUILTIN_FORMATS[id] : undefined;\n}\n\n/** Look up the numFmtId for a given format code, or `undefined` if not built-in. */\nexport function builtinFormatId(code: string): number | undefined {\n return REVERSE.get(code);\n}\n\n/** True iff `code` is one of the OOXML built-in format strings. */\nexport function isBuiltinFormat(code: string): boolean {\n return REVERSE.has(code);\n}\n\n// ---- date / timedelta heuristics ------------------------------------------\n//\n// Mirror openpyxl's regex strategy verbatim. The two patterns work together\n// to decide whether a format implies a date / time / duration interpretation.\n\nconst COLORS_GROUP = '\\\\[(BLACK|BLUE|CYAN|GREEN|MAGENTA|RED|WHITE|YELLOW)\\\\]';\nconst LITERAL_GROUP = '\"[^\"]*\"';\nconst LOCALE_GROUP = '\\\\[(?!hh?\\\\]|mm?\\\\]|ss?\\\\])[^\\\\]]*\\\\]';\n\nconst STRIP_RE = new RegExp(`${COLORS_GROUP}|${LITERAL_GROUP}|${LOCALE_GROUP}`, 'g');\nconst DATE_TOKEN_RE = /(?<![_\\\\])[dmhysDMHYS]/;\nconst TIMEDELTA_RE = /\\[hh?\\](:mm(:ss(\\.0*)?)?)?|\\[mm?\\](:ss(\\.0*)?)?|\\[ss?\\](\\.0*)?/i;\n\n/**\n * Heuristic: does the format string imply a date / time interpretation?\n * Looks at only the first format section (positive-value branch); strips\n * literals, colour codes and locale modifiers before scanning for date\n * tokens (d/m/h/y/s, case-insensitive) that aren't escaped.\n */\nexport function isDateFormat(code: string | undefined | null): boolean {\n if (code == null) return false;\n const head = code.split(';')[0] ?? '';\n const stripped = head.replace(STRIP_RE, '');\n return DATE_TOKEN_RE.test(stripped);\n}\n\n/** Heuristic: does the format string indicate a duration ([h]:mm:ss etc.)? */\nexport function isTimedeltaFormat(code: string | undefined | null): boolean {\n if (code == null) return false;\n const head = code.split(';')[0] ?? '';\n return TIMEDELTA_RE.test(head);\n}\n\n/** Categorise a date format as 'date', 'time', 'datetime' or undefined. */\nexport function classifyDateFormat(code: string | undefined | null): 'date' | 'time' | 'datetime' | undefined {\n if (!isDateFormat(code)) return undefined;\n // Reach here only with a non-null code.\n const head = (code as string).split(';')[0] ?? '';\n // Same locale / literal stripping the date detector applies.\n const stripped = head.replace(STRIP_RE, '');\n let date = false;\n let time = false;\n for (const ch of stripped) {\n if (ch === 'd' || ch === 'D' || ch === 'y' || ch === 'Y') date = true;\n else if (ch === 'h' || ch === 'H' || ch === 's' || ch === 'S') time = true;\n if (date && time) break;\n }\n if (date && time) return 'datetime';\n if (date) return 'date';\n return 'time';\n}\n\n// ---- NumberFormat value -----------------------------------------------------\n\nexport interface NumberFormat {\n /** Stylesheet-relative numFmtId. */\n readonly numFmtId: number;\n readonly formatCode: string;\n}\n\nexport function makeNumberFormat(opts: { numFmtId: number; formatCode: string }): NumberFormat {\n if (!Number.isInteger(opts.numFmtId) || opts.numFmtId < 0) {\n throw new OpenXmlSchemaError(`NumberFormat numFmtId must be a non-negative integer; got ${opts.numFmtId}`);\n }\n if (typeof opts.formatCode !== 'string') {\n throw new OpenXmlSchemaError('NumberFormat formatCode must be a string');\n }\n return Object.freeze({ numFmtId: opts.numFmtId, formatCode: opts.formatCode });\n}\n","// Stylesheet pool. The workbook holds dedup pools per style component (fonts /\n// fills / borders / numFmts / cellXfs / cellStyleXfs); cells reference entries\n// by index via a `styleId` (an index into cellXfs).\n//\n// All adds run through `add*` free functions that look up the pool via\n// `stableStringify`-keyed maps so the same logical Font / Fill / etc. added\n// 1000× lands in a single pool slot.\n\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\nimport { stableStringify } from '../utils/stable-stringify.js';\nimport type { Alignment } from './alignment.js';\nimport type { Border } from './borders.js';\nimport { DEFAULT_BORDER } from './borders.js';\nimport type { Fill } from './fills.js';\nimport { DEFAULT_EMPTY_FILL, DEFAULT_GRAY_FILL } from './fills.js';\nimport type { Font } from './fonts.js';\nimport { DEFAULT_FONT } from './fonts.js';\nimport { BUILTIN_FORMATS_MAX_SIZE, builtinFormatId } from './numbers.js';\nimport type { Protection } from './protection.js';\n\n/**\n * One entry in the cellXfs / cellStyleXfs pool. Represents the union of\n * indexes-into-other-pools that a cell or named style points at.\n *\n * Mirrors openpyxl's CellStyle (styles/cell_style.py). The TS port keeps it as\n * a plain readonly object — no class, no methods. The Stylesheet `addCellXf`\n * allocates the index; cells store only that.\n */\nexport interface CellXf {\n readonly fontId: number;\n readonly fillId: number;\n readonly borderId: number;\n readonly numFmtId: number;\n /** Index into cellStyleXfs — only set for direct-cell xfs that point at a NamedStyle. */\n readonly xfId?: number;\n readonly alignment?: Alignment;\n readonly protection?: Protection;\n readonly applyFont?: boolean;\n readonly applyFill?: boolean;\n readonly applyBorder?: boolean;\n readonly applyNumberFormat?: boolean;\n readonly applyAlignment?: boolean;\n readonly applyProtection?: boolean;\n readonly pivotButton?: boolean;\n readonly quotePrefix?: boolean;\n}\n\nexport interface Stylesheet {\n fonts: Font[];\n fills: Fill[];\n borders: Border[];\n /** numFmtId → format code (custom IDs only; built-ins implicit). */\n numFmts: Map<number, string>;\n cellXfs: CellXf[];\n cellStyleXfs: CellXf[];\n /** Named styles (Excel's \"Cell Styles\" gallery; populated by addNamedStyle). */\n namedStyles?: Array<import('./named-styles.js').StylesheetNamedStyle>;\n /**\n * The tail of `<styleSheet>` this model doesn't cover — `<tableStyles>`,\n * `<colors>` and `<extLst>` (which is where Excel keeps its x14/x15 slicer\n * and timeline styles). Captured verbatim in document order so re-saving a\n * loaded workbook keeps them; CT_Stylesheet puts all three after `<dxfs>`,\n * so the writer appends them there.\n */\n stylesXmlTail?: Array<import('../xml/tree.js').XmlNode>;\n\n // Internal dedup maps. Underscore-prefixed so JSON / structuredClone\n // serialisation can choose to skip them; never part of the public API.\n _fontIdByKey: Map<string, number>;\n _fillIdByKey: Map<string, number>;\n _borderIdByKey: Map<string, number>;\n _xfIdByKey: Map<string, number>;\n _styleXfIdByKey: Map<string, number>;\n _numFmtIdByCode: Map<string, number>;\n _namedStyleByName?: Map<string, import('./named-styles.js').StylesheetNamedStyle>;\n}\n\n/**\n * Build a fresh Stylesheet pre-populated with Excel's required default entries.\n * Mirrors openpyxl's empty Stylesheet: fonts: [DEFAULT_FONT] (index 0) fills:\n * [DEFAULT_EMPTY_FILL,\n * DEFAULT_GRAY_FILL] (indices 0, 1 — required)\n * borders: [DEFAULT_BORDER] (index 0) cellXfs: empty (indices allocated on\n * demand)\n */\nexport function makeStylesheet(): Stylesheet {\n const fontKey = stableStringify(DEFAULT_FONT);\n const fill0Key = stableStringify(DEFAULT_EMPTY_FILL);\n const fill1Key = stableStringify(DEFAULT_GRAY_FILL);\n const borderKey = stableStringify(DEFAULT_BORDER);\n\n return {\n fonts: [DEFAULT_FONT],\n fills: [DEFAULT_EMPTY_FILL, DEFAULT_GRAY_FILL],\n borders: [DEFAULT_BORDER],\n numFmts: new Map(),\n cellXfs: [],\n cellStyleXfs: [],\n _fontIdByKey: new Map([[fontKey, 0]]),\n _fillIdByKey: new Map([\n [fill0Key, 0],\n [fill1Key, 1],\n ]),\n _borderIdByKey: new Map([[borderKey, 0]]),\n _xfIdByKey: new Map(),\n _styleXfIdByKey: new Map(),\n _numFmtIdByCode: new Map(),\n };\n}\n\n// ---- pool add helpers ------------------------------------------------------\n\n/** Add a Font to the pool, returning its 0-based index. Idempotent. */\nexport function addFont(ss: Stylesheet, font: Font): number {\n return addToPool(font, ss.fonts, ss._fontIdByKey);\n}\n\n/** Add a Fill to the pool, returning its 0-based index. Idempotent. */\nexport function addFill(ss: Stylesheet, fill: Fill): number {\n return addToPool(fill, ss.fills, ss._fillIdByKey);\n}\n\n/** Add a Border to the pool, returning its 0-based index. Idempotent. */\nexport function addBorder(ss: Stylesheet, border: Border): number {\n return addToPool(border, ss.borders, ss._borderIdByKey);\n}\n\n/**\n * Resolve a number-format string to its numFmtId.\n * - Built-in codes return their canonical OOXML ID.\n * - Otherwise the custom code is registered (and allocated an ID\n * ≥ {@link BUILTIN_FORMATS_MAX_SIZE}). Idempotent.\n */\nexport function addNumFmt(ss: Stylesheet, formatCode: string): number {\n const builtin = builtinFormatId(formatCode);\n if (builtin !== undefined) return builtin;\n const cached = ss._numFmtIdByCode.get(formatCode);\n if (cached !== undefined) return cached;\n const id = BUILTIN_FORMATS_MAX_SIZE + ss.numFmts.size;\n ss.numFmts.set(id, formatCode);\n ss._numFmtIdByCode.set(formatCode, id);\n return id;\n}\n\n/** Add a CellXf to the cellXfs pool, returning its 0-based index. Idempotent. */\nexport function addCellXf(ss: Stylesheet, xf: CellXf): number {\n validateCellXfRefs(ss, xf, /* isStyle */ false);\n return addToPool(xf, ss.cellXfs, ss._xfIdByKey);\n}\n\n/** Add a CellXf to the cellStyleXfs pool. Idempotent. */\nexport function addCellStyleXf(ss: Stylesheet, xf: CellXf): number {\n validateCellXfRefs(ss, xf, /* isStyle */ true);\n return addToPool(xf, ss.cellStyleXfs, ss._styleXfIdByKey);\n}\n\n// ---- internals -------------------------------------------------------------\n\nconst addToPool = <T>(value: T, pool: T[], byKey: Map<string, number>): number => {\n const key = stableStringify(value);\n const cached = byKey.get(key);\n if (cached !== undefined) return cached;\n const id = pool.length;\n pool.push(value);\n byKey.set(key, id);\n return id;\n};\n\nconst validateCellXfRefs = (ss: Stylesheet, xf: CellXf, isStyle: boolean): void => {\n if (xf.fontId < 0 || xf.fontId >= ss.fonts.length) {\n throw new OpenXmlSchemaError(`CellXf.fontId ${xf.fontId} out of range [0, ${ss.fonts.length})`);\n }\n if (xf.fillId < 0 || xf.fillId >= ss.fills.length) {\n throw new OpenXmlSchemaError(`CellXf.fillId ${xf.fillId} out of range [0, ${ss.fills.length})`);\n }\n if (xf.borderId < 0 || xf.borderId >= ss.borders.length) {\n throw new OpenXmlSchemaError(`CellXf.borderId ${xf.borderId} out of range [0, ${ss.borders.length})`);\n }\n // numFmtId is permissive: built-ins or any registered custom ID.\n if (!Number.isInteger(xf.numFmtId) || xf.numFmtId < 0) {\n throw new OpenXmlSchemaError(`CellXf.numFmtId must be a non-negative integer; got ${xf.numFmtId}`);\n }\n if (!isStyle && xf.xfId !== undefined) {\n if (xf.xfId < 0 || xf.xfId >= ss.cellStyleXfs.length) {\n throw new OpenXmlSchemaError(`CellXf.xfId ${xf.xfId} out of range [0, ${ss.cellStyleXfs.length})`);\n }\n }\n};\n\n/** Returns the currently registered numFmt entries (built-ins are implicit and not included). */\nexport function getCustomNumFmts(ss: Stylesheet): ReadonlyArray<{ id: number; code: string }> {\n const out: Array<{ id: number; code: string }> = [];\n for (const [id, code] of ss.numFmts.entries()) out.push({ id, code });\n // numFmts is keyed by id; sort for deterministic output.\n out.sort((a, b) => a.id - b.id);\n return out;\n}\n\n/** Read-only snapshot of every Font entry in the pool, indexed by id. */\nexport function listFonts(ss: Stylesheet): ReadonlyArray<Font> {\n return ss.fonts;\n}\n\n/** Read-only snapshot of every Fill entry in the pool, indexed by id. */\nexport function listFills(ss: Stylesheet): ReadonlyArray<Fill> {\n return ss.fills;\n}\n\n/** Read-only snapshot of every Border entry in the pool, indexed by id. */\nexport function listBorders(ss: Stylesheet): ReadonlyArray<Border> {\n return ss.borders;\n}\n\n/** Read-only snapshot of every CellXf entry in the cellXfs pool. */\nexport function listCellXfs(ss: Stylesheet): ReadonlyArray<CellXf> {\n return ss.cellXfs;\n}\n\n/** Read-only snapshot of every CellStyleXf entry (named-style xfs). */\nexport function listCellStyleXfs(ss: Stylesheet): ReadonlyArray<CellXf> {\n return ss.cellStyleXfs;\n}\n\n/**\n * Convenience: build the default `cellXfs[0]` Excel emits — points at the\n * workbook's font 0 / fill 0 / border 0 / numFmtId 0 (General).\n */\nexport function defaultCellXf(): CellXf {\n return Object.freeze({ fontId: 0, fillId: 0, borderId: 0, numFmtId: 0 });\n}\n\n/**\n * A cell's look expressed across every style axis at once. Each axis is\n * independent: pass any subset, and the axes you leave out are decided by\n * whichever function consumes the spec.\n */\nexport interface CellStyleSpec {\n font?: Font;\n fill?: Fill;\n border?: Border;\n alignment?: Alignment;\n protection?: Protection;\n numberFormat?: string;\n}\n\n/**\n * Resolve a style spec to the CellXf fields it sets, registering each component\n * in its pool. The result is a patch, not a whole xf: axes absent from `spec`\n * are absent here too, so a caller can either spread it over\n * {@link defaultCellXf} for a complete style or over an existing xf to merge.\n *\n * Every path that turns a user-facing style spec into an xf goes through this,\n * so a new axis on {@link CellStyleSpec} reaches the modelled writer and the\n * streaming write-only writer together.\n */\nexport function buildXfPatch(ss: Stylesheet, spec: CellStyleSpec): { -readonly [K in keyof CellXf]?: CellXf[K] } {\n const patch: { -readonly [K in keyof CellXf]?: CellXf[K] } = {};\n if (spec.font !== undefined) {\n patch.fontId = addFont(ss, spec.font);\n patch.applyFont = true;\n }\n if (spec.fill !== undefined) {\n patch.fillId = addFill(ss, spec.fill);\n patch.applyFill = true;\n }\n if (spec.border !== undefined) {\n patch.borderId = addBorder(ss, spec.border);\n patch.applyBorder = true;\n }\n if (spec.alignment !== undefined) {\n patch.alignment = spec.alignment;\n patch.applyAlignment = true;\n }\n if (spec.protection !== undefined) {\n patch.protection = spec.protection;\n patch.applyProtection = true;\n }\n if (spec.numberFormat !== undefined) {\n patch.numFmtId = addNumFmt(ss, spec.numberFormat);\n patch.applyNumberFormat = true;\n }\n return patch;\n}\n","// NamedStyle value object + curated built-in catalogue. Mirrors\n// openpyxl/openpyxl/styles/named_styles.py + styles/builtins.py.\n//\n// A `NamedStyle` is a label that bundles Font + Fill + Border +\n// Alignment + Protection + number-format string. Cells reference it\n// via the cellStyleXfs pool. This module:\n// 1. defines the value type;\n// 2. wires `addNamedStyle` (registers sub-objects in the Stylesheet,\n// allocates a cellStyleXf, then attaches the name);\n// 3. ships a curated subset of Excel's \"Cell Styles\" gallery as\n// plain-object specs and an `ensureBuiltinStyle` ergonomics\n// function that registers one on demand.\n//\n// The Accent1..6 with 20/40/60% variants and `pandas_highlight` are\n// deferred — they balloon the bundle without earning their keep on\n// the read/write hot path.\n\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\nimport type { Alignment } from './alignment.js';\nimport type { Border } from './borders.js';\nimport { makeColor } from './colors.js';\nimport type { Fill } from './fills.js';\nimport { makePatternFill } from './fills.js';\nimport type { Font } from './fonts.js';\nimport { makeFont } from './fonts.js';\nimport { addBorder, addCellStyleXf, addFill, addFont, addNumFmt, type CellXf, type Stylesheet } from './stylesheet.js';\n\nexport interface NamedStyle {\n readonly name: string;\n /** OOXML built-in id (0..N); absent for user-defined styles. */\n readonly builtinId?: number;\n readonly customBuiltin?: boolean;\n readonly hidden?: boolean;\n readonly iLevel?: number;\n readonly font?: Font;\n readonly fill?: Fill;\n readonly border?: Border;\n readonly alignment?: Alignment;\n readonly protection?: Protection;\n readonly numberFormat?: string;\n}\n\nimport type { Protection } from './protection.js';\n\n/**\n * NamedStyle as it sits inside the Stylesheet (an `<cellStyles>` entry).\n * Captures the resolved cellStyleXfs index so the writer can emit the\n * `<cellStyle xfId=\"…\" name=\"…\" builtinId=\"…\"/>` element directly.\n */\nexport interface StylesheetNamedStyle {\n readonly name: string;\n readonly xfId: number;\n readonly builtinId?: number;\n readonly customBuiltin?: boolean;\n readonly hidden?: boolean;\n readonly iLevel?: number;\n}\n\n/**\n * Register a NamedStyle on the Stylesheet:\n * 1. add Font / Fill / Border / NumberFormat to their pools\n * 2. push a CellXf with apply* flags into cellStyleXfs\n * 3. append a {name, xfId, builtinId} entry into the workbook's\n * namedStyles list (caller-managed; this function returns the\n * xfId so callers can connect the dots)\n * Idempotent on (name): re-registering by the same name returns the\n * cached xfId.\n */\nexport function addNamedStyle(ss: Stylesheet, style: NamedStyle): number {\n const cached = ss._namedStyleByName?.get(style.name);\n if (cached !== undefined) return cached.xfId;\n\n const fontId = style.font !== undefined ? addFont(ss, style.font) : 0;\n const fillId = style.fill !== undefined ? addFill(ss, style.fill) : 0;\n const borderId = style.border !== undefined ? addBorder(ss, style.border) : 0;\n const numFmtId = style.numberFormat !== undefined ? addNumFmt(ss, style.numberFormat) : 0;\n\n // openpyxl convention: cellStyleXfs entries (the \"base\" XFs of named\n // styles) don't carry apply* flags. The cellXf that bridges a cell to\n // a named style is the one that sets apply* — that's what Excel reads\n // to decide whether to honour the inherited font / fill / border.\n const xf: CellXf = {\n fontId,\n fillId,\n borderId,\n numFmtId,\n ...(style.alignment !== undefined ? { alignment: style.alignment } : {}),\n ...(style.protection !== undefined ? { protection: style.protection } : {}),\n };\n const xfId = addCellStyleXf(ss, xf);\n\n if (ss._namedStyleByName === undefined) ss._namedStyleByName = new Map();\n if (ss.namedStyles === undefined) ss.namedStyles = [];\n const entry: StylesheetNamedStyle = {\n name: style.name,\n xfId,\n ...(style.builtinId !== undefined ? { builtinId: style.builtinId } : {}),\n ...(style.customBuiltin !== undefined ? { customBuiltin: style.customBuiltin } : {}),\n ...(style.hidden !== undefined ? { hidden: style.hidden } : {}),\n ...(style.iLevel !== undefined ? { iLevel: style.iLevel } : {}),\n };\n ss.namedStyles.push(entry);\n ss._namedStyleByName.set(style.name, entry);\n return xfId;\n}\n\n// ---- built-in catalogue ----------------------------------------------------\n//\n// Common ground: the gallery's body fonts are all Calibri 12, family 2,\n// minor scheme, theme-1 colour. Specific styles override font / fill /\n// border / numberFormat as needed.\n\nconst BODY_FONT: Font = makeFont({\n name: 'Calibri',\n family: 2,\n size: 12,\n color: makeColor({ theme: 1 }),\n scheme: 'minor',\n});\n\nconst fillRgb = (rgb: string, fg = true): Fill =>\n makePatternFill(\n fg ? { patternType: 'solid', bgColor: makeColor({ rgb }), fgColor: makeColor({ rgb }) } : { patternType: 'solid' },\n );\n\n/** Curated subset of openpyxl's `styles` dict. Keys match the user-visible names. */\nexport const BUILTIN_NAMED_STYLES: Readonly<Record<string, NamedStyle>> = Object.freeze({\n // -------- core ----------------------------------------------------------\n Normal: { name: 'Normal', builtinId: 0, font: BODY_FONT },\n\n // -------- semantic state ------------------------------------------------\n Good: {\n name: 'Good',\n builtinId: 26,\n font: makeFont({ ...BODY_FONT, color: makeColor({ rgb: 'FF006100' }) }),\n fill: fillRgb('FFC6EFCE'),\n },\n Bad: {\n name: 'Bad',\n builtinId: 27,\n font: makeFont({ ...BODY_FONT, color: makeColor({ rgb: 'FF9C0006' }) }),\n fill: fillRgb('FFFFC7CE'),\n },\n Neutral: {\n name: 'Neutral',\n builtinId: 28,\n font: makeFont({ ...BODY_FONT, color: makeColor({ rgb: 'FF9C5700' }) }),\n fill: fillRgb('FFFFEB9C'),\n },\n\n // -------- data ----------------------------------------------------------\n Calculation: {\n name: 'Calculation',\n builtinId: 22,\n font: makeFont({ ...BODY_FONT, bold: true, color: makeColor({ rgb: 'FFFA7D00' }) }),\n fill: fillRgb('FFF2F2F2'),\n },\n 'Check Cell': {\n name: 'Check Cell',\n builtinId: 23,\n font: makeFont({ ...BODY_FONT, bold: true, color: makeColor({ rgb: 'FFFFFFFF' }) }),\n fill: fillRgb('FFA5A5A5'),\n },\n 'Linked Cell': {\n name: 'Linked Cell',\n builtinId: 24,\n font: makeFont({ ...BODY_FONT, color: makeColor({ rgb: 'FFFA7D00' }) }),\n },\n Note: {\n name: 'Note',\n builtinId: 10,\n font: BODY_FONT,\n fill: fillRgb('FFFFFFC0'),\n },\n 'Warning Text': {\n name: 'Warning Text',\n builtinId: 11,\n font: makeFont({ ...BODY_FONT, color: makeColor({ rgb: 'FFFF0000' }) }),\n },\n Input: {\n name: 'Input',\n builtinId: 20,\n font: makeFont({ ...BODY_FONT, color: makeColor({ rgb: 'FF3F3F76' }) }),\n fill: fillRgb('FFFFCC99'),\n },\n Output: {\n name: 'Output',\n builtinId: 21,\n font: makeFont({ ...BODY_FONT, bold: true, color: makeColor({ rgb: 'FF3F3F3F' }) }),\n fill: fillRgb('FFF2F2F2'),\n },\n 'Explanatory Text': {\n name: 'Explanatory Text',\n builtinId: 53,\n font: makeFont({ ...BODY_FONT, italic: true, color: makeColor({ rgb: 'FF7F7F7F' }) }),\n },\n\n // -------- titles & headings ---------------------------------------------\n Title: {\n name: 'Title',\n builtinId: 15,\n font: makeFont({ name: 'Cambria', family: 2, size: 18, scheme: 'major', color: makeColor({ theme: 3 }) }),\n },\n 'Headline 1': {\n name: 'Headline 1',\n builtinId: 16,\n font: makeFont({ ...BODY_FONT, bold: true, size: 15, color: makeColor({ theme: 3 }) }),\n },\n 'Headline 2': {\n name: 'Headline 2',\n builtinId: 17,\n font: makeFont({ ...BODY_FONT, bold: true, size: 13, color: makeColor({ theme: 3 }) }),\n },\n 'Headline 3': {\n name: 'Headline 3',\n builtinId: 18,\n font: makeFont({ ...BODY_FONT, bold: true, color: makeColor({ theme: 3 }) }),\n },\n 'Headline 4': {\n name: 'Headline 4',\n builtinId: 19,\n font: makeFont({ ...BODY_FONT, bold: true, italic: true, color: makeColor({ theme: 3 }) }),\n },\n Total: {\n name: 'Total',\n builtinId: 25,\n font: makeFont({ ...BODY_FONT, bold: true }),\n },\n\n // -------- numeric -------------------------------------------------------\n Comma: { name: 'Comma', builtinId: 3, font: BODY_FONT, numberFormat: '#,##0.00' },\n 'Comma [0]': { name: 'Comma [0]', builtinId: 6, font: BODY_FONT, numberFormat: '#,##0' },\n Currency: { name: 'Currency', builtinId: 4, font: BODY_FONT, numberFormat: '\"$\"#,##0.00' },\n 'Currency [0]': { name: 'Currency [0]', builtinId: 7, font: BODY_FONT, numberFormat: '\"$\"#,##0' },\n Percent: { name: 'Percent', builtinId: 5, font: BODY_FONT, numberFormat: '0%' },\n\n // -------- hyperlinks ----------------------------------------------------\n Hyperlink: {\n name: 'Hyperlink',\n builtinId: 8,\n font: makeFont({ ...BODY_FONT, underline: 'single', color: makeColor({ theme: 10 }) }),\n },\n 'Followed Hyperlink': {\n name: 'Followed Hyperlink',\n builtinId: 9,\n font: makeFont({ ...BODY_FONT, underline: 'single', color: makeColor({ theme: 11 }) }),\n },\n});\n\n/**\n * Register a built-in style with the supplied Stylesheet (idempotent).\n * Returns the cellStyleXfs index. Throws OpenXmlSchemaError when the\n * name is unknown.\n */\nexport function ensureBuiltinStyle(ss: Stylesheet, name: keyof typeof BUILTIN_NAMED_STYLES | string): number {\n const spec = BUILTIN_NAMED_STYLES[name as keyof typeof BUILTIN_NAMED_STYLES];\n if (spec === undefined) {\n throw new OpenXmlSchemaError(`ensureBuiltinStyle: unknown built-in style \"${String(name)}\"`);\n }\n return addNamedStyle(ss, spec);\n}\n","// Cell protection value object. Mirrors openpyxl/openpyxl/styles/protection.py.\n//\n// Protection only matters when the worksheet itself is protected; until\n// then it's metadata that round-trips with the cell's style.\n\nexport interface Protection {\n /** When true (the default), the cell can't be edited if the sheet is locked. */\n readonly locked?: boolean;\n /** When true, the formula bar hides this cell's contents on a protected sheet. */\n readonly hidden?: boolean;\n}\n\nexport function makeProtection(opts: Partial<Protection> = {}): Protection {\n const out: { -readonly [K in keyof Protection]: Protection[K] } = {};\n if (opts.locked !== undefined) out.locked = opts.locked;\n if (opts.hidden !== undefined) out.hidden = opts.hidden;\n return Object.freeze(out);\n}\n\n/** Excel's Stylesheet always contains an entry equal to {locked:true, hidden:false}. */\nexport const DEFAULT_PROTECTION: Protection = makeProtection({ locked: true, hidden: false });\n","// Cell ↔ Stylesheet bridge.\n//\n// A cell's `styleId` is an index into `Workbook.styles.cellXfs`. Each CellXf\n// points at slots in the font / fill / border / numFmt pools. To \"apply\" a Font\n// to a cell we therefore:\n// 1. read the cell's current CellXf (or `defaultCellXf` if it points\n// at a slot that hasn't been allocated yet — common right after\n// `makeCell` since `cellXfs` starts empty)\n// 2. resolve / register the new component in its pool\n// 3. build a new CellXf that carries the new id + the matching\n// `apply*` flag (Excel needs the flag to honour the override over\n// the underlying NamedStyle)\n// 4. dedup that CellXf via `addCellXf` and write the returned index\n// back to `c.styleId`\n//\n// Following the no-classes rule, this module is just a flat list of free\n// functions; the workbook is passed in so callers don't need to thread the\n// stylesheet manually.\n\nimport type { Cell } from '../cell/cell.js';\nimport { OpenXmlSchemaError } from '../utils/exceptions.js';\nimport type { Workbook } from '../workbook/workbook.js';\nimport type { RangeRef } from '../utils/coordinate.js';\nimport { parseRange } from '../worksheet/cell-range.js';\nimport { ensureCell, type Worksheet } from '../worksheet/worksheet.js';\nimport type { Alignment, HorizontalAlignment, VerticalAlignment } from './alignment.js';\nimport { alignmentToCss, makeAlignment } from './alignment.js';\nimport type { Border, SideStyle } from './borders.js';\nimport { borderToCss, DEFAULT_BORDER, makeBorder, makeSide } from './borders.js';\nimport type { Color } from './colors.js';\nimport { makeColor } from './colors.js';\nimport type { Fill } from './fills.js';\nimport { DEFAULT_EMPTY_FILL, fillToCss, makePatternFill } from './fills.js';\nimport type { Font, FontPatch, UnderlineStyle } from './fonts.js';\nimport { DEFAULT_FONT, fontToCss, makeFont } from './fonts.js';\nimport { ensureBuiltinStyle } from './named-styles.js';\nimport { builtinFormatCode } from './numbers.js';\nimport type { Protection } from './protection.js';\nimport { DEFAULT_PROTECTION } from './protection.js';\nimport {\n addBorder,\n addCellXf,\n addFill,\n addFont,\n addNumFmt,\n buildXfPatch,\n type CellStyleSpec,\n type CellXf,\n defaultCellXf,\n type Stylesheet,\n} from './stylesheet.js';\n\n/** Default General number format code (numFmtId 0). */\nconst GENERAL_FORMAT_CODE = 'General';\n\n/** Resolve a cell's current CellXf, falling back to defaults when unset. */\nfunction currentXf(ss: Stylesheet, c: Cell): CellXf {\n return ss.cellXfs[c.styleId] ?? defaultCellXf();\n}\n\n// ---- read accessors --------------------------------------------------------\n\nexport function getCellFont(wb: Workbook, c: Cell): Font {\n const xf = currentXf(wb.styles, c);\n return wb.styles.fonts[xf.fontId] ?? DEFAULT_FONT;\n}\n\nexport function getCellFill(wb: Workbook, c: Cell): Fill {\n const xf = currentXf(wb.styles, c);\n return wb.styles.fills[xf.fillId] ?? DEFAULT_EMPTY_FILL;\n}\n\nexport function getCellBorder(wb: Workbook, c: Cell): Border {\n const xf = currentXf(wb.styles, c);\n return wb.styles.borders[xf.borderId] ?? DEFAULT_BORDER;\n}\n\nexport function getCellAlignment(wb: Workbook, c: Cell): Alignment {\n return currentXf(wb.styles, c).alignment ?? {};\n}\n\nexport function getCellProtection(wb: Workbook, c: Cell): Protection {\n return currentXf(wb.styles, c).protection ?? DEFAULT_PROTECTION;\n}\n\n/**\n * Returns the cell's number-format **code** (e.g. `\"0.00\"`, `\"General\"`).\n * Built-in IDs resolve through `builtinFormatCode`; custom IDs come from the\n * workbook's numFmts map.\n */\nexport function getCellNumberFormat(wb: Workbook, c: Cell): string {\n const id = currentXf(wb.styles, c).numFmtId;\n const builtin = builtinFormatCode(id);\n if (builtin !== undefined) return builtin;\n return wb.styles.numFmts.get(id) ?? GENERAL_FORMAT_CODE;\n}\n\n/**\n * Aggregate `fontToCss` + `fillToCss` + `borderToCss` + `alignmentToCss` for a\n * cell into a single CSS-property record. Resolves the cell's `styleId` against\n * the workbook stylesheet, then merges the four partials. On key collision the\n * priority is alignment > border > fill > font (alignment is most specific,\n * font is the broad default). A fully-default cell (`styleId === 0` with empty\n * pools) returns `{}`.\n */\nexport function cellStyleToCss(wb: Workbook, c: Cell): Record<string, string> {\n // Don't pay the resolve cost when the cell points at the default xf and the\n // stylesheet is still in its initial state.\n if (c.styleId === 0) {\n const xf = wb.styles.cellXfs[0];\n if (!xf || (xf.fontId === 0 && xf.fillId === 0 && xf.borderId === 0 && xf.alignment === undefined)) {\n return {};\n }\n }\n const font = getCellFont(wb, c);\n const fill = getCellFill(wb, c);\n const border = getCellBorder(wb, c);\n const alignment = getCellAlignment(wb, c);\n return {\n ...fontToCss(font),\n ...fillToCss(fill),\n ...borderToCss(border),\n ...alignmentToCss(alignment),\n };\n}\n\n// ---- write accessors -------------------------------------------------------\n\n/**\n * Reserve cellXfs[0] for the implicit default xf when the pool is empty.\n * Excel's `<c>` elements without an `s=` attribute resolve to `cellXfs[0]`, so\n * the first time a caller styles any cell we need to make sure that slot stays\n * the default — otherwise unstyled cells in the same sheet would inherit the\n * freshly added styled xf.\n *\n * Idempotent: calling this on a non-empty pool is a no-op.\n */\nconst reserveDefaultXfSlot = (wb: Workbook): void => {\n if (wb.styles.cellXfs.length === 0) addCellXf(wb.styles, defaultCellXf());\n};\n\n/**\n * Replace one field on the cell's CellXf. Centralises the dedup + styleId\n * update so each `setCell*` is a single dispatch.\n */\nfunction applyXfPatch(wb: Workbook, c: Cell, patch: Partial<CellXf>): void {\n reserveDefaultXfSlot(wb);\n const next: CellXf = { ...currentXf(wb.styles, c), ...patch };\n c.styleId = addCellXf(wb.styles, next);\n}\n\n/**\n * Replace the cell's font outright. `font` has to be complete: anything it\n * omits is omitted from the `<font>` record too, and each viewer then falls\n * back to its own default rather than the workbook's. Reach for {@link\n * patchCellFont} unless you really mean \"this font and nothing inherited\".\n */\nexport function setCellFont(wb: Workbook, c: Cell, font: Font): void {\n const fontId = addFont(wb.styles, font);\n applyXfPatch(wb, c, { fontId, applyFont: true });\n}\n\nexport function setCellFill(wb: Workbook, c: Cell, fill: Fill): void {\n const fillId = addFill(wb.styles, fill);\n applyXfPatch(wb, c, { fillId, applyFill: true });\n}\n\nexport function setCellBorder(wb: Workbook, c: Cell, border: Border): void {\n const borderId = addBorder(wb.styles, border);\n applyXfPatch(wb, c, { borderId, applyBorder: true });\n}\n\nexport function setCellAlignment(wb: Workbook, c: Cell, alignment: Alignment): void {\n applyXfPatch(wb, c, { alignment, applyAlignment: true });\n}\n\nexport function setCellProtection(wb: Workbook, c: Cell, protection: Protection): void {\n applyXfPatch(wb, c, { protection, applyProtection: true });\n}\n\n/**\n * Set the cell's number format by its **code** string. Built-in codes resolve\n * to their canonical id; custom codes are registered via `addNumFmt`.\n */\nexport function setCellNumberFormat(wb: Workbook, c: Cell, formatCode: string): void {\n const numFmtId = addNumFmt(wb.styles, formatCode);\n applyXfPatch(wb, c, { numFmtId, applyNumberFormat: true });\n}\n\n/**\n * Copy the source cell's `styleId` to the target cell. Both cells share the\n * same workbook stylesheet, so the styled appearance carries over without\n * allocating a new xf entry. Pass cells from different workbooks via {@link\n * cloneCellStyle} if you need a deep copy across workbooks.\n */\nexport function copyCellStyle(_wb: Workbook, source: Cell, target: Cell): void {\n target.styleId = source.styleId;\n}\n\n/**\n * Reset a cell back to the default (unstyled) appearance — equivalent to\n * Excel's \"Clear Formatting\" command. After the call, the cell inherits the\n * workbook's default font / fill / border / alignment / protection /\n * numberFormat. The underlying xf pool is **not** shrunk (Excel doesn't bother\n * either; the orphaned xf is harmless).\n */\nexport function clearCellStyle(_wb: Workbook, c: Cell): void {\n c.styleId = 0;\n}\n\n/**\n * Range-level shortcut for {@link clearCellStyle}. Walks every cell actually\n * present in the range and resets its `styleId` to 0; cells that don't exist\n * yet are **not** materialised (no-op for sparse regions, unlike the styled\n * `setRange*` family which has to create cells to make the patch observable).\n */\nexport function clearRangeStyle(wb: Workbook, ws: Worksheet, range: RangeRef): void {\n const { minRow, maxRow, minCol, maxCol } = parseRange(range);\n for (let r = minRow; r <= maxRow; r++) {\n const row = ws.rows.get(r);\n if (!row) continue;\n for (let c = minCol; c <= maxCol; c++) {\n const cell = row.get(c);\n if (cell) clearCellStyle(wb, cell);\n }\n }\n}\n\n/**\n * Deep-copy the source cell's full xf (font / fill / border / alignment /\n * protection / numberFormat) into a possibly-different workbook. Returns the\n * new styleId in the target workbook.\n */\nexport function cloneCellStyle(\n sourceWb: Workbook,\n source: Cell,\n targetWb: Workbook,\n target: Cell,\n): number {\n reserveDefaultXfSlot(targetWb);\n const srcXf = currentXf(sourceWb.styles, source);\n const srcFont = sourceWb.styles.fonts[srcXf.fontId] ?? DEFAULT_FONT;\n const srcFill = sourceWb.styles.fills[srcXf.fillId] ?? DEFAULT_EMPTY_FILL;\n const srcBorder = sourceWb.styles.borders[srcXf.borderId] ?? DEFAULT_BORDER;\n const srcNumFmt = builtinFormatCode(srcXf.numFmtId)\n ?? sourceWb.styles.numFmts.get(srcXf.numFmtId)\n ?? GENERAL_FORMAT_CODE;\n const fontId = addFont(targetWb.styles, srcFont);\n const fillId = addFill(targetWb.styles, srcFill);\n const borderId = addBorder(targetWb.styles, srcBorder);\n const numFmtId = addNumFmt(targetWb.styles, srcNumFmt);\n const next: { -readonly [K in keyof CellXf]?: CellXf[K] } = {\n fontId,\n fillId,\n borderId,\n numFmtId,\n };\n if (srcXf.applyFont) next.applyFont = true;\n if (srcXf.applyFill) next.applyFill = true;\n if (srcXf.applyBorder) next.applyBorder = true;\n if (srcXf.applyNumberFormat) next.applyNumberFormat = true;\n if (srcXf.alignment !== undefined) {\n next.alignment = srcXf.alignment;\n next.applyAlignment = true;\n }\n if (srcXf.protection !== undefined) {\n next.protection = srcXf.protection;\n next.applyProtection = true;\n }\n target.styleId = addCellXf(targetWb.styles, next as CellXf);\n return target.styleId;\n}\n\n/**\n * Register a style and return its `styleId`. `setCell` and `setCellByCoord`\n * take it as their last argument, `appendRow` and `appendRows` take it inside\n * `{ styleIds: [...] }`:\n *\n * ```ts\n * const INT = registerCellStyle(wb, { numberFormat: '#,##0' });\n * setCell(ws, 2, 3, 1234, INT);\n * appendRow(ws, ['de', 71_579], { styleIds: [undefined, INT] });\n * ```\n *\n * Build each distinct look once and let the write carry the formatting,\n * instead of running a styling pass over every cell afterwards.\n *\n * The id names a **complete** style, not a patch: an axis missing from `spec`\n * resolves to slot 0 of that pool, so it renders as the workbook default even\n * when the target cell previously had something there. {@link setCellStyle} is\n * the patch-an-existing-cell counterpart.\n *\n * \"Workbook default\" means slot 0 literally. On a workbook from\n * `createWorkbook` that is the neutral font / no fill / no border. A workbook\n * loaded from another producer may hold anything in slot 0, since nothing in\n * ECMA-376 reserves it, so pass the axis explicitly when the look has to be\n * neutral regardless of what the file arrived with.\n */\nexport function registerCellStyle(wb: Workbook, spec: CellStyleSpec): number {\n reserveDefaultXfSlot(wb);\n return addCellXf(wb.styles, { ...defaultCellXf(), ...buildXfPatch(wb.styles, spec) });\n}\n\n/**\n * Build a single CellXf from a multi-axis style spec, then merge it into every\n * cell in `range`. The xf is registered once per style shape, so a 1000-cell\n * range allocates one xf, which is much faster than looping `setCellStyle` per\n * cell.\n *\n * Each cell keeps the axes `spec` leaves out, which is what separates this from\n * {@link registerCellStyle}: the id that returns is a whole style, this is a\n * patch over whatever each cell already carried.\n */\nexport function setRangeStyle(wb: Workbook, ws: Worksheet, range: RangeRef, spec: CellStyleSpec): void {\n const patch = buildXfPatch(wb.styles, spec);\n if (Object.keys(patch).length === 0) return;\n reserveDefaultXfSlot(wb);\n\n const { minRow, maxRow, minCol, maxCol } = parseRange(range);\n // Pre-register the xf for each existing cell — Excel dedupes by value, so the\n // inner xf-pool ends up the same shape for cells already carrying part of the\n // patch as for blanks.\n for (let r = minRow; r <= maxRow; r++) {\n for (let c = minCol; c <= maxCol; c++) {\n const cell = ensureCell(ws, r, c);\n const next: CellXf = { ...currentXf(wb.styles, cell), ...patch };\n cell.styleId = addCellXf(wb.styles, next);\n }\n }\n}\n\n/**\n * Combined cell-style setter, patching the cell's existing xf. Each axis is\n * independent, so pass any subset and the corresponding `applyXxx` flags get set\n * on the underlying CellXf. Avoids\n * 5+ separate stylesheet round-trips when a caller wants to style a single cell\n * across multiple axes (Excel dedupes the resulting xf record on every call).\n */\nexport function setCellStyle(wb: Workbook, c: Cell, spec: CellStyleSpec): void {\n const patch = buildXfPatch(wb.styles, spec);\n if (Object.keys(patch).length === 0) return;\n applyXfPatch(wb, c, patch as Partial<CellXf>);\n}\n\n// ---- fill presets -------------------------------------------------------\n\n/**\n * Set the cell's background to a solid color. Accepts a hex string\n * (`'FFAAFFAA'`) or a partial `Color` object (`{ theme: 4, tint: 0.4 }`).\n * Equivalent to `setCellFill(wb, c, makePatternFill({ patternType: 'solid',\n * fgColor: makeColor(...) }))`.\n */\nexport function setCellBackgroundColor(wb: Workbook, c: Cell, color: string | Partial<Color>): void {\n const colorObj = typeof color === 'string' ? makeColor({ rgb: color }) : makeColor(color);\n setCellFill(wb, c, makePatternFill({ patternType: 'solid', fgColor: colorObj }));\n}\n\n/** Strip the cell's background fill, returning it to the default. */\nexport function clearCellBackground(wb: Workbook, c: Cell): void {\n setCellFill(wb, c, DEFAULT_EMPTY_FILL);\n}\n\n/**\n * Range-level shortcut for `setCellBackgroundColor`. Each cell in the range\n * gets the same solid pattern fill via `setRangeStyle`, so the fill pool dedups\n * to a single entry across the whole range.\n */\nexport function setRangeBackgroundColor(\n wb: Workbook,\n ws: Worksheet,\n range: RangeRef,\n color: string | Partial<Color>,\n): void {\n const colorObj = typeof color === 'string' ? makeColor({ rgb: color }) : makeColor(color);\n setRangeStyle(wb, ws, range, {\n fill: makePatternFill({ patternType: 'solid', fgColor: colorObj }),\n });\n}\n\n/**\n * Range-level shortcut for `setCellFont`. Replaces the whole Font on every cell\n * in the range; there is no range-level merge, so build the complete font you\n * want rather than passing `makeFont({ bold: true })` and losing the workbook\n * default.\n */\nexport function setRangeFont(\n wb: Workbook,\n ws: Worksheet,\n range: RangeRef,\n font: Font,\n): void {\n setRangeStyle(wb, ws, range, { font });\n}\n\n/**\n * Range-level shortcut for `setCellNumberFormat`. Stamps the same format-code\n * onto every cell in the range; the numFmt pool dedups the code so callers\n * don't pay per-cell pool churn.\n */\nexport function setRangeNumberFormat(\n wb: Workbook,\n ws: Worksheet,\n range: RangeRef,\n formatCode: string,\n): void {\n setRangeStyle(wb, ws, range, { numberFormat: formatCode });\n}\n\n/**\n * Range-level shortcut for `setCellProtection`. Stamps the same Protection\n * (locked / hidden) onto every cell in the range. Pass a full `Protection`\n * value or a partial — partials default missing fields to `false` per Excel's\n * `<protection>` semantics.\n *\n * Common usage: `setRangeProtection(wb, ws, 'B2:B100', { locked: false })` to\n * leave just an input column editable when the sheet is protected.\n */\nexport function setRangeProtection(\n wb: Workbook,\n ws: Worksheet,\n range: RangeRef,\n protection: Protection | Partial<Protection>,\n): void {\n // Funnel partials through the Protection factory so frozen invariant holds.\n const p: Protection = Object.isFrozen(protection)\n ? (protection as Protection)\n : { locked: protection.locked ?? false, hidden: protection.hidden ?? false };\n setRangeStyle(wb, ws, range, { protection: p });\n}\n\n/**\n * Range-level shortcut for `wrapCellText`. Toggles \"Wrap Text\" on every cell in\n * the range while preserving each cell's existing alignment (horizontal /\n * vertical / textRotation / indent are not touched). Empty cells in the range\n * are materialised so the alignment patch is observable on round-trip.\n */\nexport function setRangeWrapText(wb: Workbook, ws: Worksheet, range: RangeRef, on = true): void {\n reserveDefaultXfSlot(wb);\n const { minRow, maxRow, minCol, maxCol } = parseRange(range);\n for (let r = minRow; r <= maxRow; r++) {\n for (let c = minCol; c <= maxCol; c++) {\n const cell = ensureCell(ws, r, c);\n wrapCellText(wb, cell, on);\n }\n }\n}\n\n/**\n * Range-level Alignment setter. Two modes:\n *\n * - `mode: 'merge'` (default) — each cell's existing alignment is\n * preserved; the supplied partial overlays it. Use this when you\n * want to set just `horizontal` or `vertical` without wiping the\n * other axes.\n * - `mode: 'replace'` — each cell's alignment is **wholly replaced**\n * by the supplied value. Indent / textRotation / wrapText that\n * weren't supplied are dropped.\n *\n * Empty cells in the range are materialised so the patch is observable on\n * round-trip.\n */\nexport function setRangeAlignment(\n wb: Workbook,\n ws: Worksheet,\n range: RangeRef,\n alignment: Partial<Alignment>,\n mode: 'merge' | 'replace' = 'merge',\n): void {\n reserveDefaultXfSlot(wb);\n const { minRow, maxRow, minCol, maxCol } = parseRange(range);\n if (mode === 'replace') {\n setRangeStyle(wb, ws, range, { alignment: makeAlignment(alignment) });\n return;\n }\n for (let r = minRow; r <= maxRow; r++) {\n for (let c = minCol; c <= maxCol; c++) {\n const cell = ensureCell(ws, r, c);\n const cur = currentXf(wb.styles, cell).alignment;\n setCellAlignment(wb, cell, mergeAlignment(cur, alignment));\n }\n }\n}\n\n// ---- font presets -------------------------------------------------------\n\n/**\n * Merge `patch` over the cell's current font, so the fields left out keep the\n * value they already had (the workbook default, on an unstyled cell). This is\n * the way to change several font fields at once: `setCellFont(wb, c,\n * makeFont({ bold: true }))` is a legal call that registers a font carrying no\n * name and no size, and Excel, LibreOffice and Sheets each substitute a\n * different one.\n *\n * A field set to `undefined` is removed rather than kept, so\n * `patchCellFont(wb, c, { underline: undefined })` un-underlines a cell while\n * leaving the rest of its font alone. Omitting the key keeps the current value.\n *\n * The single-field setters below are this function with one field filled in.\n */\nexport function patchCellFont(wb: Workbook, c: Cell, patch: FontPatch): void {\n // `makeFont` drops undefined-valued keys, and spreading `patch` over the\n // current font overwrites a field with undefined only when the key is\n // actually present, so \"remove\" and \"leave alone\" stay distinguishable.\n setCellFont(wb, c, makeFont({ ...getCellFont(wb, c), ...patch }));\n}\n\n/** Toggle bold on a cell. Preserves other font fields. */\nexport function setBold(wb: Workbook, c: Cell, on = true): void {\n patchCellFont(wb, c, { bold: on });\n}\n\n/** Toggle italic on a cell. */\nexport function setItalic(wb: Workbook, c: Cell, on = true): void {\n patchCellFont(wb, c, { italic: on });\n}\n\n/** Toggle strike-through on a cell. */\nexport function setStrikethrough(wb: Workbook, c: Cell, on = true): void {\n patchCellFont(wb, c, { strike: on });\n}\n\n/**\n * Set the underline style. Pass `false` to drop underline; pass `'single' |\n * 'double' | 'singleAccounting' | 'doubleAccounting'` to apply that style; pass\n * `true` for the most common single-line.\n */\nexport function setUnderline(\n wb: Workbook,\n c: Cell,\n style: UnderlineStyle | boolean = 'single',\n): void {\n const underline = style === false ? undefined : style === true ? 'single' : style;\n patchCellFont(wb, c, { underline });\n}\n\n/** Set the font size in points (e.g. 14). Preserves other fields. */\nexport function setFontSize(wb: Workbook, c: Cell, size: number): void {\n patchCellFont(wb, c, { size });\n}\n\n/** Set the font family name (e.g. \"Arial\"). Preserves other fields. */\nexport function setFontName(wb: Workbook, c: Cell, name: string): void {\n patchCellFont(wb, c, { name });\n}\n\n/**\n * Set the font color. Accepts a hex string (\"FFAA0033\") or a partial `Color`\n * object (`{ theme: 4, tint: 0.4 }`). Preserves other font fields.\n */\nexport function setFontColor(wb: Workbook, c: Cell, color: string | Partial<Color>): void {\n const colorObj = typeof color === 'string' ? makeColor({ rgb: color }) : makeColor(color);\n patchCellFont(wb, c, { color: colorObj });\n}\n\n// ---- alignment presets --------------------------------------------------\n\nconst mergeAlignment = (current: Alignment | undefined, patch: Partial<Alignment>): Alignment => {\n return makeAlignment({ ...current, ...patch });\n};\n\n/**\n * Center a cell horizontally + vertically. Mirrors Excel's \"Merge & Center\" UI\n * button (without the merge — see {@link mergeCells} for that). Preserves any\n * other alignment fields already present.\n */\nexport function centerCell(wb: Workbook, c: Cell): void {\n const cur = currentXf(wb.styles, c).alignment;\n setCellAlignment(wb, c, mergeAlignment(cur, { horizontal: 'center', vertical: 'center' }));\n}\n\n/** Toggle \"Wrap Text\" on a cell, preserving other alignment fields. */\nexport function wrapCellText(wb: Workbook, c: Cell, wrap = true): void {\n const cur = currentXf(wb.styles, c).alignment;\n setCellAlignment(wb, c, mergeAlignment(cur, { wrapText: wrap }));\n}\n\n/** Set the horizontal alignment in isolation. */\nexport function alignCellHorizontal(wb: Workbook, c: Cell, horizontal: HorizontalAlignment): void {\n const cur = currentXf(wb.styles, c).alignment;\n setCellAlignment(wb, c, mergeAlignment(cur, { horizontal }));\n}\n\n/** Set the vertical alignment in isolation. */\nexport function alignCellVertical(wb: Workbook, c: Cell, vertical: VerticalAlignment): void {\n const cur = currentXf(wb.styles, c).alignment;\n setCellAlignment(wb, c, mergeAlignment(cur, { vertical }));\n}\n\n/**\n * Rotate the cell's text. `degrees` accepts 0..180 (clockwise) or 255 for\n * Excel's \"vertical stacked\" mode. Mirrors the rotate icons in the alignment\n * ribbon.\n */\nexport function rotateCellText(wb: Workbook, c: Cell, degrees: number): void {\n const cur = currentXf(wb.styles, c).alignment;\n setCellAlignment(wb, c, mergeAlignment(cur, { textRotation: degrees }));\n}\n\n/** Set or clear the indent level (0..255). */\nexport function indentCell(wb: Workbook, c: Cell, levels: number): void {\n const cur = currentXf(wb.styles, c).alignment;\n setCellAlignment(wb, c, mergeAlignment(cur, { indent: levels }));\n}\n\n// ---- format presets -----------------------------------------------------\n//\n// Mirror Excel's \"Format Cells → Number → Category\" panel. Each preset builds\n// the exact format-code Excel ships with, then routes through the existing\n// `setCellNumberFormat` so the dedup pool sees the same string every time.\n\n/**\n * Format a cell as currency. Produces one of:\n * - default → `\"$#,##0.00\"` (US dollar, 2 decimals)\n * - `{ symbol: \"€\" }` → `\"€#,##0.00\"`\n * - `{ symbol: \"¥\", decimals: 0 }` → `\"¥#,##0\"`\n * - `{ accounting: true }` → `\"_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \\\"-\\\"??_-;_-@_-\"`\n * (Excel's \"Accounting\" subtype with right-aligned symbol).\n */\nexport function setCellAsCurrency(\n wb: Workbook,\n c: Cell,\n opts: { symbol?: string; decimals?: number; accounting?: boolean } = {},\n): void {\n const symbol = opts.symbol ?? '$';\n const decimals = opts.decimals ?? 2;\n const decTail = decimals > 0 ? `.${'0'.repeat(decimals)}` : '';\n const code = opts.accounting\n ? `_-${symbol}* #,##0${decTail}_-;-${symbol}* #,##0${decTail}_-;_-${symbol}* \"-\"${'?'.repeat(decimals)}_-;_-@_-`\n : `${symbol}#,##0${decTail}`;\n setCellNumberFormat(wb, c, code);\n}\n\n/**\n * Format a cell as a percentage. `decimals` defaults to 0 → `\"0%\"`; `decimals:\n * 2` → `\"0.00%\"`. The cell value is multiplied by 100 by Excel during display.\n */\nexport function setCellAsPercent(wb: Workbook, c: Cell, decimals = 0): void {\n if (!Number.isInteger(decimals) || decimals < 0) {\n throw new OpenXmlSchemaError(`setCellAsPercent: decimals must be a non-negative integer; got ${decimals}`);\n }\n const code = decimals === 0 ? '0%' : `0.${'0'.repeat(decimals)}%`;\n setCellNumberFormat(wb, c, code);\n}\n\n/**\n * Format a cell as a date. `format` defaults to Excel's default\n * locale-independent ISO-style date `\"yyyy-mm-dd\"`. Common alternatives:\n * `\"m/d/yyyy\"`, `\"dd-mmm-yy\"`, `\"yyyy-mm-dd hh:mm:ss\"`.\n */\nexport function setCellAsDate(wb: Workbook, c: Cell, format = 'yyyy-mm-dd'): void {\n setCellNumberFormat(wb, c, format);\n}\n\n/**\n * Format a cell as a thousands-separated number. `decimals` defaults to 0 →\n * `\"#,##0\"`; `decimals: 2` → `\"#,##0.00\"`.\n */\nexport function setCellAsNumber(wb: Workbook, c: Cell, decimals = 0): void {\n if (!Number.isInteger(decimals) || decimals < 0) {\n throw new OpenXmlSchemaError(`setCellAsNumber: decimals must be a non-negative integer; got ${decimals}`);\n }\n const code = decimals === 0 ? '#,##0' : `#,##0.${'0'.repeat(decimals)}`;\n setCellNumberFormat(wb, c, code);\n}\n\n// ---- table-header preset ------------------------------------------------\n\n/**\n * Apply Excel's stock \"table header\" formatting to a range: bold white text on\n * a dark fill, plus a thick bottom border. Override any axis via `opts` — pass\n * `bold: false` to drop the bold, or `fillColor: 'FF305496'` for a different\n * shade. Defaults match Excel's \"Table Style Medium 2\" header row.\n */\nexport function formatAsHeader(\n wb: Workbook,\n ws: Worksheet,\n range: RangeRef,\n opts: {\n fillColor?: string | Partial<Color>;\n fontColor?: string | Partial<Color>;\n bold?: boolean;\n bottomBorder?: SideStyle | false;\n bottomBorderColor?: string | Partial<Color>;\n } = {},\n): void {\n const fillColor = opts.fillColor === undefined ? 'FF305496' : typeof opts.fillColor === 'string' ? makeColor({ rgb: opts.fillColor }) : makeColor(opts.fillColor);\n const fontColor = opts.fontColor === undefined ? 'FFFFFFFF' : typeof opts.fontColor === 'string' ? makeColor({ rgb: opts.fontColor }) : makeColor(opts.fontColor);\n const bold = opts.bold ?? true;\n const borderStyle = opts.bottomBorder ?? 'medium';\n const borderColorObj = opts.bottomBorderColor === undefined ? undefined : typeof opts.bottomBorderColor === 'string' ? makeColor({ rgb: opts.bottomBorderColor }) : makeColor(opts.bottomBorderColor);\n\n const fillColorObj = typeof fillColor === 'string' ? makeColor({ rgb: fillColor }) : fillColor;\n const fontColorObj = typeof fontColor === 'string' ? makeColor({ rgb: fontColor }) : fontColor;\n\n const styleOpts: CellStyleSpec = {\n font: makeFont({ bold, color: fontColorObj }),\n fill: makePatternFill({ patternType: 'solid', fgColor: fillColorObj }),\n };\n if (borderStyle !== false) {\n const side = makeSide({ style: borderStyle, ...(borderColorObj ? { color: borderColorObj } : {}) });\n styleOpts.border = makeBorder({ bottom: side });\n }\n setRangeStyle(wb, ws, range, styleOpts);\n}\n\n// ---- named / built-in style application --------------------------------\n\n/**\n * Apply a built-in Excel style (\"Heading 1\" / \"Total\" / \"Good\" / \"Bad\" /\n * \"Calculation\" / etc.) to a single cell. Registers the built-in on the\n * Stylesheet (idempotent) and points the cell's xf at it via `xfId` while\n * inheriting the matching font/fill/border/ numFmt ids so the cell renders\n * correctly on its own.\n *\n * Throws when `name` isn't in {@link BUILTIN_NAMED_STYLES}; use {@link\n * applyNamedStyle} for user-registered styles.\n */\nexport function applyBuiltinStyle(wb: Workbook, c: Cell, name: string): void {\n const xfId = ensureBuiltinStyle(wb.styles, name);\n applyNamedStyleByXfId(wb, c, xfId);\n}\n\n/**\n * Apply a NamedStyle that's already registered on the workbook (via\n * `addNamedStyle` or `ensureBuiltinStyle`) to a single cell, by name.\n */\nexport function applyNamedStyle(wb: Workbook, c: Cell, name: string): void {\n const entry = wb.styles._namedStyleByName?.get(name);\n if (entry === undefined) {\n throw new OpenXmlSchemaError(`applyNamedStyle: no named style \"${name}\" registered`);\n }\n applyNamedStyleByXfId(wb, c, entry.xfId);\n}\n\nconst applyNamedStyleByXfId = (wb: Workbook, c: Cell, xfId: number): void => {\n const styleXf = wb.styles.cellStyleXfs[xfId];\n if (!styleXf) {\n throw new OpenXmlSchemaError(`applyNamedStyle: cellStyleXfs[${xfId}] missing`);\n }\n // Excel only renders the cellStyleXf's font / fill / border when the cellXf\n // carries the matching `apply*` flag — even a `xfId` reference alone doesn't\n // make Excel inherit the values. So we copy every component the named style\n // touches *and* set the corresponding apply* flag, mirroring what real Excel\n // writes for `s=` referenced cells using a built-in named style.\n const patch: { -readonly [K in keyof CellXf]?: CellXf[K] } = {\n xfId,\n fontId: styleXf.fontId,\n fillId: styleXf.fillId,\n borderId: styleXf.borderId,\n numFmtId: styleXf.numFmtId,\n applyFont: true,\n applyFill: true,\n applyBorder: true,\n applyNumberFormat: true,\n };\n if (styleXf.alignment !== undefined) {\n patch.alignment = styleXf.alignment;\n patch.applyAlignment = true;\n }\n if (styleXf.protection !== undefined) {\n patch.protection = styleXf.protection;\n patch.applyProtection = true;\n }\n applyXfPatch(wb, c, patch as Partial<CellXf>);\n};\n\n// ---- border presets ----------------------------------------------------\n\n/**\n * Apply the same {@link SideStyle} to all four edges of a single cell. Optional\n * color via hex string or `Color` partial. Equivalent to `setCellBorder(wb, c,\n * makeBorder({ left, right, top, bottom: side }))` with all four sides\n * identical.\n */\nexport function setCellBorderAll(\n wb: Workbook,\n c: Cell,\n opts: { style: SideStyle; color?: string | Partial<Color> } = { style: 'thin' },\n): void {\n const colorObj = opts.color === undefined ? undefined : typeof opts.color === 'string' ? makeColor({ rgb: opts.color }) : makeColor(opts.color);\n const side = makeSide({ style: opts.style, ...(colorObj ? { color: colorObj } : {}) });\n setCellBorder(wb, c, makeBorder({ left: side, right: side, top: side, bottom: side }));\n}\n\n/**\n * Draw an outer border around a rectangular range. Cells on the perimeter\n * receive a partial border (only the edges that face outside the range); inner\n * cells are unaffected unless `inner` is provided, in which case every cell in\n * the range receives a border combining its perimeter edges with the `inner`\n * style for the inside edges.\n */\nexport function setRangeBorderBox(\n wb: Workbook,\n ws: Worksheet,\n range: RangeRef,\n opts: { style: SideStyle; color?: string | Partial<Color>; inner?: SideStyle } = { style: 'thin' },\n): void {\n const { minRow, maxRow, minCol, maxCol } = parseRange(range);\n const colorObj = opts.color === undefined ? undefined : typeof opts.color === 'string' ? makeColor({ rgb: opts.color }) : makeColor(opts.color);\n const outer = makeSide({ style: opts.style, ...(colorObj ? { color: colorObj } : {}) });\n const inner =\n opts.inner !== undefined\n ? makeSide({ style: opts.inner, ...(colorObj ? { color: colorObj } : {}) })\n : undefined;\n for (let r = minRow; r <= maxRow; r++) {\n for (let col = minCol; col <= maxCol; col++) {\n const onTop = r === minRow;\n const onBottom = r === maxRow;\n const onLeft = col === minCol;\n const onRight = col === maxCol;\n // Skip cells that wouldn't get any styling (interior cells when no\n // inner).\n if (!inner && !onTop && !onBottom && !onLeft && !onRight) continue;\n const sides: { -readonly [K in keyof Border]?: Border[K] } = {};\n const top = onTop ? outer : inner;\n const bottom = onBottom ? outer : inner;\n const left = onLeft ? outer : inner;\n const right = onRight ? outer : inner;\n if (top !== undefined) sides.top = top;\n if (bottom !== undefined) sides.bottom = bottom;\n if (left !== undefined) sides.left = left;\n if (right !== undefined) sides.right = right;\n const cell = ensureCell(ws, r, col);\n setCellBorder(wb, cell, makeBorder(sides));\n }\n }\n}\n"],"mappings":";;;AASA,MAAM,oBAAoB,MAAc,UAA4B;CAClE,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG,OAAO;CAChF,MAAM,MAAM;CACZ,MAAM,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,KAAK;CACnC,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,KAAK,MAAM,IAAI,KAAK,IAAI;CACnC,OAAO;AACT;;;;;;;AAQA,SAAgB,gBAAgB,OAAwB;CACtD,OAAO,KAAK,UAAU,OAAO,gBAAgB;AAC/C;;;ACVA,MAAa,wBAA4D,OAAO,OAAO;CACrF;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAa,sBA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KAAK,KAAK;CAC9I,MAAM,QAAQ,SAAS;EAAE,OAAO,KAAK;EAAO,GAAI,WAAW,EAAE,OAAO,SAAS,IAAI,CAAC;CAAG,CAAC;CACtF,MAAM,QACJ,KAAK,UAAU,KAAA,IACX,SAAS;EAAE,OAAO,KAAK;EAAO,GAAI,WAAW,EAAE,OAAO,SAAS,IAAI,CAAC;CAAG,CAAC,IACxE,KAAA;CACN,KAAK,IAAI,IAAI,QAAQ,KAAK,QAAQ,KAChC,KAAK,IAAI,MAAM,QAAQ,OAAO,QAAQ,OAAO;EAC3C,MAAM,QAAQ,MAAM;EACpB,MAAM,WAAW,MAAM;EACvB,MAAM,SAAS,QAAQ;EACvB,MAAM,UAAU,QAAQ;EAGxB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC,SAAS;EAC1D,MAAM,QAAuD,CAAC;EAC9D,MAAM,MAAM,QAAQ,QAAQ;EAC5B,MAAM,SAAS,WAAW,QAAQ;EAClC,MAAM,OAAO,SAAS,QAAQ;EAC9B,MAAM,QAAQ,UAAU,QAAQ;EAChC,IAAI,QAAQ,KAAA,GAAW,MAAM,MAAM;EACnC,IAAI,WAAW,KAAA,GAAW,MAAM,SAAS;EACzC,IAAI,SAAS,KAAA,GAAW,MAAM,OAAO;EACrC,IAAI,UAAU,KAAA,GAAW,MAAM,QAAQ;EAEvC,cAAc,IADD,WAAW,IAAI,GAAG,GACV,GAAG,WAAW,KAAK,CAAC;CAC3C;AAEJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coordinate-Bt5Gni2I.mjs","names":[],"sources":["../src/utils/coordinate.ts"],"sourcesContent":["// Worksheet coordinate utilities. Mirrors openpyxl/openpyxl/utils/cell.py.\n//\n// These functions are on the worksheet read/write hot path (millions of calls\n// when streaming a sheet) so the implementations stay branch-light, regex-based\n// only at the entry points, with bounded Map caches for the bidirectional\n// column letter <-> index mapping.\n\nimport { OpenXmlSchemaError } from './exceptions.js';\n\n/** Maximum column index Excel accepts (XFD). */\nexport const MAX_COL = 16384;\n/** Maximum row index Excel accepts. */\nexport const MAX_ROW = 1048576;\n\n// ---- column letter <-> 1-based index ---------------------------------------\n\nconst indexByLetter = new Map<string, number>();\nconst letterByIndex = new Map<number, string>();\n\n/**\n * 1-based column index → spreadsheet column letter (\"A\", \"Z\", \"AA\", \"XFD\").\n * Throws OpenXmlSchemaError when out of range.\n */\nexport function columnLetterFromIndex(n: number): string {\n const cached = letterByIndex.get(n);\n if (cached !== undefined) return cached;\n if (!Number.isInteger(n) || n < 1 || n > MAX_COL) {\n throw new OpenXmlSchemaError(`column index ${n} is out of range [1, ${MAX_COL}]`);\n }\n let m = n;\n let out = '';\n while (m > 0) {\n m -= 1; // shift to 0-based for the modulo\n out = String.fromCharCode(65 + (m % 26)) + out;\n m = Math.floor(m / 26);\n }\n letterByIndex.set(n, out);\n return out;\n}\n\n/**\n * Column letter → 1-based column index. Case-insensitive but at most 3 letters\n * (the spec ceiling). Throws on empty / non-A-Z / over-range.\n */\nexport function columnIndexFromLetter(letter: string): number {\n const cached = indexByLetter.get(letter);\n if (cached !== undefined) return cached;\n if (letter.length === 0 || letter.length > 3) {\n throw new OpenXmlSchemaError(`column letter \"${letter}\" is empty or too long`);\n }\n let n = 0;\n for (let i = 0; i < letter.length; i++) {\n const c = letter.charCodeAt(i);\n let v: number;\n if (c >= 65 && c <= 90)\n v = c - 64; // 'A' = 65\n else if (c >= 97 && c <= 122)\n v = c - 96; // 'a' = 97\n else throw new OpenXmlSchemaError(`column letter \"${letter}\" contains non-letter char`);\n n = n * 26 + v;\n }\n if (n < 1 || n > MAX_COL) {\n throw new OpenXmlSchemaError(`column letter \"${letter}\" expands to out-of-range index ${n}`);\n }\n // Normalise the cache key to upper-case so 'a' / 'A' share a slot.\n const key = letter.toUpperCase();\n indexByLetter.set(key, n);\n if (key !== letter) indexByLetter.set(letter, n);\n return n;\n}\n\n// ---- coordinate parsing ----------------------------------------------------\n\n/** A single-cell coordinate split into its letter and 1-based row. */\nexport interface CellCoordinate {\n column: string;\n row: number;\n}\n\n/** A single-cell coordinate split into 1-based numeric (col, row). */\nexport interface CellCoordinateNumeric {\n col: number;\n row: number;\n}\n\n/** A 1-based rectangular boundary. */\nexport interface CellRangeBoundaries {\n minCol: number;\n minRow: number;\n maxCol: number;\n maxRow: number;\n}\n\n/**\n * What every range-taking helper accepts: an A1 expression (`\"A4:H20\"`,\n * `\"A:A\"`, `\"1:1\"`) or already-computed 1-based bounds. Code that walks rows\n * and columns as integers passes the bounds directly instead of formatting a\n * string for the callee to parse straight back.\n *\n * Two spellings of one parameter, deliberately, rather than a second function\n * per helper: each capability keeps a single canonical path through the API.\n */\nexport type RangeRef = string | CellRangeBoundaries;\n\nconst COORD_RE = /^[$]?([A-Za-z]{1,3})[$]?([1-9][0-9]*)$/;\nconst COL_RANGE_RE = /^[$]?([A-Za-z]{1,3}):[$]?([A-Za-z]{1,3})$/;\nconst ROW_RANGE_RE = /^[$]?([1-9][0-9]*):[$]?([1-9][0-9]*)$/;\nconst SHEET_RANGE_RE = /^(?:'((?:[^']|'')+)'|([^'!]+))!(.+)$/;\n\n/**\n * Parse a single-cell coordinate string (\"A1\", \"$XFD$1048576\") into its column\n * letter (always uppercased) and 1-based row.\n */\nexport function coordinateFromString(coord: string): CellCoordinate {\n const m = COORD_RE.exec(coord);\n if (m === null || m[1] === undefined || m[2] === undefined) {\n throw new OpenXmlSchemaError(`coordinateFromString: invalid coordinate \"${coord}\"`);\n }\n const column = m[1].toUpperCase();\n const row = Number.parseInt(m[2], 10);\n if (row < 1 || row > MAX_ROW) {\n throw new OpenXmlSchemaError(`coordinateFromString: row ${row} out of range`);\n }\n // Validate column upper bound through the cached helper.\n columnIndexFromLetter(column);\n return { column, row };\n}\n\n/**\n * Same as {@link coordinateFromString} but returning the column as its 1-based\n * numeric index. Thin convenience for the worksheet read path.\n */\nexport function coordinateToTuple(coord: string): CellCoordinateNumeric {\n const c = coordinateFromString(coord);\n return { col: columnIndexFromLetter(c.column), row: c.row };\n}\n\n/** `$` placement for a composed A1 reference. */\nexport interface AbsoluteRefOptions {\n /** Prefix the column letter with `$` so it survives a fill-across. */\n absoluteCol?: boolean;\n /** Prefix the row number with `$` so it survives a fill-down. */\n absoluteRow?: boolean;\n}\n\n/**\n * Compose `\"A1\"` from a 1-based (col, row). Set `absoluteCol` / `absoluteRow`\n * to get the `$` forms formula text needs (`\"$B$5\"`, `\"B$5\"`), so callers\n * tracking integer coordinates never have to concatenate a column letter\n * themselves.\n */\nexport function tupleToCoordinate(col: number, row: number, opts: AbsoluteRefOptions = {}): string {\n if (!Number.isInteger(row) || row < 1 || row > MAX_ROW) {\n throw new OpenXmlSchemaError(`tupleToCoordinate: row ${row} out of range`);\n }\n const colMarker = opts.absoluteCol === true ? '$' : '';\n const rowMarker = opts.absoluteRow === true ? '$' : '';\n return `${colMarker}${columnLetterFromIndex(col)}${rowMarker}${row}`;\n}\n\n/**\n * Predicate: true iff `s` is a valid single-cell A1 coordinate (`\"A1\"`,\n * `\"XFD1048576\"`). Strings with `$` absolute markers, surrounding whitespace,\n * ranges (`A1:B2`), or out-of-bound row / column return false. Useful for\n * sanitising user input before passing to {@link coordinateToTuple} or\n * `setCellByCoord`.\n */\nexport function isValidCellRef(s: unknown): s is string {\n if (typeof s !== 'string') return false;\n const m = /^([A-Za-z]{1,3})([1-9][0-9]*)$/.exec(s);\n if (!m) return false;\n const colStr = m[1];\n const rowStr = m[2];\n if (colStr === undefined || rowStr === undefined) return false;\n const col = columnIndexFromLetterUnchecked(colStr);\n if (col < 1 || col > MAX_COL) return false;\n const row = Number.parseInt(rowStr, 10);\n if (!Number.isFinite(row) || row < 1 || row > MAX_ROW) return false;\n return true;\n}\n\n/**\n * Predicate: true iff `s` is a valid A1-style range expression — single cell,\n * two-corner range, whole column (`A:A`), or whole row (`1:1`). `$` markers,\n * whitespace, and out-of-bound bounds fail. Sanity-check before {@link\n * rangeBoundaries} / `parseRange`.\n */\nexport function isValidRangeRef(s: unknown): s is string {\n if (typeof s !== 'string' || s.length === 0) return false;\n if (isValidCellRef(s)) return true;\n const ab = /^([A-Za-z]{1,3})([1-9][0-9]*):([A-Za-z]{1,3})([1-9][0-9]*)$/.exec(s);\n if (ab) {\n const [, c1, r1, c2, r2] = ab;\n if (!c1 || !r1 || !c2 || !r2) return false;\n const col1 = columnIndexFromLetterUnchecked(c1);\n const col2 = columnIndexFromLetterUnchecked(c2);\n if (col1 < 1 || col1 > MAX_COL || col2 < 1 || col2 > MAX_COL) return false;\n const row1 = Number.parseInt(r1, 10);\n const row2 = Number.parseInt(r2, 10);\n return row1 >= 1 && row1 <= MAX_ROW && row2 >= 1 && row2 <= MAX_ROW;\n }\n const cc = /^([A-Za-z]{1,3}):([A-Za-z]{1,3})$/.exec(s);\n if (cc) {\n const [, c1, c2] = cc;\n if (!c1 || !c2) return false;\n const col1 = columnIndexFromLetterUnchecked(c1);\n const col2 = columnIndexFromLetterUnchecked(c2);\n return col1 >= 1 && col1 <= MAX_COL && col2 >= 1 && col2 <= MAX_COL;\n }\n const rr = /^([1-9][0-9]*):([1-9][0-9]*)$/.exec(s);\n if (rr) {\n const [, r1, r2] = rr;\n if (!r1 || !r2) return false;\n const row1 = Number.parseInt(r1, 10);\n const row2 = Number.parseInt(r2, 10);\n return row1 >= 1 && row1 <= MAX_ROW && row2 >= 1 && row2 <= MAX_ROW;\n }\n return false;\n}\n\nconst columnIndexFromLetterUnchecked = (letters: string): number => {\n let n = 0;\n const upper = letters.toUpperCase();\n for (let i = 0; i < upper.length; i++) {\n const ch = upper.charCodeAt(i);\n if (ch < 65 || ch > 90) return -1;\n n = n * 26 + (ch - 64);\n }\n return n;\n};\n\n/**\n * Predicate: true iff `s` is a valid 1..3-char column letter (`\"A\"` through\n * `\"XFD\"`, case-insensitive). Empty / over-long / out-of-bound / non-string\n * fails.\n */\nexport function isValidColumnLetter(s: unknown): s is string {\n if (typeof s !== 'string' || s.length === 0 || s.length > 3) return false;\n if (!/^[A-Za-z]+$/.test(s)) return false;\n const col = columnIndexFromLetterUnchecked(s);\n return col >= 1 && col <= MAX_COL;\n}\n\n/**\n * Predicate: true iff `n` is a valid 1-based row index in `[1, 1048576]`.\n * Non-finite / non-integer / out-of-bound fails.\n */\nexport function isValidRowNumber(n: unknown): n is number {\n return typeof n === 'number' && Number.isInteger(n) && n >= 1 && n <= MAX_ROW;\n}\n\n/**\n * Predicate: true iff `n` is a valid 1-based column index in `[1, 16384]`.\n * Non-finite / non-integer / out-of-bound fails.\n */\nexport function isValidColumnNumber(n: unknown): n is number {\n return typeof n === 'number' && Number.isInteger(n) && n >= 1 && n <= MAX_COL;\n}\n\n/**\n * Parse \"A1:B5\" / \"A:A\" / \"1:1\" / single-cell into 1-based (minCol, minRow,\n * maxCol, maxRow). Whole-column ranges fill rows to [1, MAX_ROW]; whole-row\n * ranges fill cols to [1, MAX_COL].\n */\nexport function rangeBoundaries(range: string): CellRangeBoundaries {\n const trimmed = range.trim();\n if (trimmed.length === 0) throw new OpenXmlSchemaError('rangeBoundaries: empty range');\n\n const colon = trimmed.indexOf(':');\n if (colon < 0) {\n // Single-cell shorthand: \"A1\" → A1:A1.\n const c = coordinateFromString(trimmed);\n const col = columnIndexFromLetter(c.column);\n return { minCol: col, minRow: c.row, maxCol: col, maxRow: c.row };\n }\n\n const left = trimmed.slice(0, colon);\n const right = trimmed.slice(colon + 1);\n\n const colsOnly = COL_RANGE_RE.exec(trimmed);\n if (colsOnly !== null && colsOnly[1] !== undefined && colsOnly[2] !== undefined) {\n const minCol = columnIndexFromLetter(colsOnly[1]);\n const maxCol = columnIndexFromLetter(colsOnly[2]);\n return {\n minCol: Math.min(minCol, maxCol),\n minRow: 1,\n maxCol: Math.max(minCol, maxCol),\n maxRow: MAX_ROW,\n };\n }\n\n const rowsOnly = ROW_RANGE_RE.exec(trimmed);\n if (rowsOnly !== null && rowsOnly[1] !== undefined && rowsOnly[2] !== undefined) {\n const minRow = Number.parseInt(rowsOnly[1], 10);\n const maxRow = Number.parseInt(rowsOnly[2], 10);\n if (minRow < 1 || maxRow < 1 || minRow > MAX_ROW || maxRow > MAX_ROW) {\n throw new OpenXmlSchemaError(`rangeBoundaries: row out of range in \"${trimmed}\"`);\n }\n return {\n minCol: 1,\n minRow: Math.min(minRow, maxRow),\n maxCol: MAX_COL,\n maxRow: Math.max(minRow, maxRow),\n };\n }\n\n const a = coordinateFromString(left);\n const b = coordinateFromString(right);\n const ac = columnIndexFromLetter(a.column);\n const bc = columnIndexFromLetter(b.column);\n return {\n minCol: Math.min(ac, bc),\n minRow: Math.min(a.row, b.row),\n maxCol: Math.max(ac, bc),\n maxRow: Math.max(a.row, b.row),\n };\n}\n\n/**\n * Inverse of {@link rangeBoundaries} for the rectangular case. `opts` forwards\n * to {@link tupleToCoordinate}, so `{ absoluteCol: true, absoluteRow: true }`\n * yields the `\"$A$4:$H$20\"` form a formula or defined name wants.\n */\nexport function boundariesToRangeString(b: CellRangeBoundaries, opts: AbsoluteRefOptions = {}): string {\n const tl = tupleToCoordinate(b.minCol, b.minRow, opts);\n if (b.minCol === b.maxCol && b.minRow === b.maxRow) return tl;\n const br = tupleToCoordinate(b.maxCol, b.maxRow, opts);\n return `${tl}:${br}`;\n}\n\n/**\n * Parse a sheet-qualified range (\"Sheet1!A1:B5\" / \"'Quarter 1'!A1\"). Sheet\n * names with single quotes inside use SQL-style doubling (\"'Bob''s Sheet'!A1\")\n * — we unescape on the way out.\n */\nexport function parseSheetRange(input: string): {\n sheet: string;\n range: string;\n bounds: CellRangeBoundaries;\n} {\n const m = SHEET_RANGE_RE.exec(input);\n if (m === null) throw new OpenXmlSchemaError(`parseSheetRange: missing \"!\" delimiter in \"${input}\"`);\n const quoted = m[1];\n const bare = m[2];\n const range = m[3];\n if (range === undefined) throw new OpenXmlSchemaError(`parseSheetRange: empty range part in \"${input}\"`);\n const sheet = quoted !== undefined ? quoted.replace(/''/g, \"'\") : (bare ?? '');\n return { sheet, range, bounds: rangeBoundaries(range) };\n}\n\nconst BARE_SHEET_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/**\n * Inverse of {@link parseSheetRange}: format a sheet title + range (or\n * single-cell ref) as `Sheet1!A1` or `'Quarter 1'!A1` per Excel's\n * sheet-qualified syntax. Single quotes inside the title are escaped by\n * doubling (`'Bob''s Sheet'`).\n *\n * Quoting rule: sheet titles consisting only of `[A-Za-z_][A-Za-z0-9_]*` are\n * emitted bare; everything else (spaces, digits-leading, hyphens, apostrophes,\n * punctuation…) gets wrapped in single quotes.\n */\nexport function formatSheetQualifiedRef(sheet: string, ref: string): string {\n if (BARE_SHEET_NAME.test(sheet)) return `${sheet}!${ref}`;\n return `'${sheet.replace(/'/g, \"''\")}'!${ref}`;\n}\n"],"mappings":";;;AAUA,MAAa,UAAU;;AAEvB,MAAa,UAAU;AAIvB,MAAM,gCAAgB,IAAI,IAAoB;AAC9C,MAAM,gCAAgB,IAAI,IAAoB;;;;;AAM9C,SAAgB,sBAAsB,GAAmB;CACvD,MAAM,SAAS,cAAc,IAAI,CAAC;CAClC,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,IAAI,CAAC,OAAO,UAAU,CAAC,KAAK,IAAI,KAAK,IAAA,OACnC,MAAM,IAAI,mBAAmB,gBAAgB,EAAE,uBAAuB,QAAQ,EAAE;CAElF,IAAI,IAAI;CACR,IAAI,MAAM;CACV,OAAO,IAAI,GAAG;EACZ,KAAK;EACL,MAAM,OAAO,aAAa,KAAM,IAAI,EAAG,IAAI;EAC3C,IAAI,KAAK,MAAM,IAAI,EAAE;CACvB;CACA,cAAc,IAAI,GAAG,GAAG;CACxB,OAAO;AACT;;;;;AAMA,SAAgB,sBAAsB,QAAwB;CAC5D,MAAM,SAAS,cAAc,IAAI,MAAM;CACvC,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,IAAI,OAAO,WAAW,KAAK,OAAO,SAAS,GACzC,MAAM,IAAI,mBAAmB,kBAAkB,OAAO,uBAAuB;CAE/E,IAAI,I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
{"version":3,"file":"escape-rnWSPpWY.mjs","names":[],"sources":["../src/utils/escape.ts"],"sourcesContent":["// XML 1.0 cell-string escaping. Mirrors openpyxl/openpyxl/utils/escape.py.\n//\n// Excel emits cell strings with control characters and other illegal\n// XML 1.0 codepoints encoded as `_xHHHH_` (uppercase hex). The\n// underscore itself is a literal in normal text but a sequence opener\n// in escape position; an existing `_xHHHH_` in the input is therefore\n// re-escaped to `_x005F_xHHHH_` so it round-trips losslessly.\n\n// Escape every C0 control character (U+0000 through U+001F) plus the\n// surrogate range U+D800–U+DFFF. NUL is invalid in XML 1.0 entirely.\n// This range deliberately covers `\\t` (U+0009), `\\n` (U+000A) and `\\r`\n// (U+000D) even though XML 1.0 considers them legal whitespace — XML\n// parsers normalise CRLF / lone CR to LF on read, so a cell string\n// containing `\\r` would silently lose its CR without the `_x000D_`\n// encoding. openpyxl escapes the same `\\x01-\\x19` range; we add NUL\n// to keep the writer well-formed when callers feed in binary data.\nconst ILLEGAL_RE =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: by design — these are the codepoints we replace\n /[\\x00-\\x1F\\ud800-\\udfff]/g;\nconst ESCAPED_PATTERN_RE = /(_)(x[0-9A-Fa-f]{4}_)/g;\n\nconst toHex4 = (n: number): string => n.toString(16).toUpperCase().padStart(4, '0');\n\n/**\n * Escape a string for safe storage in an OOXML cell. Already-escaped\n * sequences (`_xHHHH_`) are protected by escaping their leading\n * underscore; illegal codepoints are replaced with their `_xHHHH_`\n * representation.\n */\nexport function escapeCellString(s: string): string {\n // Re-escape any existing `_xHHHH_` so it round-trips; the underscore\n // becomes `_x005F_` and the rest of the sequence is left as-is.\n const protectedString = s.replace(ESCAPED_PATTERN_RE, '_x005F_$2');\n return protectedString.replace(ILLEGAL_RE, (ch) => `_x${toHex4(ch.charCodeAt(0))}_`);\n}\n\nconst UNESCAPE_RE = /_x([0-9A-Fa-f]{4})_/g;\n\n/**\n * Inverse of {@link escapeCellString}. Looking from left to right\n * we replace any `_xHHHH_` sequence with the corresponding code unit;\n * the protected `_x005F_` becomes a literal underscore which the\n * subsequent replacements skip safely (replace's regex is non-overlapping).\n */\nexport function unescapeCellString(s: string): string {\n return s.replace(UNESCAPE_RE, (_full, hex: string) => String.fromCharCode(Number.parseInt(hex, 16)));\n}\n\n// ---- XML escape helpers ----------------------------------------------------\n//\n// One canonical implementation for text-node and attribute escaping. The\n// previous codebase carried three near-identical copies (one each in save.ts,\n// xml/serializer.ts, xml/stream-writer.ts); they disagreed about `>`-in-attribute\n// handling and would have drifted further apart over time. Keeping them in a\n// single place also makes future fixes (e.g. surrogate-pair scrubbing) land\n// once rather than three times.\n\n/**\n * Escape a string for safe placement in an XML text node. Replaces the three\n * codepoints that would otherwise terminate the text region or open a markup\n * sequence (`&`, `<`, `>`); `\"` and `'` are not legal markup terminators\n * inside text and stay verbatim.\n */\nexport function escapeXmlText(s: string): string {\n return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n}\n\n/**\n * Escape a string for safe placement inside a `\"`-quoted XML attribute.\n * Handles `&`, `<`, `>` and the `\"` that would otherwise close the value.\n *\n * Note: this deliberately does NOT escape `\\r` / `\\n` / `\\t` to numeric\n * character references. XML 1.0 attribute-value normalisation would\n * collapses them to spaces, but the DOM read path (fast-xml-parser) does not\n * apply that normalisation, so the literal bytes round-trip through\n * `loadWorkbook`. Leaving them literal also matches what Excel itself emits.\n */\nexport function escapeXmlAttr(s: string): string {\n return s\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\n}\n"],"mappings":";AAgBA,MAAM,aAEJ;AACF,MAAM,qBAAqB;AAE3B,MAAM,UAAU,MAAsB,EAAE,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,GAAG,GAAG;;;;;;;AAQlF,SAAgB,iBAAiB,GAAmB;CAIlD,OADwB,EAAE,QAAQ,oBAAoB,WACjC,CAAC,CAAC,QAAQ,aAAa,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC,CAAC,EAAE,EAAE;AACrF;AAEA,MAAM,cAAc;;;;;;;AAQpB,SAAgB,mBAAmB,GAAmB;CACpD,OAAO,EAAE,QAAQ,cAAc,OAAO,QAAgB,OAAO,aAAa,OAAO,SAAS,KAAK,EAAE,CAAC,CAAC;AACrG;;;;;;;AAiBA,SAAgB,cAAc,GAAmB;CAC/C,OAAO,EAAE,QAAQ,MAAM,OAAO,CAAC,CAAC,QAAQ,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAM;AAC5E;;;;;;;;;;;AAYA,SAAgB,cAAc,GAAmB;CAC/C,OAAO,EACJ,QAAQ,MAAM,OAAO,CAAC,CACtB,QAAQ,MAAM,MAAM,CAAC,CACrB,QAAQ,MAAM,MAAM,CAAC,CACrB,QAAQ,MAAM,QAAQ;AAC3B"}
|