@office-open/xlsx 0.6.9 → 0.7.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 +26 -21
- package/dist/index.d.mts +180 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +994 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["localName"],"sources":["../src/file/content-types.ts","../src/file/core-properties.ts","../src/file/media/media.ts","../src/file/shared-strings.ts","../src/file/styles.ts","../src/file/theme.ts","../src/file/workbook.ts","../src/file/worksheet.ts","../src/file/file.ts","../src/file/drawing/drawing.ts","../src/export/packer/next-compiler.ts","../src/export/packer/packer.ts","../src/util/index.ts","../src/parse.ts","../src/patcher.ts"],"sourcesContent":["/**\n * Content Types module for XLSX packages.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\n\nconst XLSX_MAIN = \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\";\nconst XLSX_WORKSHEET = \"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\";\nconst XLSX_STYLES = \"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\";\nconst XLSX_SHARED_STRINGS =\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml\";\nconst XLSX_THEME = \"application/vnd.openxmlformats-officedocument.theme+xml\";\nconst XLSX_CHART = \"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\";\n\ntype EntryType = \"Default\" | \"Override\";\n\ninterface ContentEntry {\n readonly type: EntryType;\n readonly contentType: string;\n readonly key: string;\n}\n\nconst STATIC_ENTRIES: readonly ContentEntry[] = [\n {\n type: \"Default\",\n contentType: \"application/vnd.openxmlformats-package.relationships+xml\",\n key: \"rels\",\n },\n { type: \"Default\", contentType: \"application/xml\", key: \"xml\" },\n { type: \"Override\", contentType: XLSX_MAIN, key: \"/xl/workbook.xml\" },\n {\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-package.core-properties+xml\",\n key: \"/docProps/core.xml\",\n },\n {\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.extended-properties+xml\",\n key: \"/docProps/app.xml\",\n },\n];\n\n// Pre-compiled static XML fragment (module-level constant)\nconst STATIC_XML = STATIC_ENTRIES.map((e) =>\n e.type === \"Default\"\n ? `<Default ContentType=\"${e.contentType}\" Extension=\"${e.key}\"/>`\n : `<Override ContentType=\"${e.contentType}\" PartName=\"${e.key}\"/>`,\n).join(\"\");\n\nexport class ContentTypes extends BaseXmlComponent {\n private readonly dynamicEntries: ContentEntry[] = [];\n\n public constructor() {\n super(\"Types\");\n }\n\n public addWorksheet(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_WORKSHEET,\n key: `/xl/worksheets/sheet${index}.xml`,\n });\n }\n\n public addStyles(): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_STYLES,\n key: \"/xl/styles.xml\",\n });\n }\n\n public addSharedStrings(): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_SHARED_STRINGS,\n key: \"/xl/sharedStrings.xml\",\n });\n }\n\n public addTheme(index: number = 1): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_THEME,\n key: `/xl/theme/theme${index}.xml`,\n });\n }\n\n public addChart(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_CHART,\n key: `/xl/charts/chart${index}.xml`,\n });\n }\n\n public addDrawing(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawing+xml\",\n key: `/xl/drawings/drawing${index}.xml`,\n });\n }\n\n public addImageType(extension: \"png\" | \"jpeg\"): void {\n const contentType = extension === \"png\" ? \"image/png\" : \"image/jpeg\";\n // Avoid duplicates\n if (this.dynamicEntries.some((e) => e.type === \"Default\" && e.key === extension)) return;\n this.dynamicEntries.push({ type: \"Default\", contentType, key: extension });\n }\n\n public override toXml(_context: Context): string {\n const p: string[] = [\n '<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">',\n STATIC_XML,\n ];\n for (const e of this.dynamicEntries) {\n if (e.type === \"Default\") {\n p.push(`<Default ContentType=\"${e.contentType}\" Extension=\"${e.key}\"/>`);\n } else {\n p.push(`<Override ContentType=\"${e.contentType}\" PartName=\"${e.key}\"/>`);\n }\n }\n p.push(\"</Types>\");\n return p.join(\"\");\n }\n}\n","/**\n * Core Properties module for SpreadsheetML documents.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport { buildCorePropertiesXmlString } from \"@office-open/core\";\n\nexport interface CorePropertiesOptions {\n readonly title?: string;\n readonly subject?: string;\n readonly creator?: string;\n readonly keywords?: string;\n readonly description?: string;\n readonly lastModifiedBy?: string;\n readonly revision?: number;\n}\n\nexport class CoreProperties extends BaseXmlComponent {\n private readonly options: CorePropertiesOptions;\n\n public constructor(options: CorePropertiesOptions) {\n super(\"cp:coreProperties\");\n this.options = options;\n }\n\n public override toXml(_context: Context): string {\n return buildCorePropertiesXmlString(this.options);\n }\n}\n","/**\n * Media collection for XLSX files — stores image binary data.\n *\n * @module\n */\n\nexport interface MediaData {\n readonly fileName: string;\n readonly type: string;\n readonly data: Uint8Array;\n readonly width: number;\n readonly height: number;\n}\n\nexport class Media {\n private readonly map = new Map<string, MediaData>();\n\n public addImage(key: string, data: MediaData): void {\n this.map.set(key, data);\n }\n\n public get array(): readonly MediaData[] {\n return [...this.map.values()];\n }\n}\n","/**\n * Shared Strings Table — generates xl/sharedStrings.xml.\n *\n * XLSX stores repeated string values in a central table to reduce file size.\n * Cells reference strings by index into this table.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport { escapeXml } from \"@office-open/xml\";\n\nexport class SharedStrings extends BaseXmlComponent {\n private readonly strings: string[] = [];\n private readonly indexMap = new Map<string, number>();\n\n public constructor() {\n super(\"sst\");\n }\n\n /**\n * Register a string and return its index.\n * Returns existing index if the string is already registered.\n */\n public register(s: string): number {\n const existing = this.indexMap.get(s);\n if (existing !== undefined) return existing;\n\n const idx = this.strings.length;\n this.strings.push(s);\n this.indexMap.set(s, idx);\n return idx;\n }\n\n public get count(): number {\n return this.strings.length;\n }\n\n /**\n * Zero-allocation fast path: directly concatenate XML string.\n * Bypasses the IXmlableObject intermediate tree entirely.\n */\n public override toXml(_context: Context): string {\n const p: string[] = [\n '<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"',\n ` count=\"${this.strings.length}\" uniqueCount=\"${this.indexMap.size}\">`,\n ];\n for (const s of this.strings) {\n p.push(`<si><t>${escapeXml(s)}</t></si>`);\n }\n p.push(\"</sst>\");\n return p.join(\"\");\n }\n}\n","/**\n * Styles component — generates xl/styles.xml.\n *\n * XLSX uses an index-based style system: cells reference style entries\n * via the `s` attribute, which is an index into `cellXfs`.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport { attrs, escapeXml } from \"@office-open/xml\";\n\n// ── Sub-style option interfaces ──\n\nexport interface FontOptions {\n readonly bold?: boolean;\n readonly italic?: boolean;\n readonly underline?: boolean;\n readonly strike?: boolean;\n readonly size?: number;\n readonly color?: string;\n readonly fontName?: string;\n}\n\nexport interface FillOptions {\n readonly type?: \"solid\" | \"pattern\";\n readonly color?: string;\n readonly patternType?: string;\n}\n\nexport interface BorderOptions {\n readonly style?: \"thin\" | \"medium\" | \"thick\" | \"dotted\" | \"dashed\" | \"hair\" | \"none\";\n readonly color?: string;\n}\n\nexport interface BorderSideOptions {\n readonly top?: BorderOptions;\n readonly bottom?: BorderOptions;\n readonly left?: BorderOptions;\n readonly right?: BorderOptions;\n readonly diagonal?: BorderOptions;\n}\n\nexport interface AlignmentOptions {\n readonly horizontal?: \"left\" | \"center\" | \"right\" | \"fill\" | \"justify\";\n readonly vertical?: \"top\" | \"center\" | \"bottom\";\n readonly wrapText?: boolean;\n readonly textRotation?: number;\n readonly indent?: number;\n}\n\nexport interface StyleOptions {\n readonly font?: FontOptions;\n readonly fill?: FillOptions;\n readonly border?: BorderSideOptions;\n readonly numFmt?: string;\n readonly alignment?: AlignmentOptions;\n}\n\n// ── Style key helpers for deduplication ──\n\nfunction fontKey(f: FontOptions): string {\n return `b${f.bold ? 1 : 0}i${f.italic ? 1 : 0}u${f.underline ? 1 : 0}s${f.strike ? 1 : 0}z${f.size ?? 0}c${f.color ?? \"\"}n${f.fontName ?? \"\"}`;\n}\n\nfunction fillKey(f: FillOptions): string {\n return `t${f.type ?? \"\"}c${f.color ?? \"\"}p${f.patternType ?? \"\"}`;\n}\n\nfunction borderKey(b: BorderSideOptions): string {\n const sk = (o?: BorderOptions) => `${o?.style ?? \"\"}_${o?.color ?? \"\"}`;\n return `t${sk(b.top)}b${sk(b.bottom)}l${sk(b.left)}r${sk(b.right)}d${sk(b.diagonal)}`;\n}\n\n// ── Built-in number format IDs ──\n\nconst BUILTIN_NUMFMTS: Record<string, number> = {\n General: 0,\n \"0\": 1,\n \"0.00\": 2,\n \"#,##0\": 3,\n \"#,##0.00\": 4,\n \"0%\": 9,\n \"0.00%\": 10,\n \"0.00E+00\": 11,\n \"mm-dd-yy\": 14,\n \"d-mmm-yy\": 15,\n \"d-mmm\": 16,\n \"mmm-yy\": 17,\n \"h:mm AM/PM\": 18,\n \"h:mm:ss AM/PM\": 19,\n \"h:mm\": 20,\n \"h:mm:ss\": 21,\n \"m/d/yy h:mm\": 22,\n \"#,##0 ;(#,##0)\": 37,\n \"#,##0 ;[Red](#,##0)\": 38,\n \"#,##0.00;(#,##0.00)\": 39,\n \"#,##0.00;[Red](#,##0.00)\": 40,\n \"mm:ss\": 45,\n \"[h]:mm:ss\": 46,\n \"mmss.0\": 47,\n \"##0.0E+0\": 48,\n \"@\": 49,\n};\n\nexport class Styles extends BaseXmlComponent {\n private readonly fonts: FontOptions[] = [\n { size: 11, fontName: \"Calibri\" }, // default font (index 0)\n ];\n private readonly fontKeys = new Map<string, number>();\n\n private readonly fills: FillOptions[] = [\n { patternType: \"none\" }, // default fill (index 0)\n { patternType: \"gray125\" }, // required fill (index 1)\n ];\n private readonly fillKeys = new Map<string, number>();\n\n private readonly borders: BorderSideOptions[] = [\n {}, // default empty border (index 0)\n ];\n private readonly borderKeys = new Map<string, number>();\n\n private readonly customNumFmts = new Map<string, number>();\n private nextCustomNumFmtId = 164; // custom numFmts start at 164\n\n private readonly cellXfs: Array<{\n readonly fontId: number;\n readonly fillId: number;\n readonly borderId: number;\n readonly numFmtId: number;\n readonly alignment?: AlignmentOptions;\n }> = [\n { fontId: 0, fillId: 0, borderId: 0, numFmtId: 0 }, // default xf (index 0)\n ];\n private readonly cellXfKeys = new Map<string, number>();\n\n public constructor() {\n super(\"styleSheet\");\n\n // Pre-register default font/fill/border keys\n this.fontKeys.set(fontKey(this.fonts[0]), 0);\n this.fillKeys.set(fillKey(this.fills[0]), 0);\n this.fillKeys.set(fillKey(this.fills[1]), 1);\n this.borderKeys.set(borderKey(this.borders[0]), 0);\n this.cellXfKeys.set(this.cellXfKey(this.cellXfs[0]), 0);\n }\n\n /**\n * Register a style and return its index (for the cell `s` attribute).\n * Deduplicates across fonts, fills, borders, numFmts, and cellXfs.\n */\n public register(opts: StyleOptions): number {\n const fontId = this.registerFont(opts.font);\n const fillId = this.registerFill(opts.fill);\n const borderId = this.registerBorder(opts.border);\n const numFmtId = this.registerNumFmt(opts.numFmt);\n\n const xf = {\n fontId,\n fillId,\n borderId,\n numFmtId,\n alignment: opts.alignment,\n };\n\n const key = this.cellXfKey(xf);\n const existing = this.cellXfKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.cellXfs.length;\n this.cellXfs.push(xf);\n this.cellXfKeys.set(key, idx);\n return idx;\n }\n\n private registerFont(opts?: FontOptions): number {\n if (!opts) return 0;\n const key = fontKey(opts);\n const existing = this.fontKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.fonts.length;\n this.fonts.push(opts);\n this.fontKeys.set(key, idx);\n return idx;\n }\n\n private registerFill(opts?: FillOptions): number {\n if (!opts) return 0;\n const key = fillKey(opts);\n const existing = this.fillKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.fills.length;\n this.fills.push(opts);\n this.fillKeys.set(key, idx);\n return idx;\n }\n\n private registerBorder(opts?: BorderSideOptions): number {\n if (!opts) return 0;\n const key = borderKey(opts);\n const existing = this.borderKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.borders.length;\n this.borders.push(opts);\n this.borderKeys.set(key, idx);\n return idx;\n }\n\n private registerNumFmt(fmt?: string): number {\n if (!fmt) return 0;\n const builtin = BUILTIN_NUMFMTS[fmt];\n if (builtin !== undefined) return builtin;\n\n const existing = this.customNumFmts.get(fmt);\n if (existing !== undefined) return existing;\n\n const id = this.nextCustomNumFmtId++;\n this.customNumFmts.set(fmt, id);\n return id;\n }\n\n private cellXfKey(xf: {\n readonly fontId: number;\n readonly fillId: number;\n readonly borderId: number;\n readonly numFmtId: number;\n readonly alignment?: AlignmentOptions;\n }): string {\n const a = xf.alignment;\n const ak = a\n ? `h${a.horizontal ?? \"\"}v${a.vertical ?? \"\"}w${a.wrapText ? 1 : 0}r${a.textRotation ?? \"\"}i${a.indent ?? \"\"}`\n : \"\";\n return `${xf.fontId}|${xf.fillId}|${xf.borderId}|${xf.numFmtId}|${ak}`;\n }\n\n // ── XML generation ──\n\n /**\n * Zero-allocation fast path: directly concatenate XML string.\n * Bypasses the IXmlableObject intermediate tree entirely.\n */\n public override toXml(_context: Context): string {\n const p: string[] = [\n '<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">',\n ];\n\n // numFmts\n if (this.customNumFmts.size > 0) {\n p.push(`<numFmts count=\"${this.customNumFmts.size}\">`);\n for (const [fmt, id] of this.customNumFmts) {\n p.push(`<numFmt numFmtId=\"${id}\" formatCode=\"${escapeXml(fmt)}\"/>`);\n }\n p.push(\"</numFmts>\");\n }\n\n // fonts\n p.push(`<fonts count=\"${this.fonts.length}\">`);\n for (const f of this.fonts) {\n p.push(`<font>${this.fontXmlStr(f)}</font>`);\n }\n p.push(\"</fonts>\");\n\n // fills\n p.push(`<fills count=\"${this.fills.length}\">`);\n for (const f of this.fills) {\n const patternAttrs = attrs({ patternType: f.patternType ?? \"solid\" });\n const fgColor = f.color ? `<fgColor rgb=\"FF${f.color}\"/>` : \"\";\n p.push(\n fgColor\n ? `<fill><patternFill${patternAttrs}>${fgColor}</patternFill></fill>`\n : `<fill><patternFill${patternAttrs}/></fill>`,\n );\n }\n p.push(\"</fills>\");\n\n // borders\n p.push(`<borders count=\"${this.borders.length}\">`);\n for (const b of this.borders) {\n p.push(`<border>${this.borderXmlStr(b)}</border>`);\n }\n p.push(\"</borders>\");\n\n // cellStyleXfs\n p.push(\n '<cellStyleXfs count=\"1\"><xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\"/></cellStyleXfs>',\n );\n\n // cellXfs\n p.push(`<cellXfs count=\"${this.cellXfs.length}\">`);\n for (const xf of this.cellXfs) {\n const xAttrs: Record<string, string | number | boolean | undefined> = {\n numFmtId: xf.numFmtId,\n fontId: xf.fontId,\n fillId: xf.fillId,\n borderId: xf.borderId,\n xfId: 0,\n };\n if (xf.alignment) xAttrs.applyAlignment = 1;\n if (xf.fontId > 0) xAttrs.applyFont = 1;\n if (xf.fillId > 0) xAttrs.applyFill = 1;\n if (xf.borderId > 0) xAttrs.applyBorder = 1;\n\n const alignStr = xf.alignment ? this.alignmentXmlStr(xf.alignment) : \"\";\n p.push(alignStr ? `<xf${attrs(xAttrs)}>${alignStr}</xf>` : `<xf${attrs(xAttrs)}/>`);\n }\n p.push(\"</cellXfs>\");\n\n // cellStyles\n p.push('<cellStyles count=\"1\"><cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/></cellStyles>');\n\n // dxfs and tableStyles (required by Excel)\n p.push('<dxfs count=\"0\"/>');\n p.push(\n '<tableStyles count=\"0\" defaultTableStyle=\"TableStyleMedium2\" defaultPivotStyle=\"PivotStyleLight16\"/>',\n );\n p.push(\"<extLst/>\");\n\n p.push(\"</styleSheet>\");\n return p.join(\"\");\n }\n\n private fontXmlStr(f: FontOptions): string {\n const parts: string[] = [];\n if (f.bold) parts.push(\"<b/>\");\n if (f.italic) parts.push(\"<i/>\");\n if (f.underline) parts.push(\"<u/>\");\n if (f.strike) parts.push(\"<strike/>\");\n if (f.size) parts.push(`<sz val=\"${f.size}\"/>`);\n if (f.color) parts.push(`<color rgb=\"FF${f.color}\"/>`);\n if (f.fontName) parts.push(`<name val=\"${escapeXml(f.fontName)}\"/>`);\n return parts.join(\"\");\n }\n\n private borderXmlStr(b: BorderSideOptions): string {\n const parts: string[] = [];\n for (const side of [\"left\", \"right\", \"top\", \"bottom\", \"diagonal\"] as const) {\n const opts = b[side] as BorderOptions | undefined;\n if (opts && opts.style && opts.style !== \"none\") {\n const colorStr = opts.color ? `<color rgb=\"FF${opts.color}\"/>` : \"\";\n parts.push(`<${side} style=\"${opts.style}\">${colorStr}</${side}>`);\n } else {\n parts.push(`<${side}/>`);\n }\n }\n return parts.join(\"\");\n }\n\n private alignmentXmlStr(a: AlignmentOptions): string {\n const aAttrs: Record<string, string | number | boolean | undefined> = {};\n if (a.horizontal) aAttrs.horizontal = a.horizontal;\n if (a.vertical) aAttrs.vertical = a.vertical;\n if (a.wrapText) aAttrs.wrapText = 1;\n if (a.textRotation !== undefined) aAttrs.textRotation = a.textRotation;\n if (a.indent !== undefined) aAttrs.indent = a.indent;\n return `<alignment${attrs(aAttrs)}/>`;\n }\n}\n","/**\n * Default theme for XLSX files — matches Microsoft Office's output structure.\n * Produces xl/theme/theme1.xml that Excel accepts without repair warnings.\n *\n * The theme XML is completely static — identical for every XLSX file.\n * Pre-serialized as a string constant to avoid building the IXmlableObject\n * tree and re-serializing on every compile.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\n\n// Pre-serialized theme XML. Generated once via xml(buildThemeObj()) and inlined.\n// To regenerate: run `pnpm tsx scripts/gen-theme.ts` from packages/xlsx.\nconst THEME_XML =\n '<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office Theme\"><a:themeElements><a:clrScheme name=\"Office\"><a:dk1><a:sysClr val=\"windowText\" lastClr=\"000000\"/></a:dk1><a:lt1><a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1><a:dk2><a:srgbClr val=\"44546A\"/></a:dk2><a:lt2><a:srgbClr val=\"E7E6E6\"/></a:lt2><a:accent1><a:srgbClr val=\"5B9BD5\"/></a:accent1><a:accent2><a:srgbClr val=\"ED7D31\"/></a:accent2><a:accent3><a:srgbClr val=\"A5A5A5\"/></a:accent3><a:accent4><a:srgbClr val=\"FFC000\"/></a:accent4><a:accent5><a:srgbClr val=\"4472C4\"/></a:accent5><a:accent6><a:srgbClr val=\"70AD47\"/></a:accent6><a:hlink><a:srgbClr val=\"0563C1\"/></a:hlink><a:folHlink><a:srgbClr val=\"954F72\"/></a:folHlink></a:clrScheme><a:fontScheme name=\"Office\"><a:majorFont><a:latin typeface=\"Calibri Light\" panose=\"020F0302020204030204\"/><a:ea typeface=\"\"/><a:cs typeface=\"\"/></a:majorFont><a:minorFont><a:latin typeface=\"Calibri\" panose=\"020F0502020204030204\"/><a:ea typeface=\"\"/><a:cs typeface=\"\"/></a:minorFont></a:fontScheme><a:fmtScheme name=\"Office\"><a:fillStyleLst><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"110000\"/><a:satMod val=\"105000\"/><a:tint val=\"67000\"/></a:schemeClr></a:gs><a:gs pos=\"50000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"105000\"/><a:satMod val=\"103000\"/><a:tint val=\"73000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"105000\"/><a:satMod val=\"109000\"/><a:tint val=\"81000\"/></a:schemeClr></a:gs></a:gsLst><a:lin ang=\"5400000\" scaled=\"0\"/></a:gradFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"102000\"/><a:satMod val=\"103000\"/><a:tint val=\"94000\"/></a:schemeClr></a:gs><a:gs pos=\"50000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"100000\"/><a:satMod val=\"110000\"/><a:shade val=\"100000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"99000\"/><a:satMod val=\"120000\"/><a:shade val=\"78000\"/></a:schemeClr></a:gs></a:gsLst><a:lin ang=\"5400000\" scaled=\"0\"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w=\"6350\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"solid\"/><a:miter lim=\"800000\"/></a:ln><a:ln w=\"12700\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"solid\"/><a:miter lim=\"800000\"/></a:ln><a:ln w=\"19050\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"solid\"/><a:miter lim=\"800000\"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad=\"57150\" dist=\"19050\" dir=\"5400000\" algn=\"ctr\" rotWithShape=\"0\"><a:srgbClr val=\"000000\"><a:alpha val=\"63000\"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:solidFill><a:schemeClr val=\"phClr\"><a:tint val=\"95000\"/><a:satMod val=\"170000\"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"102000\"/><a:satMod val=\"150000\"/><a:tint val=\"93000\"/><a:shade val=\"98000\"/></a:schemeClr></a:gs><a:gs pos=\"50000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"103000\"/><a:satMod val=\"130000\"/><a:tint val=\"98000\"/><a:shade val=\"90000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:satMod val=\"120000\"/><a:shade val=\"63000\"/></a:schemeClr></a:gs></a:gsLst><a:lin ang=\"5400000\" scaled=\"0\"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>';\n\nexport class DefaultTheme extends BaseXmlComponent {\n public constructor() {\n super(\"a:theme\");\n }\n\n /** Return pre-cached static theme XML — zero allocation. */\n public override toXml(_context: Context): string {\n return THEME_XML;\n }\n}\n","/**\n * Workbook component — generates xl/workbook.xml.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport { escapeXml } from \"@office-open/xml\";\n\nexport interface SheetDefinition {\n readonly name: string;\n readonly sheetId: number;\n readonly rId: string;\n readonly state?: \"visible\" | \"hidden\" | \"veryHidden\";\n}\n\nexport class WorkbookXml extends BaseXmlComponent {\n private readonly sheets: readonly SheetDefinition[];\n\n public constructor(sheets: readonly SheetDefinition[]) {\n super(\"workbook\");\n this.sheets = sheets;\n }\n\n public override toXml(_context: Context): string {\n const p: string[] = [\n '<workbook xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">',\n '<bookViews><workbookView xWindow=\"0\" yWindow=\"0\" windowWidth=\"28800\" windowHeight=\"12300\"/></bookViews>',\n \"<sheets>\",\n ];\n for (const s of this.sheets) {\n const stateAttr = s.state && s.state !== \"visible\" ? ` state=\"${s.state}\"` : \"\";\n p.push(\n `<sheet name=\"${escapeXml(s.name)}\" sheetId=\"${s.sheetId}\" r:id=\"${s.rId}\"${stateAttr}/>`,\n );\n }\n p.push('</sheets><calcPr calcId=\"191029\"/></workbook>');\n return p.join(\"\");\n }\n}\n","import type { SharedStrings } from \"@file/shared-strings\";\nimport type { Styles, StyleOptions } from \"@file/styles\";\n/**\n * Worksheet component — generates xl/worksheets/sheet{n}.xml.\n *\n * @module\n */\nimport { IgnoreIfEmptyXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport type { ChartSpaceOptions } from \"@office-open/core\";\nimport { attrs, escapeXml, selfCloseElement } from \"@office-open/xml\";\n\nexport interface ColumnOptions {\n readonly min: number;\n readonly max: number;\n readonly width?: number;\n readonly hidden?: boolean;\n readonly customWidth?: boolean;\n}\n\nexport interface RowOptions {\n readonly cells?: readonly CellOptions[];\n readonly height?: number;\n readonly hidden?: boolean;\n readonly rowNumber?: number;\n}\n\nexport interface CellOptions {\n readonly value?: string | number | boolean | Date | null;\n readonly reference?: string;\n /** Direct style index (for pre-resolved styles) */\n readonly styleIndex?: number;\n /** Style options (resolved to index at compile time) */\n readonly style?: StyleOptions;\n /** Formula options. When set, value becomes the cached result. */\n readonly formula?: FormulaOptions;\n}\n\n/** Cell formula type (maps to ST_CellFormulaType). */\nexport const FormulaType = {\n NORMAL: \"normal\",\n ARRAY: \"array\",\n SHARED: \"shared\",\n} as const;\n\nexport type FormulaType = (typeof FormulaType)[keyof typeof FormulaType];\n\n/** Options for a cell formula (maps to CT_CellFormula). */\nexport interface FormulaOptions {\n /** Formula expression, e.g. \"SUM(A1:B1)\" */\n readonly formula: string;\n /** Formula type (default: \"normal\") */\n readonly type?: FormulaType;\n /** Reference range for array/shared formulas, e.g. \"C1:C10\" */\n readonly reference?: string;\n /** Shared formula group index (required for shared formulas) */\n readonly sharedIndex?: number;\n}\n\nexport interface MergeCellOptions {\n readonly from: { readonly row: number; readonly col: number };\n readonly to: { readonly row: number; readonly col: number };\n}\n\nexport interface FreezePaneOptions {\n /** Row split position (1-based, freezes rows above) */\n readonly row?: number;\n /** Column split position (1-based, freezes columns to the left) */\n readonly col?: number;\n}\n\nexport interface WorksheetImageOptions {\n readonly data: Uint8Array;\n readonly type: \"png\" | \"jpeg\" | \"jpg\";\n readonly col: number;\n readonly row: number;\n}\n\nexport interface WorksheetChartOptions extends ChartSpaceOptions {\n /** 1-based column position for the chart */\n readonly col: number;\n /** 1-based row position for the chart */\n readonly row: number;\n}\n\nexport type DataValidationType =\n | \"none\"\n | \"whole\"\n | \"decimal\"\n | \"list\"\n | \"date\"\n | \"time\"\n | \"textLength\"\n | \"custom\";\nexport type DataValidationOperator =\n | \"between\"\n | \"notBetween\"\n | \"equal\"\n | \"notEqual\"\n | \"greaterThan\"\n | \"lessThan\"\n | \"greaterThanOrEqual\"\n | \"lessThanOrEqual\";\n\nexport interface DataValidationOptions {\n /** Cell range, e.g. \"A1:A10\" */\n readonly sqref: string;\n readonly type?: DataValidationType;\n readonly operator?: DataValidationOperator;\n readonly formula1?: string;\n readonly formula2?: string;\n readonly allowBlank?: boolean;\n readonly showErrorMessage?: boolean;\n readonly errorTitle?: string;\n readonly error?: string;\n readonly showInputMessage?: boolean;\n readonly promptTitle?: string;\n readonly prompt?: string;\n}\n\nexport type ConditionalFormatType =\n | \"cellIs\"\n | \"containsText\"\n | \"expression\"\n | \"top10\"\n | \"aboveAverage\";\nexport type ConditionalFormatOperator =\n | \"lessThan\"\n | \"lessThanOrEqual\"\n | \"equal\"\n | \"notEqual\"\n | \"greaterThanOrEqual\"\n | \"greaterThan\"\n | \"between\"\n | \"notBetween\"\n | \"containsText\"\n | \"notContains\"\n | \"beginsWith\"\n | \"endsWith\";\n\nexport interface ConditionalFormatRule {\n readonly type: ConditionalFormatType;\n readonly operator?: ConditionalFormatOperator;\n /** Formula(s) — up to 3 */\n readonly formulas?: readonly string[];\n readonly priority?: number;\n /** Reference to a dxf (differential format) in the styles table */\n readonly dxfId?: number;\n}\n\nexport interface ConditionalFormatOptions {\n /** Cell range, e.g. \"A1:A10\" */\n readonly sqref: string;\n readonly rules: readonly ConditionalFormatRule[];\n}\n\nexport interface WorksheetOptions {\n readonly name?: string;\n readonly children?: readonly RowOptions[];\n readonly columns?: readonly ColumnOptions[];\n readonly mergeCells?: readonly MergeCellOptions[];\n readonly freezePanes?: FreezePaneOptions;\n /** Auto-filter range, e.g. \"A1:D10\" */\n readonly autoFilter?: string;\n readonly images?: readonly WorksheetImageOptions[];\n readonly charts?: readonly WorksheetChartOptions[];\n readonly dataValidations?: readonly DataValidationOptions[];\n readonly conditionalFormats?: readonly ConditionalFormatOptions[];\n}\n\nexport class Worksheet extends IgnoreIfEmptyXmlComponent {\n private readonly rows: readonly RowOptions[];\n private readonly columns: readonly ColumnOptions[];\n private readonly mergeCells: readonly MergeCellOptions[];\n private readonly freezePanes?: FreezePaneOptions;\n private readonly autoFilter?: string;\n private readonly images: readonly WorksheetImageOptions[];\n private readonly chartOptions: readonly WorksheetChartOptions[];\n private readonly dataValidations: readonly DataValidationOptions[];\n private readonly conditionalFormats: readonly ConditionalFormatOptions[];\n\n public constructor(options: WorksheetOptions) {\n super(\"worksheet\");\n this.rows = options.children ?? [];\n this.columns = options.columns ?? [];\n this.mergeCells = options.mergeCells ?? [];\n this.freezePanes = options.freezePanes;\n this.autoFilter = options.autoFilter;\n this.images = options.images ?? [];\n this.chartOptions = options.charts ?? [];\n this.dataValidations = options.dataValidations ?? [];\n this.conditionalFormats = options.conditionalFormats ?? [];\n }\n\n public get imageOptions(): readonly WorksheetImageOptions[] {\n return this.images;\n }\n\n public get charts(): readonly WorksheetChartOptions[] {\n return this.chartOptions;\n }\n\n /**\n * Zero-allocation fast path: directly concatenate XML string.\n * Bypasses the IXmlableObject intermediate tree entirely.\n */\n public override toXml(context: Context): string {\n const fileData = context.fileData as\n | { sharedStrings?: SharedStrings; styles?: Styles }\n | undefined;\n const sharedStrings = fileData?.sharedStrings;\n const styles = fileData?.styles;\n\n const p: string[] = [\n '<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">',\n ];\n\n // Dimension — defines the used range of the sheet\n const maxRow = this.rows.length;\n let maxCol = 0;\n for (const row of this.rows) {\n if (row.cells && row.cells.length > maxCol) maxCol = row.cells.length;\n }\n if (maxRow > 0 && maxCol > 0) {\n const dimRef = `A1:${this.defaultCellRef(maxRow, maxCol)}`;\n p.push(`<dimension ref=\"${dimRef}\"/>`);\n }\n\n // Sheet views\n if (this.freezePanes) {\n const fp = this.freezePanes;\n const ySplit = fp.row ? fp.row : 0;\n const xSplit = fp.col ? fp.col : 0;\n const topRow = fp.row ? fp.row + 1 : 1;\n const leftCol = fp.col ? fp.col + 1 : 1;\n const topLeftCell = this.defaultCellRef(topRow, leftCol);\n const activePane =\n ySplit > 0 && xSplit > 0 ? \"bottomRight\" : ySplit > 0 ? \"bottomLeft\" : \"topRight\";\n p.push(\n '<sheetViews><sheetView tabSelected=\"1\" workbookViewId=\"0\">',\n `<pane ySplit=\"${ySplit}\" xSplit=\"${xSplit}\" topLeftCell=\"${topLeftCell}\" activePane=\"${activePane}\" state=\"frozen\"/>`,\n \"</sheetView></sheetViews>\",\n );\n } else {\n // Default sheetView (required by Excel)\n p.push('<sheetViews><sheetView tabSelected=\"1\" workbookViewId=\"0\"/></sheetViews>');\n }\n\n // Sheet format — default row height\n p.push('<sheetFormatPr defaultRowHeight=\"15\"/>');\n\n // Column definitions\n if (this.columns.length > 0) {\n p.push(\"<cols>\");\n for (const col of this.columns) {\n const colAttrs: Record<string, string | number | boolean | undefined> = {\n min: col.min,\n max: col.max,\n };\n if (col.width !== undefined) {\n colAttrs.width = col.width;\n colAttrs.customWidth = 1;\n }\n if (col.hidden) {\n colAttrs.hidden = 1;\n }\n p.push(selfCloseElement(\"col\", attrs(colAttrs)));\n }\n p.push(\"</cols>\");\n }\n\n // Sheet data (rows + cells) — the hot path\n p.push(\"<sheetData>\");\n for (let i = 0; i < this.rows.length; i++) {\n const rowOpts = this.rows[i];\n const rowNumber = rowOpts.rowNumber ?? i + 1;\n const rowAttrs: Record<string, string | number | boolean | undefined> = { r: rowNumber };\n if (rowOpts.height !== undefined) {\n rowAttrs.ht = rowOpts.height;\n rowAttrs.customHeight = 1;\n }\n if (rowOpts.hidden) {\n rowAttrs.hidden = 1;\n }\n\n if (rowOpts.cells) {\n const rowParts: string[] = [];\n for (let j = 0; j < rowOpts.cells.length; j++) {\n const cell = rowOpts.cells[j];\n const ref = cell.reference ?? this.defaultCellRef(rowNumber, j + 1);\n const cellStr = this.buildCellString(ref, cell, sharedStrings, styles);\n if (cellStr) rowParts.push(cellStr);\n }\n p.push(`<row${attrs(rowAttrs)}>`, ...rowParts, \"</row>\");\n } else {\n p.push(`<row${attrs(rowAttrs)}/>`);\n }\n }\n p.push(\"</sheetData>\");\n\n // Auto filter\n if (this.autoFilter) {\n p.push(selfCloseElement(\"autoFilter\", attrs({ ref: this.autoFilter })));\n }\n\n // Merge cells\n if (this.mergeCells.length > 0) {\n p.push(`<mergeCells count=\"${this.mergeCells.length}\">`);\n for (const mc of this.mergeCells) {\n const fromRef = this.defaultCellRef(mc.from.row, mc.from.col);\n const toRef = this.defaultCellRef(mc.to.row, mc.to.col);\n p.push(selfCloseElement(\"mergeCell\", attrs({ ref: `${fromRef}:${toRef}` })));\n }\n p.push(\"</mergeCells>\");\n }\n\n // Conditional formatting\n if (this.conditionalFormats.length > 0) {\n for (const cf of this.conditionalFormats) {\n p.push(`<conditionalFormatting sqref=\"${cf.sqref}\">`);\n for (let ri = 0; ri < cf.rules.length; ri++) {\n const rule = cf.rules[ri];\n const ruleAttrs: Record<string, string | number | boolean | undefined> = {\n type: rule.type,\n priority: rule.priority ?? ri + 1,\n };\n if (rule.operator) ruleAttrs.operator = rule.operator;\n if (rule.dxfId !== undefined) ruleAttrs.dxfId = rule.dxfId;\n if (rule.formulas && rule.formulas.length > 0) {\n const formulaParts = rule.formulas.map((f) => `<formula>${escapeXml(f)}</formula>`);\n p.push(`<cfRule${attrs(ruleAttrs)}>`, ...formulaParts, \"</cfRule>\");\n } else {\n p.push(selfCloseElement(\"cfRule\", attrs(ruleAttrs)));\n }\n }\n p.push(\"</conditionalFormatting>\");\n }\n }\n\n // Data validations\n if (this.dataValidations.length > 0) {\n p.push(`<dataValidations count=\"${this.dataValidations.length}\">`);\n for (const dv of this.dataValidations) {\n const dvAttrs: Record<string, string | number | boolean | undefined> = { sqref: dv.sqref };\n if (dv.type && dv.type !== \"none\") dvAttrs.type = dv.type;\n if (dv.operator) dvAttrs.operator = dv.operator;\n if (dv.allowBlank) dvAttrs.allowBlank = 1;\n if (dv.showErrorMessage) dvAttrs.showErrorMessage = 1;\n if (dv.showInputMessage) dvAttrs.showInputMessage = 1;\n if (dv.errorTitle) dvAttrs.errorTitle = dv.errorTitle;\n if (dv.error) dvAttrs.error = dv.error;\n if (dv.promptTitle) dvAttrs.promptTitle = dv.promptTitle;\n if (dv.prompt) dvAttrs.prompt = dv.prompt;\n const inner: string[] = [];\n if (dv.formula1 !== undefined) inner.push(`<formula1>${escapeXml(dv.formula1)}</formula1>`);\n if (dv.formula2 !== undefined) inner.push(`<formula2>${escapeXml(dv.formula2)}</formula2>`);\n if (inner.length > 0) {\n p.push(`<dataValidation${attrs(dvAttrs)}>`, ...inner, \"</dataValidation>\");\n } else {\n p.push(selfCloseElement(\"dataValidation\", attrs(dvAttrs)));\n }\n }\n p.push(\"</dataValidations>\");\n }\n\n p.push('<pageMargins left=\"0.75\" right=\"0.75\" top=\"1\" bottom=\"1\" header=\"0.5\" footer=\"0.5\"/>');\n p.push(\"</worksheet>\");\n return p.join(\"\");\n }\n\n /**\n * Build the <f> element string for a cell formula.\n */\n private buildFormulaString(fOpts: FormulaOptions): string {\n const fAttrs: Record<string, string | number | boolean | undefined> = {};\n if (fOpts.type && fOpts.type !== FormulaType.NORMAL) fAttrs.t = fOpts.type;\n if (fOpts.reference) fAttrs.ref = fOpts.reference;\n if (fOpts.sharedIndex !== undefined) fAttrs.si = fOpts.sharedIndex;\n\n const hasContent = fOpts.formula !== undefined && fOpts.formula !== \"\";\n\n if (hasContent) {\n return `<f${attrs(fAttrs)}>${escapeXml(fOpts.formula)}</f>`;\n }\n if (Object.keys(fAttrs).length > 0) {\n return selfCloseElement(\"f\", attrs(fAttrs));\n }\n return \"\";\n }\n\n /**\n * Direct string serialization of a single cell — zero intermediate objects.\n */\n private buildCellString(\n ref: string,\n cell: CellOptions,\n sharedStrings?: SharedStrings,\n styles?: Styles,\n ): string {\n const cellAttrs: Record<string, string | number | boolean | undefined> = { r: ref };\n\n // Resolve style\n if (cell.style !== undefined && styles) {\n cellAttrs.s = styles.register(cell.style);\n } else if (cell.styleIndex !== undefined) {\n cellAttrs.s = cell.styleIndex;\n }\n\n const value = cell.value;\n\n // Formula path — formula takes precedence; value is the cached result.\n if (cell.formula) {\n const fStr = this.buildFormulaString(cell.formula);\n let vStr = \"\";\n if (value === null || value === undefined) {\n return `<c${attrs(cellAttrs)}>${fStr}</c>`;\n }\n if (typeof value === \"number\") {\n vStr = `<v>${value}</v>`;\n } else if (typeof value === \"boolean\") {\n cellAttrs.t = \"b\";\n vStr = `<v>${value ? 1 : 0}</v>`;\n } else if (typeof value === \"string\") {\n cellAttrs.t = \"str\";\n vStr = `<v>${escapeXml(value)}</v>`;\n } else if (value instanceof Date) {\n vStr = `<v>${this.dateToSerialNumber(value)}</v>`;\n }\n if (vStr) {\n return `<c${attrs(cellAttrs)}>${fStr}${vStr}</c>`;\n }\n return `<c${attrs(cellAttrs)}>${fStr}</c>`;\n }\n\n if (value === null || value === undefined) {\n if (cell.styleIndex !== undefined) {\n return selfCloseElement(\"c\", attrs(cellAttrs));\n }\n return \"\";\n }\n\n if (typeof value === \"string\") {\n if (sharedStrings) {\n cellAttrs.t = \"s\";\n const idx = sharedStrings.register(value);\n return `<c${attrs(cellAttrs)}><v>${idx}</v></c>`;\n }\n cellAttrs.t = \"inlineStr\";\n return `<c${attrs(cellAttrs)}><is><t>${escapeXml(value)}</t></is></c>`;\n }\n\n if (typeof value === \"number\") {\n return `<c${attrs(cellAttrs)}><v>${value}</v></c>`;\n }\n\n if (typeof value === \"boolean\") {\n cellAttrs.t = \"b\";\n return `<c${attrs(cellAttrs)}><v>${value ? 1 : 0}</v></c>`;\n }\n\n if (value instanceof Date) {\n const serial = this.dateToSerialNumber(value);\n return `<c${attrs(cellAttrs)}><v>${serial}</v></c>`;\n }\n\n return \"\";\n }\n\n private defaultCellRef(row: number, col: number): string {\n return this.columnToLetter(col) + row;\n }\n\n private columnToLetter(col: number): string {\n let result = \"\";\n let n = col;\n while (n > 0) {\n const remainder = (n - 1) % 26;\n result = String.fromCharCode(65 + remainder) + result;\n n = Math.floor((n - 1) / 26);\n }\n return result;\n }\n\n private dateToSerialNumber(date: Date): number {\n const epoch = new Date(1899, 11, 30);\n const msPerDay = 86400000;\n return (date.getTime() - epoch.getTime()) / msPerDay;\n }\n}\n","import { ContentTypes } from \"@file/content-types\";\nimport { CoreProperties, type CorePropertiesOptions } from \"@file/core-properties\";\nimport { Media } from \"@file/media/media\";\nimport { SharedStrings } from \"@file/shared-strings\";\nimport { Styles } from \"@file/styles\";\nimport { DefaultTheme } from \"@file/theme\";\nimport { WorkbookXml, type SheetDefinition } from \"@file/workbook\";\nimport { Worksheet, type WorksheetOptions } from \"@file/worksheet\";\n/**\n * File class (exported as Workbook) — the top-level container for XLSX documents.\n *\n * @module\n */\nimport { AppProperties, ChartCollection, Relationships } from \"@office-open/core\";\n\nexport interface WorkbookOptions extends CorePropertiesOptions {\n readonly worksheets?: readonly WorksheetOptions[];\n}\n\nexport class File {\n private readonly worksheetOptions: readonly WorksheetOptions[];\n private readonly corePropsOptions: CorePropertiesOptions;\n\n // Lazy components\n private _coreProperties?: CoreProperties;\n private _appProperties?: AppProperties;\n private _contentTypes?: ContentTypes;\n private _styles?: Styles;\n private _theme?: DefaultTheme;\n private _workbookXml?: WorkbookXml;\n private _worksheets?: Worksheet[];\n private _sharedStrings?: SharedStrings;\n private _media?: Media;\n private _fileRels?: Relationships;\n private _workbookRels?: Relationships;\n private _charts?: ChartCollection;\n\n public constructor(options: WorkbookOptions) {\n this.worksheetOptions = options.worksheets ?? [];\n this.corePropsOptions = options;\n }\n\n // ── Lazy getters ──\n\n public get coreProperties(): CoreProperties {\n return (this._coreProperties ??= new CoreProperties(this.corePropsOptions));\n }\n\n public get appProperties(): AppProperties {\n return (this._appProperties ??= new AppProperties());\n }\n\n public get contentTypes(): ContentTypes {\n if (!this._contentTypes) {\n this._contentTypes = new ContentTypes();\n for (let i = 0; i < this.worksheetOptions.length; i++) {\n this._contentTypes.addWorksheet(i + 1);\n }\n this._contentTypes.addStyles();\n this._contentTypes.addSharedStrings();\n this._contentTypes.addTheme();\n }\n return this._contentTypes;\n }\n\n public get styles(): Styles {\n return (this._styles ??= new Styles());\n }\n\n public get theme(): DefaultTheme {\n return (this._theme ??= new DefaultTheme());\n }\n\n public get workbookXml(): WorkbookXml {\n if (!this._workbookXml) {\n const sheets: SheetDefinition[] = this.worksheetOptions.map((ws, i) => ({\n name: ws.name ?? `Sheet${i + 1}`,\n sheetId: i + 1,\n rId: `rId${i + 1}`,\n }));\n this._workbookXml = new WorkbookXml(sheets);\n }\n return this._workbookXml;\n }\n\n public get sharedStrings(): SharedStrings {\n return (this._sharedStrings ??= new SharedStrings());\n }\n\n public get media(): Media {\n return (this._media ??= new Media());\n }\n\n public get charts(): ChartCollection {\n return (this._charts ??= new ChartCollection());\n }\n\n public get worksheets(): readonly Worksheet[] {\n if (!this._worksheets) {\n this._worksheets = this.worksheetOptions.map((ws) => new Worksheet(ws));\n }\n return this._worksheets;\n }\n\n public get fileRelationships(): Relationships {\n if (!this._fileRels) {\n this._fileRels = new Relationships();\n this._fileRels.addRelationship(\n 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\",\n \"xl/workbook.xml\",\n );\n this._fileRels.addRelationship(\n 2,\n \"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\",\n \"docProps/core.xml\",\n );\n this._fileRels.addRelationship(\n 3,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\",\n \"docProps/app.xml\",\n );\n }\n return this._fileRels;\n }\n\n public get workbookRelationships(): Relationships {\n if (!this._workbookRels) {\n this._workbookRels = new Relationships();\n let rid = 1;\n for (let i = 0; i < this.worksheetOptions.length; i++) {\n this._workbookRels.addRelationship(\n rid++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet\",\n `worksheets/sheet${i + 1}.xml`,\n );\n }\n this._workbookRels.addRelationship(\n rid++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\",\n \"styles.xml\",\n );\n this._workbookRels.addRelationship(\n rid++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\",\n \"theme/theme1.xml\",\n );\n this._workbookRels.addRelationship(\n rid++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings\",\n \"sharedStrings.xml\",\n );\n }\n return this._workbookRels;\n }\n}\n","/**\n * XLSX Drawing component — generates xl/drawings/drawing{n}.xml.\n *\n * Uses the spreadsheetDrawing namespace (default, no prefix) for anchoring\n * images and charts to worksheet cells.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\n\nexport interface ImageOptions {\n /** 1-based column */\n readonly col: number;\n /** Column offset in EMU (default 0) */\n readonly colOffset?: number;\n /** 1-based row */\n readonly row: number;\n /** Row offset in EMU (default 0) */\n readonly rowOffset?: number;\n /** Relationship ID for the image */\n readonly rId: string;\n}\n\nexport interface ChartAnchorOptions {\n /** 1-based column */\n readonly col: number;\n /** Column offset in EMU (default 0) */\n readonly colOffset?: number;\n /** 1-based row */\n readonly row: number;\n /** Row offset in EMU (default 0) */\n readonly rowOffset?: number;\n /** Relationship ID for the chart */\n readonly rId: string;\n}\n\nconst XDR_NS = \"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\";\nconst A_NS = \"http://schemas.openxmlformats.org/drawingml/2006/main\";\nconst R_NS = \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\";\nconst C_URI = \"http://schemas.openxmlformats.org/drawingml/2006/chart\";\n\nexport class Drawing extends BaseXmlComponent {\n private readonly images: readonly ImageOptions[];\n private readonly charts: readonly ChartAnchorOptions[];\n\n public constructor(images: readonly ImageOptions[], charts: readonly ChartAnchorOptions[] = []) {\n super(\"wsDr\");\n this.images = images;\n this.charts = charts;\n }\n\n public override toXml(_context: Context): string {\n const p: string[] = [`<wsDr xmlns=\"${XDR_NS}\" xmlns:a=\"${A_NS}\" xmlns:r=\"${R_NS}\">`];\n let id = 1;\n for (const img of this.images) {\n p.push(\n `<twoCellAnchor editAs=\"oneCell\"><from><col>${img.col - 1}</col><colOff>${img.colOffset ?? 0}</colOff><row>${img.row - 1}</row><rowOff>${img.rowOffset ?? 0}</rowOff></from>`,\n `<to><col>${img.col}</col><colOff>0</colOff><row>${img.row}</row><rowOff>0</rowOff></to>`,\n `<pic><nvPicPr><cNvPr id=\"${id}\" name=\"Picture ${id}\"/><cNvPicPr preferRelativeResize=\"1\"/></nvPicPr>`,\n `<blipFill><a:blip r:embed=\"${img.rId}\"/><a:stretch><a:fillRect/></a:stretch></blipFill>`,\n `<spPr><a:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"400000\" cy=\"300000\"/></a:xfrm><a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom></spPr></pic>`,\n `<clientData/></twoCellAnchor>`,\n );\n id++;\n }\n for (const chart of this.charts) {\n p.push(\n `<twoCellAnchor editAs=\"oneCell\"><from><col>${chart.col - 1}</col><colOff>${chart.colOffset ?? 0}</colOff><row>${chart.row - 1}</row><rowOff>${chart.rowOffset ?? 0}</rowOff></from>`,\n `<to><col>${chart.col + 8}</col><colOff>0</colOff><row>${chart.row + 15}</row><rowOff>0</rowOff></to>`,\n `<graphicFrame><nvGraphicFramePr><cNvPr id=\"${id}\" name=\"Chart ${id}\"/><cNvGraphicFramePr><a:graphicFrameLocks noGrp=\"1\"/></cNvGraphicFramePr></nvGraphicFramePr>`,\n `<xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"0\" cy=\"0\"/></xfrm>`,\n `<a:graphic><a:graphicData uri=\"${C_URI}\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"${R_NS}\" r:id=\"${chart.rId}\"/></a:graphicData></a:graphic></graphicFrame>`,\n `<clientData/></twoCellAnchor>`,\n );\n id++;\n }\n p.push(\"</wsDr>\");\n return p.join(\"\");\n }\n}\n","/**\n * XLSX Compiler — compiles a File object into a Zippable structure.\n *\n * @module\n */\nimport { Formatter } from \"@export/formatter\";\nimport { Drawing, type ImageOptions, type ChartAnchorOptions } from \"@file/drawing/drawing\";\nimport type { File } from \"@file/file\";\nimport type { Context } from \"@file/xml-components\";\nimport {\n ChartSpace,\n Relationships,\n compileMapping,\n type XmlifyedFile,\n type Zippable,\n} from \"@office-open/core\";\n\nexport class Compiler {\n private readonly formatter = new Formatter();\n\n public compile(file: File, overrides: readonly XmlifyedFile[] = []): Zippable {\n const context: Context = { fileData: file, stack: [] };\n const f = this.formatter;\n\n const mapping: Record<string, { data: string; path: string }> = {};\n\n const fmt = (component: any) => f.formatToXml(component, context);\n\n // Core properties\n mapping[\"Properties\"] = {\n data: fmt(file.coreProperties),\n path: \"docProps/core.xml\",\n };\n\n // App properties\n mapping[\"AppProperties\"] = {\n data: fmt(file.appProperties),\n path: \"docProps/app.xml\",\n };\n\n // File-level relationships (_rels/.rels)\n mapping[\"FileRelationships\"] = {\n data: fmt(file.fileRelationships),\n path: \"_rels/.rels\",\n };\n\n // Workbook\n mapping[\"Workbook\"] = {\n data: fmt(file.workbookXml),\n path: \"xl/workbook.xml\",\n };\n\n // Workbook relationships\n mapping[\"WorkbookRelationships\"] = {\n data: fmt(file.workbookRelationships),\n path: \"xl/_rels/workbook.xml.rels\",\n };\n\n // Worksheets — formatted BEFORE SharedStrings so strings are registered\n const worksheets = file.worksheets;\n let globalMediaIdx = 0;\n let globalChartIdx = 0;\n\n for (let i = 0; i < worksheets.length; i++) {\n const ws = worksheets[i];\n const imgOpts = ws.imageOptions;\n const chartOpts = ws.charts;\n\n // Worksheet uses toXml() fast path (zero-allocation string concat)\n let sheetXml = fmt(ws);\n\n const hasMedia = imgOpts.length > 0 || chartOpts.length > 0;\n\n if (hasMedia) {\n const drawingImages: ImageOptions[] = [];\n const drawingCharts: ChartAnchorOptions[] = [];\n const drawingRels = new Relationships();\n let rid = 1;\n\n // Process images\n for (const img of imgOpts) {\n const mediaKey = `image_${globalMediaIdx}`;\n const ext = img.type === \"jpeg\" || img.type === \"jpg\" ? \"jpeg\" : \"png\";\n file.media.addImage(mediaKey, {\n fileName: `image${globalMediaIdx + 1}.${ext}`,\n type: ext,\n data: img.data,\n width: 0,\n height: 0,\n });\n\n drawingRels.addRelationship(\n rid,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\",\n `../media/image${globalMediaIdx + 1}.${ext}`,\n );\n\n drawingImages.push({\n col: img.col,\n row: img.row,\n rId: `rId${rid}`,\n });\n rid++;\n globalMediaIdx++;\n }\n\n // Process charts\n for (const chart of chartOpts) {\n const chartKey = `chart_${globalChartIdx}`;\n file.charts.addChart(chartKey, {\n key: chartKey,\n chartSpace: new ChartSpace(chart),\n });\n\n drawingRels.addRelationship(\n rid,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart\",\n `../charts/chart${globalChartIdx + 1}.xml`,\n );\n\n drawingCharts.push({\n col: chart.col,\n row: chart.row,\n rId: `rId${rid}`,\n });\n rid++;\n globalChartIdx++;\n }\n\n // Generate drawing XML\n const drawing = new Drawing(drawingImages, drawingCharts);\n const drawingIdx = i + 1;\n mapping[`Drawing${i}`] = {\n data: fmt(drawing),\n path: `xl/drawings/drawing${drawingIdx}.xml`,\n };\n\n // Drawing relationships\n mapping[`DrawingRels${i}`] = {\n data: fmt(drawingRels),\n path: `xl/drawings/_rels/drawing${drawingIdx}.xml.rels`,\n };\n\n // Insert drawing reference before the closing </worksheet> tag.\n // Use slice instead of replace to avoid O(n) full-string scan.\n const closingTag = \"</worksheet>\";\n sheetXml =\n sheetXml.slice(0, -closingTag.length) + `<drawing r:id=\"rId${rid}\"/>` + closingTag;\n\n // Worksheet needs its own rels for drawing reference\n const wsRels = new Relationships();\n wsRels.addRelationship(\n rid,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing\",\n `../drawings/drawing${drawingIdx}.xml`,\n );\n mapping[`WorksheetRels${i}`] = {\n data: fmt(wsRels),\n path: `xl/worksheets/_rels/sheet${i + 1}.xml.rels`,\n };\n\n file.contentTypes.addDrawing(drawingIdx);\n }\n\n mapping[`Worksheet${i}`] = {\n data: sheetXml,\n path: `xl/worksheets/sheet${i + 1}.xml`,\n };\n }\n\n // Shared Strings — AFTER worksheets so all strings are collected\n const sharedStrings = file.sharedStrings;\n if (sharedStrings.count > 0) {\n mapping[\"SharedStrings\"] = {\n data: fmt(sharedStrings),\n path: \"xl/sharedStrings.xml\",\n };\n }\n\n // Styles\n mapping[\"Styles\"] = {\n data: fmt(file.styles),\n path: \"xl/styles.xml\",\n };\n\n // Theme\n mapping[\"Theme\"] = {\n data: fmt(file.theme),\n path: \"xl/theme/theme1.xml\",\n };\n\n // Charts — AFTER worksheets so charts are registered\n for (let i = 0; i < file.charts.array.length; i++) {\n const chartData = file.charts.array[i];\n mapping[`Chart${i}`] = {\n data: fmt(chartData.chartSpace),\n path: `xl/charts/chart${i + 1}.xml`,\n };\n file.contentTypes.addChart(i + 1);\n }\n\n // Register image content types\n const imageExts = new Set<string>();\n for (const img of file.media.array) {\n const ext = img.fileName.endsWith(\".png\") ? \"png\" : \"jpeg\";\n if (!imageExts.has(ext)) {\n imageExts.add(ext);\n file.contentTypes.addImageType(ext as \"png\" | \"jpeg\");\n }\n }\n\n // Content Types — must be last\n mapping[\"ContentTypes\"] = {\n data: fmt(file.contentTypes),\n path: \"[Content_Types].xml\",\n };\n\n // Convert mapping to Zippable\n const mediaFiles: Array<{ data: Uint8Array; path: string }> = [];\n for (const img of file.media.array) {\n mediaFiles.push({ data: img.data, path: `xl/media/${img.fileName}` });\n }\n\n return compileMapping(mapping, overrides, mediaFiles);\n }\n}\n","import type { File } from \"@file/file\";\n/**\n * Packer module — export API for XLSX files.\n *\n * @module\n */\nimport { createPacker, OoxmlMimeType } from \"@office-open/core\";\n\nimport { Compiler } from \"./next-compiler\";\n\nconst compiler = new Compiler();\n\nexport const Packer = createPacker<File>({\n compile: (file, overrides) => compiler.compile(file, overrides),\n mimeType: OoxmlMimeType.XLSX,\n});\n","/**\n * Convert a 1-based column number to Excel column letter(s).\n * 1 → \"A\", 26 → \"Z\", 27 → \"AA\", 28 → \"AB\"\n */\nexport function columnToLetter(col: number): string {\n let result = \"\";\n let n = col;\n while (n > 0) {\n const remainder = (n - 1) % 26;\n result = String.fromCharCode(65 + remainder) + result;\n n = Math.floor((n - 1) / 26);\n }\n return result;\n}\n\n/**\n * Convert Excel column letter(s) to a 1-based column number.\n * \"A\" → 1, \"Z\" → 26, \"AA\" → 27\n */\nexport function letterToColumn(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n result = result * 26 + (s.charCodeAt(i) - 64);\n }\n return result;\n}\n\n/**\n * Convert a JavaScript Date to an Excel serial number.\n * Excel epoch: January 1, 1900 = 1 (with the 1900 leap year bug).\n */\nexport function dateToSerialNumber(date: Date): number {\n // Excel treats 1900 as a leap year (bug inherited from Lotus 1-2-3).\n // The epoch is effectively December 30, 1899 = 0.\n const epoch = new Date(1899, 11, 30);\n const msPerDay = 86400000;\n const diff = date.getTime() - epoch.getTime();\n return diff / msPerDay;\n}\n","/**\n * XLSX parsing — parse .xlsx files into structured data.\n *\n * @module\n */\nimport { parseArchive, parseCorePropsElement } from \"@office-open/core\";\nimport type { ParsedArchive } from \"@office-open/core\";\nimport type { Element } from \"@office-open/xml\";\nimport { attr, attrNum, findChild, textOf } from \"@office-open/xml\";\nimport { toUint8Array } from \"undio\";\nimport type { DataType } from \"undio\";\n\nimport type { WorkbookOptions } from \"./file/file\";\nimport type {\n WorksheetOptions,\n RowOptions,\n CellOptions,\n ColumnOptions,\n MergeCellOptions,\n} from \"./file/worksheet\";\nimport { letterToColumn } from \"./util\";\n\nexport { parseArchive };\n\n// ── Low-level parse result ──\n\nexport interface XlsxPartRefs {\n worksheets: string[];\n charts: string[];\n media: string[];\n drawings: string[];\n}\n\nexport interface XlsxDocument {\n doc: ParsedArchive;\n /** xl/workbook.xml root element */\n workbook?: Element;\n /** Worksheet paths (xl/worksheets/sheet{n}.xml) */\n worksheets: string[];\n /** xl/styles.xml root element */\n styles?: Element;\n /** xl/sharedStrings.xml root element */\n sharedStrings?: Element;\n partRefs: XlsxPartRefs;\n /** docProps/core.xml path */\n coreProps?: string;\n /** docProps/app.xml path */\n appProps?: string;\n}\n\nfunction sortByNumber(paths: string[]): string[] {\n return paths.sort((a, b) => {\n const numA = parseInt(a.match(/(\\d+)/)?.[1] ?? \"0\", 10);\n const numB = parseInt(b.match(/(\\d+)/)?.[1] ?? \"0\", 10);\n return numA - numB;\n });\n}\n\n/**\n * Parse raw .xlsx data into a low-level XlsxDocument.\n */\nexport function parseXlsx(data: DataType): XlsxDocument {\n const uint8 = toUint8Array(data);\n const doc = parseArchive(uint8);\n\n const workbook = doc.get(\"xl/workbook.xml\");\n const styles = doc.get(\"xl/styles.xml\");\n const sharedStrings = doc.get(\"xl/sharedStrings.xml\");\n\n // Resolve worksheet paths from workbook rels\n const worksheets: string[] = [];\n const charts: string[] = [];\n const drawings: string[] = [];\n const media: string[] = [];\n\n const wbRels = doc.get(\"xl/_rels/workbook.xml.rels\");\n if (wbRels) {\n for (const child of wbRels.elements ?? []) {\n if (child.name !== \"Relationship\") continue;\n const type = attr(child, \"Type\") ?? \"\";\n const target = attr(child, \"Target\") ?? \"\";\n if (!target) continue;\n\n if (type.includes(\"/worksheet\")) {\n worksheets.push(target.startsWith(\"/\") ? target.slice(1) : `xl/${target}`);\n }\n }\n }\n sortByNumber(worksheets);\n\n // Scan for drawings, charts, media\n drawings.push(...doc.keys(\"xl/drawings/\").filter((k) => k.endsWith(\".xml\")));\n charts.push(...doc.keys(\"xl/charts/\").filter((k) => k.endsWith(\".xml\")));\n media.push(...doc.keys(\"xl/media/\"));\n sortByNumber(drawings);\n sortByNumber(charts);\n\n // Root rels → core/app props\n let coreProps: string | undefined;\n let appProps: string | undefined;\n const rootRels = doc.get(\"_rels/.rels\");\n if (rootRels) {\n for (const child of rootRels.elements ?? []) {\n if (child.name !== \"Relationship\") continue;\n const type = attr(child, \"Type\") ?? \"\";\n const target = attr(child, \"Target\") ?? \"\";\n if (type.includes(\"/core-properties\")) coreProps = target;\n else if (type.includes(\"/extended-properties\")) appProps = target;\n }\n }\n\n return {\n doc,\n workbook,\n worksheets,\n styles,\n sharedStrings,\n partRefs: { worksheets, charts, media, drawings },\n coreProps,\n appProps,\n };\n}\n\n// ── Shared strings helper ──\n\nfunction parseSharedStrings(el: Element | undefined): string[] {\n if (!el) return [];\n const strings: string[] = [];\n for (const si of el.elements ?? []) {\n if (si.name !== \"si\") continue;\n // Handle both <si><t>text</t></si> and <si><r><t>text</t></r>...</si>\n const t = findChild(si, \"t\");\n if (t) {\n strings.push(textOf(t) ?? \"\");\n } else {\n // Rich text: concatenate all <r><t> segments\n const parts: string[] = [];\n for (const r of si.elements ?? []) {\n if (r.name !== \"r\") continue;\n const rt = findChild(r, \"t\");\n if (rt) parts.push(textOf(rt) ?? \"\");\n }\n strings.push(parts.join(\"\"));\n }\n }\n return strings;\n}\n\n// ── Cell reference helpers ──\n\nfunction colFromRef(ref: string): number {\n const match = ref.match(/^([A-Z]+)/);\n return match ? letterToColumn(match[1]) : 1;\n}\n\nfunction rowFromRef(ref: string): number {\n const match = ref.match(/(\\d+)$/);\n return match ? parseInt(match[1], 10) : 1;\n}\n\n// ── Worksheet parsing ──\n\nfunction parseWorksheetElement(wsEl: Element, strings: string[]): WorksheetOptions {\n const opts: Record<string, unknown> = {};\n\n // Sheet name from the parent workbook's sheet element (not available here)\n // Caller should set it\n\n // Columns\n // Elements might be prefixed or unprefixed depending on how the XML parser handles default namespaces.\n const colsEl = findChild(wsEl, \"cols\") ?? findChildByLocalName(wsEl, \"cols\");\n if (colsEl) {\n const columns: ColumnOptions[] = [];\n for (const col of colsEl.elements ?? []) {\n if (localName(col) !== \"col\") continue;\n const min = attrNum(col, \"min\");\n const max = attrNum(col, \"max\");\n if (min === undefined || max === undefined) continue;\n const colOpts: Record<string, unknown> = { min, max };\n const width = attrNum(col, \"width\");\n if (width !== undefined) colOpts.width = width;\n if (attr(col, \"hidden\") === \"1\") colOpts.hidden = true;\n columns.push(colOpts as unknown as ColumnOptions);\n }\n if (columns.length > 0) opts.columns = columns;\n }\n\n // Freeze panes\n const sheetViews = findChildByLocalName(wsEl, \"sheetViews\");\n if (sheetViews) {\n const sheetView = findChildByLocalName(sheetViews, \"sheetView\");\n if (sheetView) {\n const pane = findChildByLocalName(sheetView, \"pane\");\n if (pane) {\n const state = attr(pane, \"state\");\n if (state === \"frozen\") {\n const freezePanes: Record<string, unknown> = {};\n const ySplit = attrNum(pane, \"ySplit\");\n const xSplit = attrNum(pane, \"xSplit\");\n if (ySplit && ySplit > 0) freezePanes.row = ySplit;\n if (xSplit && xSplit > 0) freezePanes.col = xSplit;\n if (Object.keys(freezePanes).length > 0) opts.freezePanes = freezePanes;\n }\n }\n }\n }\n\n // Sheet data (rows)\n const sheetData = findChildByLocalName(wsEl, \"sheetData\");\n const rows: RowOptions[] = [];\n if (sheetData) {\n for (const rowEl of sheetData.elements ?? []) {\n if (localName(rowEl) !== \"row\") continue;\n const rowNumber = attrNum(rowEl, \"r\");\n const rowOpts: Record<string, unknown> = {};\n if (rowNumber !== undefined) rowOpts.rowNumber = rowNumber;\n\n const ht = attrNum(rowEl, \"ht\");\n if (ht !== undefined) rowOpts.height = ht;\n if (attr(rowEl, \"hidden\") === \"1\") rowOpts.hidden = true;\n\n const cells: CellOptions[] = [];\n for (const cellEl of rowEl.elements ?? []) {\n if (localName(cellEl) !== \"c\") continue;\n const ref = attr(cellEl, \"r\");\n const type = attr(cellEl, \"t\");\n const cellOpts: Record<string, unknown> = {};\n if (ref) cellOpts.reference = ref;\n\n const styleIdx = attrNum(cellEl, \"s\");\n if (styleIdx !== undefined) cellOpts.styleIndex = styleIdx;\n\n // Cell value\n const vEl = findChildByLocalName(cellEl, \"v\");\n const isEl = findChildByLocalName(cellEl, \"is\");\n\n if (type === \"s\" && vEl) {\n // Shared string\n const idx = parseInt(textOf(vEl) ?? \"\", 10);\n cellOpts.value = strings[idx] ?? \"\";\n } else if (type === \"b\" && vEl) {\n cellOpts.value = textOf(vEl) === \"1\";\n } else if (type === \"inlineStr\" && isEl) {\n const t = findChildByLocalName(isEl, \"t\");\n cellOpts.value = textOf(t) ?? \"\";\n } else if (vEl) {\n const raw = textOf(vEl) ?? \"\";\n const num = Number(raw);\n cellOpts.value = isNaN(num) ? raw : num;\n }\n\n cells.push(cellOpts as CellOptions);\n }\n\n rowOpts.cells = cells;\n rows.push(rowOpts as RowOptions);\n }\n }\n opts.children = rows;\n\n // Merge cells\n const mergeCellsEl = findChildByLocalName(wsEl, \"mergeCells\");\n if (mergeCellsEl) {\n const mergeCells: MergeCellOptions[] = [];\n for (const mc of mergeCellsEl.elements ?? []) {\n if (localName(mc) !== \"mergeCell\") continue;\n const ref = attr(mc, \"ref\");\n if (!ref) continue;\n const parts = ref.split(\":\");\n if (parts.length === 2) {\n mergeCells.push({\n from: { row: rowFromRef(parts[0]), col: colFromRef(parts[0]) },\n to: { row: rowFromRef(parts[1]), col: colFromRef(parts[1]) },\n });\n }\n }\n if (mergeCells.length > 0) opts.mergeCells = mergeCells;\n }\n\n // Auto filter\n const autoFilterEl = findChildByLocalName(wsEl, \"autoFilter\");\n if (autoFilterEl) {\n const ref = attr(autoFilterEl, \"ref\");\n if (ref) opts.autoFilter = ref;\n }\n\n return opts as WorksheetOptions;\n}\n\n// ── Helpers ──\n\nfunction localName(el: Element): string {\n const name = el.name ?? \"\";\n const colonIdx = name.indexOf(\":\");\n return colonIdx >= 0 ? name.slice(colonIdx + 1) : name;\n}\n\nfunction findChildByLocalName(parent: Element, name: string): Element | undefined {\n return (parent.elements ?? []).find((el) => localName(el) === name);\n}\n\n/**\n * Parse a .xlsx file and convert it into WorkbookOptions.\n *\n * The returned options can be passed to `new Workbook(parsed)`.\n */\nexport function parseWorkbook(data: DataType): WorkbookOptions {\n const xlsx = parseXlsx(data);\n\n const opts: Record<string, unknown> = {};\n\n // Core properties\n if (xlsx.coreProps) {\n const corePropsEl = xlsx.doc.get(xlsx.coreProps);\n if (corePropsEl) {\n const cp = parseCorePropsElement(corePropsEl);\n if (cp.title) opts.title = cp.title;\n if (cp.subject) opts.subject = cp.subject;\n if (cp.creator) opts.creator = cp.creator;\n if (cp.keywords) opts.keywords = cp.keywords;\n if (cp.description) opts.description = cp.description;\n if (cp.lastModifiedBy) opts.lastModifiedBy = cp.lastModifiedBy;\n if (cp.revision) opts.revision = parseInt(cp.revision, 10);\n }\n }\n\n // Shared strings\n const strings = parseSharedStrings(xlsx.sharedStrings);\n\n // Sheet names from workbook\n const sheetNames: string[] = [];\n if (xlsx.workbook) {\n const sheetsEl = findChildByLocalName(xlsx.workbook, \"sheets\");\n if (sheetsEl) {\n for (const s of sheetsEl.elements ?? []) {\n if (localName(s) !== \"sheet\") continue;\n sheetNames.push(attr(s, \"name\") ?? \"\");\n }\n }\n }\n\n // Parse worksheets\n const worksheets: WorksheetOptions[] = [];\n for (let i = 0; i < xlsx.worksheets.length; i++) {\n const wsPath = xlsx.worksheets[i];\n const wsEl = xlsx.doc.get(wsPath);\n if (!wsEl) continue;\n\n const wsOpts = parseWorksheetElement(wsEl, strings) as Record<string, unknown>;\n if (sheetNames[i]) wsOpts.name = sheetNames[i];\n worksheets.push(wsOpts as WorksheetOptions);\n }\n\n opts.worksheets = worksheets;\n return opts as WorkbookOptions;\n}\n","/**\n * XLSX patching — replace placeholders in existing .xlsx files.\n *\n * Unlike DOCX/PPTX (paragraph-based), XLSX patching targets cell values:\n * - Replaces placeholders in the shared strings table (most common)\n * - Replaces placeholders in inline strings within worksheet cells\n *\n * @module\n */\nimport { OoxmlMimeType, unzipSync, zipAndConvert, strFromU8, toJson } from \"@office-open/core\";\nimport type { OutputByType, OutputType } from \"@office-open/core\";\nimport { js2xml } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { toUint8Array } from \"undio\";\n\n/** Reusable TextEncoder (stateless, safe to share). */\nconst encoder = new TextEncoder();\n\nexport type InputDataType = Buffer | string | number[] | Uint8Array | ArrayBuffer | Blob;\n\nexport type PatchDocumentOutputType = OutputType;\n\nexport const PatchType = {\n CELL: \"cell\",\n} as const;\n\nexport interface CellPatch {\n /** Replacement value (string, number, boolean, or Date) */\n readonly value: string | number | boolean | Date;\n}\n\nexport type IPatch = CellPatch;\n\nexport interface PatchWorkbookOptions<T extends PatchDocumentOutputType = PatchDocumentOutputType> {\n readonly outputType: T;\n readonly data: InputDataType;\n readonly patches: Readonly<Record<string, IPatch>>;\n readonly placeholderDelimiters?: Readonly<{\n readonly start: string;\n readonly end: string;\n }>;\n}\n\n/**\n * Patch an existing .xlsx workbook by replacing placeholder text in cells.\n *\n * Placeholders are matched in shared strings and inline strings.\n * For string replacements, the shared string value is updated in-place.\n * For non-string replacements, the cell type and value are updated.\n */\nexport const patchWorkbook = async <T extends PatchDocumentOutputType = PatchDocumentOutputType>({\n outputType,\n data,\n patches,\n placeholderDelimiters = { start: \"{{\", end: \"}}\" } as const,\n}: PatchWorkbookOptions<T>): Promise<OutputByType[T]> => {\n const zipContent = unzipSync(toUint8Array(data));\n\n const xmlMap = new Map<string, Element>();\n const binaryMap = new Map<string, Uint8Array>();\n\n // Separate XML files from binary files\n for (const [key, value] of Object.entries(zipContent)) {\n if (key.endsWith(\".xml\") || key.endsWith(\".rels\")) {\n xmlMap.set(key, toJson(strFromU8(value)));\n } else {\n binaryMap.set(key, value);\n }\n }\n\n const { start, end } = placeholderDelimiters;\n\n // Build placeholder → patch map\n const patchMap = new Map<string, IPatch>();\n for (const [key, patch] of Object.entries(patches)) {\n patchMap.set(`${start}${key}${end}`, patch);\n }\n\n // 1. Patch shared strings\n const sst = xmlMap.get(\"xl/sharedStrings.xml\");\n if (sst) {\n patchSharedStrings(sst, patchMap);\n }\n\n // 2. Patch inline strings in worksheets\n const worksheetKeys = Object.keys(zipContent).filter(\n (k) => k.startsWith(\"xl/worksheets/sheet\") && k.endsWith(\".xml\"),\n );\n for (const wsKey of worksheetKeys) {\n const ws = xmlMap.get(wsKey);\n if (ws) patchWorksheetInlineStrings(ws, patchMap);\n }\n\n // Rebuild ZIP\n const files: Record<string, Uint8Array> = {};\n for (const [key, value] of xmlMap) {\n files[key] = encoder.encode(js2xml(value));\n }\n for (const [key, value] of binaryMap) {\n files[key] = value;\n }\n\n return await zipAndConvert(files, outputType, OoxmlMimeType.XLSX);\n};\n\nfunction patchSharedStrings(sst: Element, patchMap: Map<string, IPatch>): void {\n // toJson returns {elements: [{name: \"sst\", ...}]} — unwrap to actual root\n const root = sst.name ? sst : sst.elements?.[0];\n if (!root) return;\n\n for (const si of root.elements ?? []) {\n if (si.name !== \"si\") continue;\n\n // Simple: <si><t>text</t></si>\n const t = findLocalChild(si, \"t\");\n if (t) {\n patchTextElement(t, patchMap);\n } else {\n // Rich text: <si><r><t>text</t></r>...</si>\n for (const r of si.elements ?? []) {\n if (r.name !== \"r\") continue;\n const rt = findLocalChild(r, \"t\");\n if (rt) patchTextElement(rt, patchMap);\n }\n }\n }\n}\n\nfunction patchWorksheetInlineStrings(ws: Element, patchMap: Map<string, IPatch>): void {\n const root = ws.name ? ws : ws.elements?.[0];\n if (!root) return;\n\n const sheetData = findLocalChild(root, \"sheetData\");\n if (!sheetData) return;\n\n for (const row of sheetData.elements ?? []) {\n if (localName(row) !== \"row\") continue;\n for (const cell of row.elements ?? []) {\n if (localName(cell) !== \"c\") continue;\n\n // Check inline strings: <c t=\"inlineStr\"><is><t>text</t></is></c>\n const isEl = findLocalChild(cell, \"is\");\n if (isEl) {\n const t = findLocalChild(isEl, \"t\");\n if (t) patchTextElement(t, patchMap);\n }\n }\n }\n}\n\nfunction patchTextElement(tEl: Element, patchMap: Map<string, IPatch>): void {\n const text = tEl.elements?.[0]?.text;\n if (typeof text !== \"string\") return;\n\n for (const [placeholder, patch] of patchMap) {\n if (text.includes(placeholder)) {\n const newValue = String(patch.value);\n const replaced = text.replace(placeholder, newValue);\n if (tEl.elements) {\n tEl.elements[0] = { ...tEl.elements[0], text: replaced };\n }\n }\n }\n}\n\nfunction localName(el: Element): string {\n const name = el.name ?? \"\";\n const colonIdx = name.indexOf(\":\");\n return colonIdx >= 0 ? name.slice(colonIdx + 1) : name;\n}\n\nfunction findLocalChild(parent: Element, name: string): Element | undefined {\n return (parent.elements ?? []).find((el) => localName(el) === name);\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,YAAY;AAClB,MAAM,iBAAiB;AACvB,MAAM,cAAc;AACpB,MAAM,sBACJ;AACF,MAAM,aAAa;AACnB,MAAM,aAAa;AA+BnB,MAAM,aAAa;CApBjB;EACE,MAAM;EACN,aAAa;EACb,KAAK;CACP;CACA;EAAE,MAAM;EAAW,aAAa;EAAmB,KAAK;CAAM;CAC9D;EAAE,MAAM;EAAY,aAAa;EAAW,KAAK;CAAmB;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,GAAG,MAAM,OAAO,UAAU,EAAE,MAAM,IAAI;AACpE"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["localName"],"sources":["../src/file/content-types.ts","../src/file/core-properties.ts","../src/file/media/media.ts","../src/file/shared-strings.ts","../src/file/styles.ts","../src/file/theme.ts","../src/file/workbook.ts","../src/file/worksheet.ts","../src/file/file.ts","../src/file/comments.ts","../src/file/drawing/drawing.ts","../src/file/pivot/pivot-utils.ts","../src/file/pivot/pivot-cache-definition-xml.ts","../src/file/pivot/pivot-cache-records-xml.ts","../src/file/pivot/pivot-table-xml.ts","../src/file/vml-notes.ts","../src/export/packer/next-compiler.ts","../src/export/packer/packer.ts","../src/util/index.ts","../src/parse.ts","../src/patcher.ts"],"sourcesContent":["/**\n * Content Types module for XLSX packages.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\n\nconst XLSX_MAIN = \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\";\nconst XLSX_WORKSHEET = \"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\";\nconst XLSX_STYLES = \"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\";\nconst XLSX_SHARED_STRINGS =\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml\";\nconst XLSX_THEME = \"application/vnd.openxmlformats-officedocument.theme+xml\";\nconst XLSX_CHART = \"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\";\n\ntype EntryType = \"Default\" | \"Override\";\n\ninterface ContentEntry {\n readonly type: EntryType;\n readonly contentType: string;\n readonly key: string;\n}\n\nconst STATIC_ENTRIES: readonly ContentEntry[] = [\n {\n type: \"Default\",\n contentType: \"application/vnd.openxmlformats-package.relationships+xml\",\n key: \"rels\",\n },\n { type: \"Default\", contentType: \"application/xml\", key: \"xml\" },\n { type: \"Override\", contentType: XLSX_MAIN, key: \"/xl/workbook.xml\" },\n {\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-package.core-properties+xml\",\n key: \"/docProps/core.xml\",\n },\n {\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.extended-properties+xml\",\n key: \"/docProps/app.xml\",\n },\n];\n\n// Pre-compiled static XML fragment (module-level constant)\nconst STATIC_XML = STATIC_ENTRIES.map((e) =>\n e.type === \"Default\"\n ? `<Default ContentType=\"${e.contentType}\" Extension=\"${e.key}\"/>`\n : `<Override ContentType=\"${e.contentType}\" PartName=\"${e.key}\"/>`,\n).join(\"\");\n\nexport class ContentTypes extends BaseXmlComponent {\n private readonly dynamicEntries: ContentEntry[] = [];\n\n public constructor() {\n super(\"Types\");\n }\n\n public addWorksheet(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_WORKSHEET,\n key: `/xl/worksheets/sheet${index}.xml`,\n });\n }\n\n public addStyles(): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_STYLES,\n key: \"/xl/styles.xml\",\n });\n }\n\n public addSharedStrings(): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_SHARED_STRINGS,\n key: \"/xl/sharedStrings.xml\",\n });\n }\n\n public addTheme(index: number = 1): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_THEME,\n key: `/xl/theme/theme${index}.xml`,\n });\n }\n\n public addChart(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_CHART,\n key: `/xl/charts/chart${index}.xml`,\n });\n }\n\n public addDrawing(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawing+xml\",\n key: `/xl/drawings/drawing${index}.xml`,\n });\n }\n\n public addComments(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml\",\n key: `/xl/comments${index}.xml`,\n });\n }\n\n public addVmlDrawing(): void {\n if (this.dynamicEntries.some((e) => e.type === \"Default\" && e.key === \"vml\")) return;\n this.dynamicEntries.push({\n type: \"Default\",\n contentType: \"application/vnd.openxmlformats-officedocument.vmlDrawing\",\n key: \"vml\",\n });\n }\n\n public addImageType(extension: \"png\" | \"jpeg\"): void {\n const contentType = extension === \"png\" ? \"image/png\" : \"image/jpeg\";\n if (this.dynamicEntries.some((e) => e.type === \"Default\" && e.key === extension)) return;\n this.dynamicEntries.push({ type: \"Default\", contentType, key: extension });\n }\n\n public addPivotTable(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml\",\n key: `/xl/pivotTables/pivotTable${index}.xml`,\n });\n }\n\n public addPivotCacheDefinition(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml\",\n key: `/xl/pivotCache/pivotCacheDefinition${index}.xml`,\n });\n }\n\n public addPivotCacheRecords(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml\",\n key: `/xl/pivotCache/pivotCacheRecords${index}.xml`,\n });\n }\n\n public override toXml(_context: Context): string {\n const p: string[] = [\n '<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">',\n STATIC_XML,\n ];\n for (const e of this.dynamicEntries) {\n if (e.type === \"Default\") {\n p.push(`<Default ContentType=\"${e.contentType}\" Extension=\"${e.key}\"/>`);\n } else {\n p.push(`<Override ContentType=\"${e.contentType}\" PartName=\"${e.key}\"/>`);\n }\n }\n p.push(\"</Types>\");\n return p.join(\"\");\n }\n}\n","/**\n * Core Properties module for SpreadsheetML documents.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport { buildCorePropertiesXmlString } from \"@office-open/core\";\n\nexport interface CorePropertiesOptions {\n readonly title?: string;\n readonly subject?: string;\n readonly creator?: string;\n readonly keywords?: string;\n readonly description?: string;\n readonly lastModifiedBy?: string;\n readonly revision?: number;\n}\n\nexport class CoreProperties extends BaseXmlComponent {\n private readonly options: CorePropertiesOptions;\n\n public constructor(options: CorePropertiesOptions) {\n super(\"cp:coreProperties\");\n this.options = options;\n }\n\n public override toXml(_context: Context): string {\n return buildCorePropertiesXmlString(this.options);\n }\n}\n","/**\n * Media collection for XLSX files — stores image binary data.\n *\n * @module\n */\n\nexport interface MediaData {\n readonly fileName: string;\n readonly type: string;\n readonly data: Uint8Array;\n readonly width: number;\n readonly height: number;\n}\n\nexport class Media {\n private readonly map = new Map<string, MediaData>();\n\n public addImage(key: string, data: MediaData): void {\n this.map.set(key, data);\n }\n\n public get array(): readonly MediaData[] {\n return [...this.map.values()];\n }\n}\n","/**\n * Shared Strings Table — generates xl/sharedStrings.xml.\n *\n * XLSX stores repeated string values in a central table to reduce file size.\n * Cells reference strings by index into this table.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport { escapeXml } from \"@office-open/xml\";\n\nexport class SharedStrings extends BaseXmlComponent {\n private readonly strings: string[] = [];\n private readonly indexMap = new Map<string, number>();\n\n public constructor() {\n super(\"sst\");\n }\n\n /**\n * Register a string and return its index.\n * Returns existing index if the string is already registered.\n */\n public register(s: string): number {\n const existing = this.indexMap.get(s);\n if (existing !== undefined) return existing;\n\n const idx = this.strings.length;\n this.strings.push(s);\n this.indexMap.set(s, idx);\n return idx;\n }\n\n public get count(): number {\n return this.strings.length;\n }\n\n /**\n * Zero-allocation fast path: directly concatenate XML string.\n * Bypasses the IXmlableObject intermediate tree entirely.\n */\n public override toXml(_context: Context): string {\n const p: string[] = [\n '<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"',\n ` count=\"${this.strings.length}\" uniqueCount=\"${this.indexMap.size}\">`,\n ];\n for (const s of this.strings) {\n p.push(`<si><t>${escapeXml(s)}</t></si>`);\n }\n p.push(\"</sst>\");\n return p.join(\"\");\n }\n}\n","/**\n * Styles component — generates xl/styles.xml.\n *\n * XLSX uses an index-based style system: cells reference style entries\n * via the `s` attribute, which is an index into `cellXfs`.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport { attrs, escapeXml } from \"@office-open/xml\";\n\n// ── Sub-style option interfaces ──\n\nexport interface FontOptions {\n readonly bold?: boolean;\n readonly italic?: boolean;\n readonly underline?: boolean;\n readonly strike?: boolean;\n readonly size?: number;\n readonly color?: string;\n readonly fontName?: string;\n}\n\nexport interface FillOptions {\n readonly type?: \"solid\" | \"pattern\";\n readonly color?: string;\n readonly patternType?: string;\n}\n\nexport interface BorderOptions {\n readonly style?: \"thin\" | \"medium\" | \"thick\" | \"dotted\" | \"dashed\" | \"hair\" | \"none\";\n readonly color?: string;\n}\n\nexport interface BorderSideOptions {\n readonly top?: BorderOptions;\n readonly bottom?: BorderOptions;\n readonly left?: BorderOptions;\n readonly right?: BorderOptions;\n readonly diagonal?: BorderOptions;\n}\n\nexport interface AlignmentOptions {\n readonly horizontal?: \"left\" | \"center\" | \"right\" | \"fill\" | \"justify\";\n readonly vertical?: \"top\" | \"center\" | \"bottom\";\n readonly wrapText?: boolean;\n readonly textRotation?: number;\n readonly indent?: number;\n}\n\nexport interface StyleOptions {\n readonly font?: FontOptions;\n readonly fill?: FillOptions;\n readonly border?: BorderSideOptions;\n readonly numFmt?: string;\n readonly alignment?: AlignmentOptions;\n}\n\n/** Differential format — used by conditional formatting to specify what changes. */\nexport interface DxfOptions {\n readonly font?: FontOptions;\n readonly fill?: FillOptions;\n readonly border?: BorderSideOptions;\n readonly numFmt?: string;\n}\n\n// ── Style key helpers for deduplication ──\n\nfunction fontKey(f: FontOptions): string {\n return `b${f.bold ? 1 : 0}i${f.italic ? 1 : 0}u${f.underline ? 1 : 0}s${f.strike ? 1 : 0}z${f.size ?? 0}c${f.color ?? \"\"}n${f.fontName ?? \"\"}`;\n}\n\nfunction fillKey(f: FillOptions): string {\n return `t${f.type ?? \"\"}c${f.color ?? \"\"}p${f.patternType ?? \"\"}`;\n}\n\nfunction borderKey(b: BorderSideOptions): string {\n const sk = (o?: BorderOptions) => `${o?.style ?? \"\"}_${o?.color ?? \"\"}`;\n return `t${sk(b.top)}b${sk(b.bottom)}l${sk(b.left)}r${sk(b.right)}d${sk(b.diagonal)}`;\n}\n\n// ── Built-in number format IDs ──\n\nconst BUILTIN_NUMFMTS: Record<string, number> = {\n General: 0,\n \"0\": 1,\n \"0.00\": 2,\n \"#,##0\": 3,\n \"#,##0.00\": 4,\n \"0%\": 9,\n \"0.00%\": 10,\n \"0.00E+00\": 11,\n \"mm-dd-yy\": 14,\n \"d-mmm-yy\": 15,\n \"d-mmm\": 16,\n \"mmm-yy\": 17,\n \"h:mm AM/PM\": 18,\n \"h:mm:ss AM/PM\": 19,\n \"h:mm\": 20,\n \"h:mm:ss\": 21,\n \"m/d/yy h:mm\": 22,\n \"#,##0 ;(#,##0)\": 37,\n \"#,##0 ;[Red](#,##0)\": 38,\n \"#,##0.00;(#,##0.00)\": 39,\n \"#,##0.00;[Red](#,##0.00)\": 40,\n \"mm:ss\": 45,\n \"[h]:mm:ss\": 46,\n \"mmss.0\": 47,\n \"##0.0E+0\": 48,\n \"@\": 49,\n};\n\nexport class Styles extends BaseXmlComponent {\n private readonly fonts: FontOptions[] = [\n { size: 11, fontName: \"Calibri\" }, // default font (index 0)\n ];\n private readonly fontKeys = new Map<string, number>();\n\n private readonly fills: FillOptions[] = [\n { patternType: \"none\" }, // default fill (index 0)\n { patternType: \"gray125\" }, // required fill (index 1)\n ];\n private readonly fillKeys = new Map<string, number>();\n\n private readonly borders: BorderSideOptions[] = [\n {}, // default empty border (index 0)\n ];\n private readonly borderKeys = new Map<string, number>();\n\n private readonly customNumFmts = new Map<string, number>();\n private nextCustomNumFmtId = 164; // custom numFmts start at 164\n\n private readonly cellXfs: Array<{\n readonly fontId: number;\n readonly fillId: number;\n readonly borderId: number;\n readonly numFmtId: number;\n readonly alignment?: AlignmentOptions;\n }> = [\n { fontId: 0, fillId: 0, borderId: 0, numFmtId: 0 }, // default xf (index 0)\n ];\n private readonly cellXfKeys = new Map<string, number>();\n\n private readonly dxfs: DxfOptions[] = [];\n\n public constructor() {\n super(\"styleSheet\");\n\n // Pre-register default font/fill/border keys\n this.fontKeys.set(fontKey(this.fonts[0]), 0);\n this.fillKeys.set(fillKey(this.fills[0]), 0);\n this.fillKeys.set(fillKey(this.fills[1]), 1);\n this.borderKeys.set(borderKey(this.borders[0]), 0);\n this.cellXfKeys.set(this.cellXfKey(this.cellXfs[0]), 0);\n }\n\n /**\n * Register a style and return its index (for the cell `s` attribute).\n * Deduplicates across fonts, fills, borders, numFmts, and cellXfs.\n */\n public register(opts: StyleOptions): number {\n const fontId = this.registerFont(opts.font);\n const fillId = this.registerFill(opts.fill);\n const borderId = this.registerBorder(opts.border);\n const numFmtId = this.registerNumFmt(opts.numFmt);\n\n const xf = {\n fontId,\n fillId,\n borderId,\n numFmtId,\n alignment: opts.alignment,\n };\n\n const key = this.cellXfKey(xf);\n const existing = this.cellXfKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.cellXfs.length;\n this.cellXfs.push(xf);\n this.cellXfKeys.set(key, idx);\n return idx;\n }\n\n /**\n * Register a differential format and return its index (dxfId).\n * Used by conditional formatting rules.\n */\n public registerDxf(opts: DxfOptions): number {\n const idx = this.dxfs.length;\n this.dxfs.push(opts);\n return idx;\n }\n\n private registerFont(opts?: FontOptions): number {\n if (!opts) return 0;\n const key = fontKey(opts);\n const existing = this.fontKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.fonts.length;\n this.fonts.push(opts);\n this.fontKeys.set(key, idx);\n return idx;\n }\n\n private registerFill(opts?: FillOptions): number {\n if (!opts) return 0;\n const key = fillKey(opts);\n const existing = this.fillKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.fills.length;\n this.fills.push(opts);\n this.fillKeys.set(key, idx);\n return idx;\n }\n\n private registerBorder(opts?: BorderSideOptions): number {\n if (!opts) return 0;\n const key = borderKey(opts);\n const existing = this.borderKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.borders.length;\n this.borders.push(opts);\n this.borderKeys.set(key, idx);\n return idx;\n }\n\n private registerNumFmt(fmt?: string): number {\n if (!fmt) return 0;\n const builtin = BUILTIN_NUMFMTS[fmt];\n if (builtin !== undefined) return builtin;\n\n const existing = this.customNumFmts.get(fmt);\n if (existing !== undefined) return existing;\n\n const id = this.nextCustomNumFmtId++;\n this.customNumFmts.set(fmt, id);\n return id;\n }\n\n private cellXfKey(xf: {\n readonly fontId: number;\n readonly fillId: number;\n readonly borderId: number;\n readonly numFmtId: number;\n readonly alignment?: AlignmentOptions;\n }): string {\n const a = xf.alignment;\n const ak = a\n ? `h${a.horizontal ?? \"\"}v${a.vertical ?? \"\"}w${a.wrapText ? 1 : 0}r${a.textRotation ?? \"\"}i${a.indent ?? \"\"}`\n : \"\";\n return `${xf.fontId}|${xf.fillId}|${xf.borderId}|${xf.numFmtId}|${ak}`;\n }\n\n // ── XML generation ──\n\n /**\n * Zero-allocation fast path: directly concatenate XML string.\n * Bypasses the IXmlableObject intermediate tree entirely.\n */\n public override toXml(_context: Context): string {\n const p: string[] = [\n '<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">',\n ];\n\n // numFmts\n if (this.customNumFmts.size > 0) {\n p.push(`<numFmts count=\"${this.customNumFmts.size}\">`);\n for (const [fmt, id] of this.customNumFmts) {\n p.push(`<numFmt numFmtId=\"${id}\" formatCode=\"${escapeXml(fmt)}\"/>`);\n }\n p.push(\"</numFmts>\");\n }\n\n // fonts\n p.push(`<fonts count=\"${this.fonts.length}\">`);\n for (const f of this.fonts) {\n p.push(`<font>${this.fontXmlStr(f)}</font>`);\n }\n p.push(\"</fonts>\");\n\n // fills\n p.push(`<fills count=\"${this.fills.length}\">`);\n for (const f of this.fills) {\n const patternAttrs = attrs({ patternType: f.patternType ?? \"solid\" });\n const fgColor = f.color ? `<fgColor rgb=\"FF${f.color}\"/>` : \"\";\n p.push(\n fgColor\n ? `<fill><patternFill${patternAttrs}>${fgColor}</patternFill></fill>`\n : `<fill><patternFill${patternAttrs}/></fill>`,\n );\n }\n p.push(\"</fills>\");\n\n // borders\n p.push(`<borders count=\"${this.borders.length}\">`);\n for (const b of this.borders) {\n p.push(`<border>${this.borderXmlStr(b)}</border>`);\n }\n p.push(\"</borders>\");\n\n // cellStyleXfs\n p.push(\n '<cellStyleXfs count=\"1\"><xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\"/></cellStyleXfs>',\n );\n\n // cellXfs\n p.push(`<cellXfs count=\"${this.cellXfs.length}\">`);\n for (const xf of this.cellXfs) {\n const xAttrs: Record<string, string | number | boolean | undefined> = {\n numFmtId: xf.numFmtId,\n fontId: xf.fontId,\n fillId: xf.fillId,\n borderId: xf.borderId,\n xfId: 0,\n };\n if (xf.alignment) xAttrs.applyAlignment = 1;\n if (xf.fontId > 0) xAttrs.applyFont = 1;\n if (xf.fillId > 0) xAttrs.applyFill = 1;\n if (xf.borderId > 0) xAttrs.applyBorder = 1;\n\n const alignStr = xf.alignment ? this.alignmentXmlStr(xf.alignment) : \"\";\n p.push(alignStr ? `<xf${attrs(xAttrs)}>${alignStr}</xf>` : `<xf${attrs(xAttrs)}/>`);\n }\n p.push(\"</cellXfs>\");\n\n // cellStyles\n p.push('<cellStyles count=\"1\"><cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/></cellStyles>');\n\n // dxfs\n if (this.dxfs.length > 0) {\n p.push(`<dxfs count=\"${this.dxfs.length}\">`);\n for (const dxf of this.dxfs) {\n const dParts: string[] = [];\n if (dxf.font) dParts.push(`<font>${this.fontXmlStr(dxf.font)}</font>`);\n if (dxf.fill) {\n const bgColor = dxf.fill.color ? `<bgColor rgb=\"FF${dxf.fill.color}\"/>` : \"\";\n const patAttrs = attrs({ patternType: dxf.fill.patternType ?? \"solid\" });\n dParts.push(`<fill><patternFill${patAttrs}>${bgColor}</patternFill></fill>`);\n }\n if (dxf.numFmt) dParts.push(`<numFmt formatCode=\"${escapeXml(dxf.numFmt)}\"/>`);\n if (dParts.length > 0) {\n p.push(`<dxf>${dParts.join(\"\")}</dxf>`);\n } else {\n p.push(\"<dxf/>\");\n }\n }\n p.push(\"</dxfs>\");\n } else {\n p.push('<dxfs count=\"0\"/>');\n }\n p.push(\n '<tableStyles count=\"0\" defaultTableStyle=\"TableStyleMedium2\" defaultPivotStyle=\"PivotStyleLight16\"/>',\n );\n p.push(\"<extLst/>\");\n\n p.push(\"</styleSheet>\");\n return p.join(\"\");\n }\n\n private fontXmlStr(f: FontOptions): string {\n const parts: string[] = [];\n if (f.bold) parts.push(\"<b/>\");\n if (f.italic) parts.push(\"<i/>\");\n if (f.underline) parts.push(\"<u/>\");\n if (f.strike) parts.push(\"<strike/>\");\n if (f.size) parts.push(`<sz val=\"${f.size}\"/>`);\n if (f.color) parts.push(`<color rgb=\"FF${f.color}\"/>`);\n if (f.fontName) parts.push(`<name val=\"${escapeXml(f.fontName)}\"/>`);\n return parts.join(\"\");\n }\n\n private borderXmlStr(b: BorderSideOptions): string {\n const parts: string[] = [];\n for (const side of [\"left\", \"right\", \"top\", \"bottom\", \"diagonal\"] as const) {\n const opts = b[side] as BorderOptions | undefined;\n if (opts && opts.style && opts.style !== \"none\") {\n const colorStr = opts.color ? `<color rgb=\"FF${opts.color}\"/>` : \"\";\n parts.push(`<${side} style=\"${opts.style}\">${colorStr}</${side}>`);\n } else {\n parts.push(`<${side}/>`);\n }\n }\n return parts.join(\"\");\n }\n\n private alignmentXmlStr(a: AlignmentOptions): string {\n const aAttrs: Record<string, string | number | boolean | undefined> = {};\n if (a.horizontal) aAttrs.horizontal = a.horizontal;\n if (a.vertical) aAttrs.vertical = a.vertical;\n if (a.wrapText) aAttrs.wrapText = 1;\n if (a.textRotation !== undefined) aAttrs.textRotation = a.textRotation;\n if (a.indent !== undefined) aAttrs.indent = a.indent;\n return `<alignment${attrs(aAttrs)}/>`;\n }\n}\n","/**\n * Default theme for XLSX files — matches Microsoft Office's output structure.\n * Produces xl/theme/theme1.xml that Excel accepts without repair warnings.\n *\n * The theme XML is completely static — identical for every XLSX file.\n * Pre-serialized as a string constant to avoid building the IXmlableObject\n * tree and re-serializing on every compile.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\n\n// Pre-serialized theme XML. Generated once via xml(buildThemeObj()) and inlined.\n// To regenerate: run `pnpm tsx scripts/gen-theme.ts` from packages/xlsx.\nconst THEME_XML =\n '<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office Theme\"><a:themeElements><a:clrScheme name=\"Office\"><a:dk1><a:sysClr val=\"windowText\" lastClr=\"000000\"/></a:dk1><a:lt1><a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1><a:dk2><a:srgbClr val=\"44546A\"/></a:dk2><a:lt2><a:srgbClr val=\"E7E6E6\"/></a:lt2><a:accent1><a:srgbClr val=\"5B9BD5\"/></a:accent1><a:accent2><a:srgbClr val=\"ED7D31\"/></a:accent2><a:accent3><a:srgbClr val=\"A5A5A5\"/></a:accent3><a:accent4><a:srgbClr val=\"FFC000\"/></a:accent4><a:accent5><a:srgbClr val=\"4472C4\"/></a:accent5><a:accent6><a:srgbClr val=\"70AD47\"/></a:accent6><a:hlink><a:srgbClr val=\"0563C1\"/></a:hlink><a:folHlink><a:srgbClr val=\"954F72\"/></a:folHlink></a:clrScheme><a:fontScheme name=\"Office\"><a:majorFont><a:latin typeface=\"Calibri Light\" panose=\"020F0302020204030204\"/><a:ea typeface=\"\"/><a:cs typeface=\"\"/></a:majorFont><a:minorFont><a:latin typeface=\"Calibri\" panose=\"020F0502020204030204\"/><a:ea typeface=\"\"/><a:cs typeface=\"\"/></a:minorFont></a:fontScheme><a:fmtScheme name=\"Office\"><a:fillStyleLst><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"110000\"/><a:satMod val=\"105000\"/><a:tint val=\"67000\"/></a:schemeClr></a:gs><a:gs pos=\"50000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"105000\"/><a:satMod val=\"103000\"/><a:tint val=\"73000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"105000\"/><a:satMod val=\"109000\"/><a:tint val=\"81000\"/></a:schemeClr></a:gs></a:gsLst><a:lin ang=\"5400000\" scaled=\"0\"/></a:gradFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"102000\"/><a:satMod val=\"103000\"/><a:tint val=\"94000\"/></a:schemeClr></a:gs><a:gs pos=\"50000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"100000\"/><a:satMod val=\"110000\"/><a:shade val=\"100000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"99000\"/><a:satMod val=\"120000\"/><a:shade val=\"78000\"/></a:schemeClr></a:gs></a:gsLst><a:lin ang=\"5400000\" scaled=\"0\"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w=\"6350\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"solid\"/><a:miter lim=\"800000\"/></a:ln><a:ln w=\"12700\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"solid\"/><a:miter lim=\"800000\"/></a:ln><a:ln w=\"19050\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"solid\"/><a:miter lim=\"800000\"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad=\"57150\" dist=\"19050\" dir=\"5400000\" algn=\"ctr\" rotWithShape=\"0\"><a:srgbClr val=\"000000\"><a:alpha val=\"63000\"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:solidFill><a:schemeClr val=\"phClr\"><a:tint val=\"95000\"/><a:satMod val=\"170000\"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"102000\"/><a:satMod val=\"150000\"/><a:tint val=\"93000\"/><a:shade val=\"98000\"/></a:schemeClr></a:gs><a:gs pos=\"50000\"><a:schemeClr val=\"phClr\"><a:lumMod val=\"103000\"/><a:satMod val=\"130000\"/><a:tint val=\"98000\"/><a:shade val=\"90000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:satMod val=\"120000\"/><a:shade val=\"63000\"/></a:schemeClr></a:gs></a:gsLst><a:lin ang=\"5400000\" scaled=\"0\"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>';\n\nexport class DefaultTheme extends BaseXmlComponent {\n public constructor() {\n super(\"a:theme\");\n }\n\n /** Return pre-cached static theme XML — zero allocation. */\n public override toXml(_context: Context): string {\n return THEME_XML;\n }\n}\n","/**\n * Workbook component — generates xl/workbook.xml.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport { escapeXml } from \"@office-open/xml\";\n\nexport interface SheetDefinition {\n readonly name: string;\n readonly sheetId: number;\n readonly rId: string;\n readonly state?: \"visible\" | \"hidden\" | \"veryHidden\";\n}\n\nexport interface PivotCacheReference {\n readonly cacheId: number;\n readonly rId: string;\n}\n\nexport class WorkbookXml extends BaseXmlComponent {\n private readonly sheets: readonly SheetDefinition[];\n private readonly pivotCaches: readonly PivotCacheReference[];\n\n public constructor(\n sheets: readonly SheetDefinition[],\n pivotCaches?: readonly PivotCacheReference[],\n ) {\n super(\"workbook\");\n this.sheets = sheets;\n this.pivotCaches = pivotCaches ?? [];\n }\n\n public override toXml(_context: Context): string {\n const p: string[] = [\n '<workbook xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"' +\n ' xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"' +\n ' xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"' +\n ' mc:Ignorable=\"x15 xr xr6 xr10 xr2\"' +\n ' xmlns:x15=\"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main\"' +\n ' xmlns:xr=\"http://schemas.microsoft.com/office/spreadsheetml/2014/revision\"' +\n ' xmlns:xr6=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision6\"' +\n ' xmlns:xr10=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision10\"' +\n ' xmlns:xr2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2\">',\n '<fileVersion appName=\"xl\" lastEdited=\"7\" lowestEdited=\"6\" rupBuild=\"29929\"/>',\n \"<workbookPr/>\",\n '<bookViews><workbookView xWindow=\"0\" yWindow=\"0\" windowWidth=\"28800\" windowHeight=\"12300\"/></bookViews>',\n \"<sheets>\",\n ];\n for (const s of this.sheets) {\n const stateAttr = s.state && s.state !== \"visible\" ? ` state=\"${s.state}\"` : \"\";\n p.push(\n `<sheet name=\"${escapeXml(s.name)}\" sheetId=\"${s.sheetId}\" r:id=\"${s.rId}\"${stateAttr}/>`,\n );\n }\n p.push(\"</sheets>\");\n\n p.push('<calcPr calcId=\"162913\"/>');\n\n if (this.pivotCaches.length > 0) {\n p.push(\"<pivotCaches>\");\n for (const pc of this.pivotCaches) {\n p.push(`<pivotCache cacheId=\"${pc.cacheId}\" r:id=\"${pc.rId}\"/>`);\n }\n p.push(\"</pivotCaches>\");\n }\n\n p.push(\"</workbook>\");\n return p.join(\"\");\n }\n}\n","import type { SharedStrings } from \"@file/shared-strings\";\nimport type { Styles, StyleOptions } from \"@file/styles\";\n/**\n * Worksheet component — generates xl/worksheets/sheet{n}.xml.\n *\n * @module\n */\nimport { IgnoreIfEmptyXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport type { ChartSpaceOptions } from \"@office-open/core\";\nimport { attrs, escapeXml, selfCloseElement } from \"@office-open/xml\";\n\nimport type { PivotTableOptions } from \"./pivot\";\n\nexport interface ColumnOptions {\n readonly min: number;\n readonly max: number;\n readonly width?: number;\n readonly hidden?: boolean;\n readonly customWidth?: boolean;\n readonly outlineLevel?: number;\n readonly collapsed?: boolean;\n}\n\nexport interface RowOptions {\n readonly cells?: readonly CellOptions[];\n readonly height?: number;\n readonly hidden?: boolean;\n readonly rowNumber?: number;\n}\n\nexport interface CellOptions {\n readonly value?: string | number | boolean | Date | null;\n readonly reference?: string;\n /** Direct style index (for pre-resolved styles) */\n readonly styleIndex?: number;\n /** Style options (resolved to index at compile time) */\n readonly style?: StyleOptions;\n /** Formula options. When set, value becomes the cached result. */\n readonly formula?: FormulaOptions;\n}\n\n/** Cell formula type (maps to ST_CellFormulaType). */\nexport const FormulaType = {\n NORMAL: \"normal\",\n ARRAY: \"array\",\n SHARED: \"shared\",\n} as const;\n\nexport type FormulaType = (typeof FormulaType)[keyof typeof FormulaType];\n\n/** Options for a cell formula (maps to CT_CellFormula). */\nexport interface FormulaOptions {\n /** Formula expression, e.g. \"SUM(A1:B1)\" */\n readonly formula: string;\n /** Formula type (default: \"normal\") */\n readonly type?: FormulaType;\n /** Reference range for array/shared formulas, e.g. \"C1:C10\" */\n readonly reference?: string;\n /** Shared formula group index (required for shared formulas) */\n readonly sharedIndex?: number;\n}\n\nexport interface MergeCellOptions {\n readonly from: { readonly row: number; readonly col: number };\n readonly to: { readonly row: number; readonly col: number };\n}\n\nexport interface SheetProtectionOptions {\n /** Plain-text password — legacy Excel hash is computed automatically */\n readonly password?: string;\n /** Set true to enable sheet protection (required for protection flags to take effect) */\n readonly sheet?: boolean;\n readonly objects?: boolean;\n readonly scenarios?: boolean;\n readonly formatCells?: boolean;\n readonly formatColumns?: boolean;\n readonly formatRows?: boolean;\n readonly insertColumns?: boolean;\n readonly insertRows?: boolean;\n readonly insertHyperlinks?: boolean;\n readonly deleteColumns?: boolean;\n readonly deleteRows?: boolean;\n readonly selectLockedCells?: boolean;\n readonly sort?: boolean;\n readonly autoFilter?: boolean;\n readonly pivotTables?: boolean;\n readonly selectUnlockedCells?: boolean;\n}\n\nexport interface FreezePaneOptions {\n /** Row split position (1-based, freezes rows above) */\n readonly row?: number;\n /** Column split position (1-based, freezes columns to the left) */\n readonly col?: number;\n}\n\nexport interface WorksheetImageOptions {\n readonly data: Uint8Array;\n readonly type: \"png\" | \"jpeg\" | \"jpg\";\n readonly col: number;\n readonly row: number;\n}\n\nexport interface WorksheetChartOptions extends ChartSpaceOptions {\n /** 1-based column position for the chart */\n readonly col: number;\n /** 1-based row position for the chart */\n readonly row: number;\n}\n\nexport interface SheetViewOptions {\n readonly showGridLines?: boolean;\n readonly showRowColHeaders?: boolean;\n readonly showZeros?: boolean;\n readonly zoomScale?: number;\n readonly tabSelected?: boolean;\n readonly rightToLeft?: boolean;\n}\n\nexport type HyperlinkTarget =\n | { readonly type: \"external\"; readonly url: string }\n | { readonly type: \"internal\"; readonly location: string };\n\nexport interface HyperlinkOptions {\n /** Cell reference, e.g. \"A1\" */\n readonly cell: string;\n /** Hyperlink target */\n readonly target: HyperlinkTarget;\n /** Tooltip text */\n readonly tooltip?: string;\n /** Display text */\n readonly display?: string;\n}\n\nexport interface HeaderFooterOptions {\n readonly oddHeader?: string;\n readonly oddFooter?: string;\n readonly evenHeader?: string;\n readonly evenFooter?: string;\n readonly firstHeader?: string;\n readonly firstFooter?: string;\n readonly differentOddEven?: boolean;\n readonly differentFirst?: boolean;\n}\n\nexport type PageOrientation = \"default\" | \"portrait\" | \"landscape\";\n\nexport interface PageSetupOptions {\n readonly paperSize?: number;\n readonly orientation?: PageOrientation;\n readonly scale?: number;\n readonly fitToWidth?: number;\n readonly fitToHeight?: number;\n readonly pageOrder?: \"downThenOver\" | \"overThenDown\";\n readonly useFirstPageNumber?: boolean;\n readonly firstPageNumber?: number;\n}\n\nexport interface TabColorOptions {\n /** RGB color string, e.g. \"FF0000\" */\n readonly rgb?: string;\n /** Theme color index (0-based) */\n readonly theme?: number;\n /** Tint value (-1.0 to 1.0) */\n readonly tint?: number;\n}\n\nexport interface CommentOptions {\n /** Cell reference, e.g. \"A1\" */\n readonly cell: string;\n /** Author name */\n readonly author: string;\n /** Comment text */\n readonly text: string;\n}\n\nexport type DataValidationType =\n | \"none\"\n | \"whole\"\n | \"decimal\"\n | \"list\"\n | \"date\"\n | \"time\"\n | \"textLength\"\n | \"custom\";\nexport type DataValidationOperator =\n | \"between\"\n | \"notBetween\"\n | \"equal\"\n | \"notEqual\"\n | \"greaterThan\"\n | \"lessThan\"\n | \"greaterThanOrEqual\"\n | \"lessThanOrEqual\";\n\nexport interface DataValidationOptions {\n /** Cell range, e.g. \"A1:A10\" */\n readonly sqref: string;\n readonly type?: DataValidationType;\n readonly operator?: DataValidationOperator;\n readonly formula1?: string;\n readonly formula2?: string;\n readonly allowBlank?: boolean;\n readonly showErrorMessage?: boolean;\n readonly errorTitle?: string;\n readonly error?: string;\n readonly showInputMessage?: boolean;\n readonly promptTitle?: string;\n readonly prompt?: string;\n}\n\nexport type ConditionalFormatType =\n | \"cellIs\"\n | \"containsText\"\n | \"expression\"\n | \"top10\"\n | \"aboveAverage\";\nexport type ConditionalFormatOperator =\n | \"lessThan\"\n | \"lessThanOrEqual\"\n | \"equal\"\n | \"notEqual\"\n | \"greaterThanOrEqual\"\n | \"greaterThan\"\n | \"between\"\n | \"notBetween\"\n | \"containsText\"\n | \"notContains\"\n | \"beginsWith\"\n | \"endsWith\";\n\nexport interface ConditionalFormatRule {\n readonly type: ConditionalFormatType;\n readonly operator?: ConditionalFormatOperator;\n /** Formula(s) — up to 3 */\n readonly formulas?: readonly string[];\n readonly priority?: number;\n /** Reference to a dxf (differential format) in the styles table */\n readonly dxfId?: number;\n}\n\nexport interface ConditionalFormatOptions {\n /** Cell range, e.g. \"A1:A10\" */\n readonly sqref: string;\n readonly rules: readonly ConditionalFormatRule[];\n}\n\nexport interface Top10FilterOptions {\n readonly colId: number;\n readonly top?: boolean;\n readonly percent?: boolean;\n readonly val: number;\n}\n\nexport interface CustomFilterOptions {\n readonly colId: number;\n readonly operator?:\n | \"equal\"\n | \"notEqual\"\n | \"greaterThan\"\n | \"greaterThanOrEqual\"\n | \"lessThan\"\n | \"lessThanOrEqual\";\n readonly val?: string;\n readonly and?: boolean;\n readonly val2?: string;\n}\n\nexport interface SortCondition {\n /** Cell reference for the sort column, e.g. \"B1\" */\n readonly ref: string;\n readonly descending?: boolean;\n}\n\nexport interface AutoFilterOptions {\n /** Range, e.g. \"A1:D10\" */\n readonly ref: string;\n readonly top10?: readonly Top10FilterOptions[];\n readonly customFilters?: readonly CustomFilterOptions[];\n readonly sort?: readonly SortCondition[];\n}\n\nexport interface WorksheetOptions {\n readonly name?: string;\n readonly rows?: readonly RowOptions[];\n readonly columns?: readonly ColumnOptions[];\n readonly mergeCells?: readonly MergeCellOptions[];\n readonly freezePanes?: FreezePaneOptions;\n readonly protection?: SheetProtectionOptions;\n /** Auto-filter configuration */\n readonly autoFilter?: string | AutoFilterOptions;\n readonly images?: readonly WorksheetImageOptions[];\n readonly charts?: readonly WorksheetChartOptions[];\n readonly dataValidations?: readonly DataValidationOptions[];\n readonly conditionalFormats?: readonly ConditionalFormatOptions[];\n readonly hyperlinks?: readonly HyperlinkOptions[];\n readonly comments?: readonly CommentOptions[];\n readonly headerFooter?: HeaderFooterOptions;\n readonly pageSetup?: PageSetupOptions;\n readonly tabColor?: TabColorOptions;\n readonly sheetView?: SheetViewOptions;\n readonly pivotTables?: readonly PivotTableOptions[];\n}\n\nexport class Worksheet extends IgnoreIfEmptyXmlComponent {\n private readonly rows: readonly RowOptions[];\n private readonly columns: readonly ColumnOptions[];\n private readonly mergeCells: readonly MergeCellOptions[];\n private readonly freezePanes?: FreezePaneOptions;\n private readonly protection?: SheetProtectionOptions;\n private readonly autoFilter?: string | AutoFilterOptions;\n private readonly images: readonly WorksheetImageOptions[];\n private readonly chartOptions: readonly WorksheetChartOptions[];\n private readonly dataValidations: readonly DataValidationOptions[];\n private readonly conditionalFormats: readonly ConditionalFormatOptions[];\n private readonly hyperlinks: readonly HyperlinkOptions[];\n private readonly comments: readonly CommentOptions[];\n private readonly headerFooter?: HeaderFooterOptions;\n private readonly pageSetup?: PageSetupOptions;\n private readonly tabColor?: TabColorOptions;\n private readonly sheetView?: SheetViewOptions;\n private readonly pivotTableOptions: readonly PivotTableOptions[];\n\n public constructor(options: WorksheetOptions) {\n super(\"worksheet\");\n this.rows = options.rows ?? [];\n this.columns = options.columns ?? [];\n this.mergeCells = options.mergeCells ?? [];\n this.freezePanes = options.freezePanes;\n this.protection = options.protection;\n this.autoFilter = options.autoFilter;\n this.images = options.images ?? [];\n this.chartOptions = options.charts ?? [];\n this.dataValidations = options.dataValidations ?? [];\n this.conditionalFormats = options.conditionalFormats ?? [];\n this.hyperlinks = options.hyperlinks ?? [];\n this.comments = options.comments ?? [];\n this.headerFooter = options.headerFooter;\n this.pageSetup = options.pageSetup;\n this.tabColor = options.tabColor;\n this.sheetView = options.sheetView;\n this.pivotTableOptions = options.pivotTables ?? [];\n }\n\n public get imageOptions(): readonly WorksheetImageOptions[] {\n return this.images;\n }\n\n public get charts(): readonly WorksheetChartOptions[] {\n return this.chartOptions;\n }\n\n public get hyperlinkOptions(): readonly HyperlinkOptions[] {\n return this.hyperlinks;\n }\n\n public get worksheetRows(): readonly RowOptions[] {\n return this.rows;\n }\n\n public get commentOptions(): readonly CommentOptions[] {\n return this.comments;\n }\n\n public get pivotTables(): readonly PivotTableOptions[] {\n return this.pivotTableOptions;\n }\n\n /**\n * Zero-allocation fast path: directly concatenate XML string.\n * Bypasses the IXmlableObject intermediate tree entirely.\n */\n public override toXml(context: Context): string {\n const fileData = context.fileData as\n | { sharedStrings?: SharedStrings; styles?: Styles }\n | undefined;\n const sharedStrings = fileData?.sharedStrings;\n const styles = fileData?.styles;\n\n const p: string[] = [\n '<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"' +\n ' xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"' +\n ' xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"' +\n ' mc:Ignorable=\"x14ac xr xr2 xr3\"' +\n ' xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\"' +\n ' xmlns:xr=\"http://schemas.microsoft.com/office/spreadsheetml/2014/revision\"' +\n ' xmlns:xr2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2\"' +\n ' xmlns:xr3=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3\">',\n ];\n\n // Sheet properties (tabColor, outlinePr go here)\n const hasTabColor = !!this.tabColor;\n const hasOutline = this.columns.some((c) => c.outlineLevel !== undefined);\n if (hasTabColor || hasOutline) {\n const prParts: string[] = [];\n if (this.tabColor) {\n const tc = this.tabColor;\n const tcAttrs: Record<string, string | number | boolean | undefined> = {};\n if (tc.rgb) tcAttrs.rgb = tc.rgb;\n if (tc.theme !== undefined) tcAttrs.theme = tc.theme;\n if (tc.tint !== undefined) tcAttrs.tint = tc.tint;\n prParts.push(`<tabColor${attrs(tcAttrs)}/>`);\n }\n if (hasOutline) {\n prParts.push('<outlinePr summaryBelow=\"1\" summaryRight=\"1\"/>');\n }\n p.push(`<sheetPr>${prParts.join(\"\")}</sheetPr>`);\n }\n\n // Dimension — defines the used range of the sheet\n const maxRow = this.rows.length;\n let maxCol = 0;\n for (const row of this.rows) {\n if (row.cells && row.cells.length > maxCol) maxCol = row.cells.length;\n }\n if (maxRow > 0 && maxCol > 0) {\n const dimRef = `A1:${this.defaultCellRef(maxRow, maxCol)}`;\n p.push(`<dimension ref=\"${dimRef}\"/>`);\n }\n\n // Sheet views\n if (this.freezePanes) {\n const fp = this.freezePanes;\n const ySplit = fp.row ? fp.row : 0;\n const xSplit = fp.col ? fp.col : 0;\n const topRow = fp.row ? fp.row + 1 : 1;\n const leftCol = fp.col ? fp.col + 1 : 1;\n const topLeftCell = this.defaultCellRef(topRow, leftCol);\n const activePane =\n ySplit > 0 && xSplit > 0 ? \"bottomRight\" : ySplit > 0 ? \"bottomLeft\" : \"topRight\";\n const svAttrs = this.buildSheetViewAttrs();\n p.push(\n `<sheetViews><sheetView${svAttrs}>`,\n `<pane ySplit=\"${ySplit}\" xSplit=\"${xSplit}\" topLeftCell=\"${topLeftCell}\" activePane=\"${activePane}\" state=\"frozen\"/>`,\n \"</sheetView></sheetViews>\",\n );\n } else {\n const svAttrs = this.buildSheetViewAttrs();\n p.push(`<sheetViews><sheetView${svAttrs}/></sheetViews>`);\n }\n\n // Sheet format — default row height\n p.push('<sheetFormatPr defaultRowHeight=\"15\"/>');\n\n // Column definitions\n if (this.columns.length > 0) {\n p.push(\"<cols>\");\n for (const col of this.columns) {\n const colAttrs: Record<string, string | number | boolean | undefined> = {\n min: col.min,\n max: col.max,\n };\n if (col.width !== undefined) {\n colAttrs.width = col.width;\n colAttrs.customWidth = 1;\n }\n if (col.hidden) {\n colAttrs.hidden = 1;\n }\n if (col.outlineLevel !== undefined) {\n colAttrs.outlineLevel = col.outlineLevel;\n }\n if (col.collapsed) {\n colAttrs.collapsed = 1;\n }\n p.push(selfCloseElement(\"col\", attrs(colAttrs)));\n }\n p.push(\"</cols>\");\n }\n\n // Sheet data (rows + cells) — the hot path\n p.push(\"<sheetData>\");\n for (let i = 0; i < this.rows.length; i++) {\n const rowOpts = this.rows[i];\n const rowNumber = rowOpts.rowNumber ?? i + 1;\n const rowAttrs: Record<string, string | number | boolean | undefined> = { r: rowNumber };\n if (rowOpts.height !== undefined) {\n rowAttrs.ht = rowOpts.height;\n rowAttrs.customHeight = 1;\n }\n if (rowOpts.hidden) {\n rowAttrs.hidden = 1;\n }\n\n if (rowOpts.cells) {\n const rowParts: string[] = [];\n for (let j = 0; j < rowOpts.cells.length; j++) {\n const cell = rowOpts.cells[j];\n const ref = cell.reference ?? this.defaultCellRef(rowNumber, j + 1);\n const cellStr = this.buildCellString(ref, cell, sharedStrings, styles);\n if (cellStr) rowParts.push(cellStr);\n }\n p.push(`<row${attrs(rowAttrs)}>`, ...rowParts, \"</row>\");\n } else {\n p.push(`<row${attrs(rowAttrs)}/>`);\n }\n }\n p.push(\"</sheetData>\");\n\n // Sheet protection (before autoFilter per XSD sequence)\n if (this.protection) {\n const prot = this.protection;\n const protAttrs: Record<string, string | number | boolean | undefined> = {};\n if (prot.password) protAttrs.password = this.hashPassword(prot.password);\n if (prot.sheet) protAttrs.sheet = 1;\n if (prot.objects) protAttrs.objects = 1;\n if (prot.scenarios) protAttrs.scenarios = 1;\n if (prot.formatCells === false) protAttrs.formatCells = 0;\n if (prot.formatColumns === false) protAttrs.formatColumns = 0;\n if (prot.formatRows === false) protAttrs.formatRows = 0;\n if (prot.insertColumns === false) protAttrs.insertColumns = 0;\n if (prot.insertRows === false) protAttrs.insertRows = 0;\n if (prot.insertHyperlinks === false) protAttrs.insertHyperlinks = 0;\n if (prot.deleteColumns === false) protAttrs.deleteColumns = 0;\n if (prot.deleteRows === false) protAttrs.deleteRows = 0;\n if (prot.selectLockedCells) protAttrs.selectLockedCells = 1;\n if (prot.sort === false) protAttrs.sort = 0;\n if (prot.autoFilter === false) protAttrs.autoFilter = 0;\n if (prot.pivotTables === false) protAttrs.pivotTables = 0;\n if (prot.selectUnlockedCells) protAttrs.selectUnlockedCells = 1;\n p.push(selfCloseElement(\"sheetProtection\", attrs(protAttrs)));\n }\n\n // Auto filter\n if (this.autoFilter) {\n if (typeof this.autoFilter === \"string\") {\n p.push(selfCloseElement(\"autoFilter\", attrs({ ref: this.autoFilter })));\n } else {\n const af = this.autoFilter;\n const inner: string[] = [];\n for (const t10 of af.top10 ?? []) {\n const t10Attrs: Record<string, string | number | boolean | undefined> = { val: t10.val };\n if (t10.top === false) t10Attrs.top = 0;\n if (t10.percent) t10Attrs.percent = 1;\n inner.push(\n `<filterColumn colId=\"${t10.colId}\"><top10${attrs(t10Attrs)}/></filterColumn>`,\n );\n }\n for (const cf of af.customFilters ?? []) {\n const cfAttrs: Record<string, string | number | boolean | undefined> = {};\n if (cf.and) cfAttrs.and = 1;\n const filters: string[] = [];\n if (cf.val !== undefined) {\n const fAttrs: Record<string, string | number | boolean | undefined> = { val: cf.val };\n if (cf.operator) fAttrs.operator = cf.operator;\n filters.push(selfCloseElement(\"customFilter\", attrs(fAttrs)));\n }\n if (cf.val2 !== undefined) {\n filters.push(selfCloseElement(\"customFilter\", attrs({ val: cf.val2 })));\n }\n if (filters.length > 0) {\n inner.push(\n `<filterColumn colId=\"${cf.colId}\"><customFilters${attrs(cfAttrs)}>${filters.join(\"\")}</customFilters></filterColumn>`,\n );\n }\n }\n if (af.sort && af.sort.length > 0) {\n const sortParts: string[] = [];\n for (const sc of af.sort) {\n const scAttrs: Record<string, string | number | boolean | undefined> = { ref: sc.ref };\n if (sc.descending) scAttrs.descending = 1;\n sortParts.push(selfCloseElement(\"sortCondition\", attrs(scAttrs)));\n }\n inner.push(`<sortState ref=\"${af.ref}\">${sortParts.join(\"\")}</sortState>`);\n }\n if (inner.length > 0) {\n p.push(`<autoFilter ref=\"${af.ref}\">`, ...inner, \"</autoFilter>\");\n } else {\n p.push(selfCloseElement(\"autoFilter\", attrs({ ref: af.ref })));\n }\n }\n }\n\n // Merge cells\n if (this.mergeCells.length > 0) {\n p.push(`<mergeCells count=\"${this.mergeCells.length}\">`);\n for (const mc of this.mergeCells) {\n const fromRef = this.defaultCellRef(mc.from.row, mc.from.col);\n const toRef = this.defaultCellRef(mc.to.row, mc.to.col);\n p.push(selfCloseElement(\"mergeCell\", attrs({ ref: `${fromRef}:${toRef}` })));\n }\n p.push(\"</mergeCells>\");\n }\n\n // Conditional formatting\n if (this.conditionalFormats.length > 0) {\n for (const cf of this.conditionalFormats) {\n p.push(`<conditionalFormatting sqref=\"${cf.sqref}\">`);\n for (let ri = 0; ri < cf.rules.length; ri++) {\n const rule = cf.rules[ri];\n const ruleAttrs: Record<string, string | number | boolean | undefined> = {\n type: rule.type,\n priority: rule.priority ?? ri + 1,\n };\n if (rule.operator) ruleAttrs.operator = rule.operator;\n if (rule.dxfId !== undefined) ruleAttrs.dxfId = rule.dxfId;\n if (rule.formulas && rule.formulas.length > 0) {\n const formulaParts = rule.formulas.map((f) => `<formula>${escapeXml(f)}</formula>`);\n p.push(`<cfRule${attrs(ruleAttrs)}>`, ...formulaParts, \"</cfRule>\");\n } else {\n p.push(selfCloseElement(\"cfRule\", attrs(ruleAttrs)));\n }\n }\n p.push(\"</conditionalFormatting>\");\n }\n }\n\n // Data validations\n if (this.dataValidations.length > 0) {\n p.push(`<dataValidations count=\"${this.dataValidations.length}\">`);\n for (const dv of this.dataValidations) {\n const dvAttrs: Record<string, string | number | boolean | undefined> = { sqref: dv.sqref };\n if (dv.type && dv.type !== \"none\") dvAttrs.type = dv.type;\n if (dv.operator) dvAttrs.operator = dv.operator;\n if (dv.allowBlank) dvAttrs.allowBlank = 1;\n if (dv.showErrorMessage) dvAttrs.showErrorMessage = 1;\n if (dv.showInputMessage) dvAttrs.showInputMessage = 1;\n if (dv.errorTitle) dvAttrs.errorTitle = dv.errorTitle;\n if (dv.error) dvAttrs.error = dv.error;\n if (dv.promptTitle) dvAttrs.promptTitle = dv.promptTitle;\n if (dv.prompt) dvAttrs.prompt = dv.prompt;\n const inner: string[] = [];\n if (dv.formula1 !== undefined) inner.push(`<formula1>${escapeXml(dv.formula1)}</formula1>`);\n if (dv.formula2 !== undefined) inner.push(`<formula2>${escapeXml(dv.formula2)}</formula2>`);\n if (inner.length > 0) {\n p.push(`<dataValidation${attrs(dvAttrs)}>`, ...inner, \"</dataValidation>\");\n } else {\n p.push(selfCloseElement(\"dataValidation\", attrs(dvAttrs)));\n }\n }\n p.push(\"</dataValidations>\");\n }\n\n // Hyperlinks — r:id numbering must match worksheet rels order (compiler handles rels)\n if (this.hyperlinks.length > 0) {\n p.push(\"<hyperlinks>\");\n let hlIdx = 0;\n for (const hl of this.hyperlinks) {\n const hlAttrs: Record<string, string | number | boolean | undefined> = { ref: hl.cell };\n if (hl.target.type === \"external\") {\n hlIdx++;\n hlAttrs[\"r:id\"] = `rId${hlIdx}`;\n } else {\n hlAttrs.location = hl.target.location;\n }\n if (hl.tooltip) hlAttrs.tooltip = hl.tooltip;\n if (hl.display) hlAttrs.display = hl.display;\n p.push(selfCloseElement(\"hyperlink\", attrs(hlAttrs)));\n }\n p.push(\"</hyperlinks>\");\n }\n\n p.push('<pageMargins left=\"0.75\" right=\"0.75\" top=\"1\" bottom=\"1\" header=\"0.5\" footer=\"0.5\"/>');\n\n // Page setup\n if (this.pageSetup) {\n const ps = this.pageSetup;\n const psAttrs: Record<string, string | number | boolean | undefined> = {};\n if (ps.paperSize !== undefined) psAttrs.paperSize = ps.paperSize;\n if (ps.orientation && ps.orientation !== \"default\") psAttrs.orientation = ps.orientation;\n if (ps.scale !== undefined) psAttrs.scale = ps.scale;\n if (ps.fitToWidth !== undefined) psAttrs.fitToWidth = ps.fitToWidth;\n if (ps.fitToHeight !== undefined) psAttrs.fitToHeight = ps.fitToHeight;\n if (ps.pageOrder && ps.pageOrder !== \"downThenOver\") psAttrs.pageOrder = ps.pageOrder;\n if (ps.useFirstPageNumber) psAttrs.useFirstPageNumber = 1;\n if (ps.firstPageNumber !== undefined) psAttrs.firstPageNumber = ps.firstPageNumber;\n p.push(selfCloseElement(\"pageSetup\", attrs(psAttrs)));\n }\n\n // Header/footer\n if (this.headerFooter) {\n const hf = this.headerFooter;\n const hfAttrs: Record<string, string | number | boolean | undefined> = {};\n if (hf.differentOddEven) hfAttrs.differentOddEven = 1;\n if (hf.differentFirst) hfAttrs.differentFirst = 1;\n const inner: string[] = [];\n if (hf.oddHeader) inner.push(`<oddHeader>${escapeXml(hf.oddHeader)}</oddHeader>`);\n if (hf.oddFooter) inner.push(`<oddFooter>${escapeXml(hf.oddFooter)}</oddFooter>`);\n if (hf.evenHeader) inner.push(`<evenHeader>${escapeXml(hf.evenHeader)}</evenHeader>`);\n if (hf.evenFooter) inner.push(`<evenFooter>${escapeXml(hf.evenFooter)}</evenFooter>`);\n if (hf.firstHeader) inner.push(`<firstHeader>${escapeXml(hf.firstHeader)}</firstHeader>`);\n if (hf.firstFooter) inner.push(`<firstFooter>${escapeXml(hf.firstFooter)}</firstFooter>`);\n if (inner.length > 0) {\n p.push(`<headerFooter${attrs(hfAttrs)}>`, ...inner, \"</headerFooter>\");\n } else if (hfAttrs.differentOddEven || hfAttrs.differentFirst) {\n p.push(selfCloseElement(\"headerFooter\", attrs(hfAttrs)));\n }\n }\n\n p.push(\"</worksheet>\");\n return p.join(\"\");\n }\n\n private buildSheetViewAttrs(): string {\n const sv = this.sheetView;\n const svMap: Record<string, string | number | boolean | undefined> = {\n workbookViewId: 0,\n };\n if (sv?.tabSelected !== undefined) svMap.tabSelected = sv.tabSelected ? 1 : 0;\n else svMap.tabSelected = 1;\n if (sv?.showGridLines === false) svMap.showGridLines = 0;\n if (sv?.showRowColHeaders === false) svMap.showRowColHeaders = 0;\n if (sv?.showZeros === false) svMap.showZeros = 0;\n if (sv?.zoomScale !== undefined) svMap.zoomScale = sv.zoomScale;\n if (sv?.rightToLeft) svMap.rightToLeft = 1;\n return attrs(svMap);\n }\n\n /**\n * Excel legacy password hash (16-bit, little-endian hex).\n * Matches the algorithm used by ECMA-376 Part 1, §18.2.27.\n */\n private hashPassword(password: string): string {\n let hash = 0;\n for (let i = 0; i < password.length; i++) {\n const c = password.charCodeAt(i);\n hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n hash ^= c;\n hash = hash & 0x4000 ? hash ^ 0x1 : hash;\n }\n hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n hash ^= password.length;\n return hash.toString(16).toUpperCase().padStart(4, \"0\");\n }\n\n /**\n * Build the <f> element string for a cell formula.\n */\n private buildFormulaString(fOpts: FormulaOptions): string {\n const fAttrs: Record<string, string | number | boolean | undefined> = {};\n if (fOpts.type && fOpts.type !== FormulaType.NORMAL) fAttrs.t = fOpts.type;\n if (fOpts.reference) fAttrs.ref = fOpts.reference;\n if (fOpts.sharedIndex !== undefined) fAttrs.si = fOpts.sharedIndex;\n\n const hasContent = fOpts.formula !== undefined && fOpts.formula !== \"\";\n\n if (hasContent) {\n return `<f${attrs(fAttrs)}>${escapeXml(fOpts.formula)}</f>`;\n }\n if (Object.keys(fAttrs).length > 0) {\n return selfCloseElement(\"f\", attrs(fAttrs));\n }\n return \"\";\n }\n\n /**\n * Direct string serialization of a single cell — zero intermediate objects.\n */\n private buildCellString(\n ref: string,\n cell: CellOptions,\n sharedStrings?: SharedStrings,\n styles?: Styles,\n ): string {\n const cellAttrs: Record<string, string | number | boolean | undefined> = { r: ref };\n\n // Resolve style\n if (cell.style !== undefined && styles) {\n cellAttrs.s = styles.register(cell.style);\n } else if (cell.styleIndex !== undefined) {\n cellAttrs.s = cell.styleIndex;\n }\n\n const value = cell.value;\n\n // Formula path — formula takes precedence; value is the cached result.\n if (cell.formula) {\n const fStr = this.buildFormulaString(cell.formula);\n let vStr = \"\";\n if (value === null || value === undefined) {\n return `<c${attrs(cellAttrs)}>${fStr}</c>`;\n }\n if (typeof value === \"number\") {\n vStr = `<v>${value}</v>`;\n } else if (typeof value === \"boolean\") {\n cellAttrs.t = \"b\";\n vStr = `<v>${value ? 1 : 0}</v>`;\n } else if (typeof value === \"string\") {\n cellAttrs.t = \"str\";\n vStr = `<v>${escapeXml(value)}</v>`;\n } else if (value instanceof Date) {\n vStr = `<v>${this.dateToSerialNumber(value)}</v>`;\n }\n if (vStr) {\n return `<c${attrs(cellAttrs)}>${fStr}${vStr}</c>`;\n }\n return `<c${attrs(cellAttrs)}>${fStr}</c>`;\n }\n\n if (value === null || value === undefined) {\n if (cell.styleIndex !== undefined) {\n return selfCloseElement(\"c\", attrs(cellAttrs));\n }\n return \"\";\n }\n\n if (typeof value === \"string\") {\n if (sharedStrings) {\n cellAttrs.t = \"s\";\n const idx = sharedStrings.register(value);\n return `<c${attrs(cellAttrs)}><v>${idx}</v></c>`;\n }\n cellAttrs.t = \"inlineStr\";\n return `<c${attrs(cellAttrs)}><is><t>${escapeXml(value)}</t></is></c>`;\n }\n\n if (typeof value === \"number\") {\n return `<c${attrs(cellAttrs)}><v>${value}</v></c>`;\n }\n\n if (typeof value === \"boolean\") {\n cellAttrs.t = \"b\";\n return `<c${attrs(cellAttrs)}><v>${value ? 1 : 0}</v></c>`;\n }\n\n if (value instanceof Date) {\n const serial = this.dateToSerialNumber(value);\n return `<c${attrs(cellAttrs)}><v>${serial}</v></c>`;\n }\n\n return \"\";\n }\n\n private defaultCellRef(row: number, col: number): string {\n return this.columnToLetter(col) + row;\n }\n\n private columnToLetter(col: number): string {\n let result = \"\";\n let n = col;\n while (n > 0) {\n const remainder = (n - 1) % 26;\n result = String.fromCharCode(65 + remainder) + result;\n n = Math.floor((n - 1) / 26);\n }\n return result;\n }\n\n private dateToSerialNumber(date: Date): number {\n const epoch = new Date(1899, 11, 30);\n const msPerDay = 86400000;\n return (date.getTime() - epoch.getTime()) / msPerDay;\n }\n}\n","import { ContentTypes } from \"@file/content-types\";\nimport { CoreProperties, type CorePropertiesOptions } from \"@file/core-properties\";\nimport { Media } from \"@file/media/media\";\nimport { SharedStrings } from \"@file/shared-strings\";\nimport { Styles } from \"@file/styles\";\nimport type { DxfOptions } from \"@file/styles\";\nimport { DefaultTheme } from \"@file/theme\";\nimport { WorkbookXml, type SheetDefinition, type PivotCacheReference } from \"@file/workbook\";\nimport { Worksheet, type WorksheetOptions } from \"@file/worksheet\";\n/**\n * File class (exported as Workbook) — the top-level container for XLSX documents.\n *\n * @module\n */\nimport { AppProperties, ChartCollection, Relationships } from \"@office-open/core\";\n\nexport interface WorkbookOptions extends CorePropertiesOptions {\n readonly worksheets?: readonly WorksheetOptions[];\n /** Pre-defined differential formats for conditional formatting */\n readonly dxfs?: readonly DxfOptions[];\n}\n\nexport class File {\n private readonly worksheetOptions: readonly WorksheetOptions[];\n private readonly corePropsOptions: CorePropertiesOptions;\n private readonly dxfOptions: readonly DxfOptions[];\n\n // Lazy components\n private _coreProperties?: CoreProperties;\n private _appProperties?: AppProperties;\n private _contentTypes?: ContentTypes;\n private _styles?: Styles;\n private _theme?: DefaultTheme;\n private _workbookXml?: WorkbookXml;\n private _worksheets?: Worksheet[];\n private _sharedStrings?: SharedStrings;\n private _media?: Media;\n private _fileRels?: Relationships;\n private _workbookRels?: Relationships;\n private _charts?: ChartCollection;\n private _pivotCacheRefs: PivotCacheReference[] = [];\n\n public constructor(options: WorkbookOptions) {\n this.worksheetOptions = options.worksheets ?? [];\n this.corePropsOptions = options;\n this.dxfOptions = options.dxfs ?? [];\n }\n\n // ── Lazy getters ──\n\n public get coreProperties(): CoreProperties {\n return (this._coreProperties ??= new CoreProperties(this.corePropsOptions));\n }\n\n public get appProperties(): AppProperties {\n return (this._appProperties ??= new AppProperties());\n }\n\n public get contentTypes(): ContentTypes {\n if (!this._contentTypes) {\n this._contentTypes = new ContentTypes();\n for (let i = 0; i < this.worksheetOptions.length; i++) {\n this._contentTypes.addWorksheet(i + 1);\n }\n this._contentTypes.addStyles();\n this._contentTypes.addSharedStrings();\n this._contentTypes.addTheme();\n }\n return this._contentTypes;\n }\n\n public get styles(): Styles {\n return (this._styles ??= new Styles());\n }\n\n /**\n * Register a differential format and return its dxfId.\n * Call this before generating XML to use the ID in conditional formatting rules.\n */\n public registerDxf(opts: DxfOptions): number {\n return this.styles.registerDxf(opts);\n }\n\n public get theme(): DefaultTheme {\n return (this._theme ??= new DefaultTheme());\n }\n\n public get workbookXml(): WorkbookXml {\n if (!this._workbookXml) {\n const sheets: SheetDefinition[] = this.worksheetOptions.map((ws, i) => ({\n name: ws.name ?? `Sheet${i + 1}`,\n sheetId: i + 1,\n rId: `rId${i + 1}`,\n }));\n this._workbookXml = new WorkbookXml(sheets, this._pivotCacheRefs);\n }\n return this._workbookXml;\n }\n\n public get sharedStrings(): SharedStrings {\n return (this._sharedStrings ??= new SharedStrings());\n }\n\n public get media(): Media {\n return (this._media ??= new Media());\n }\n\n public get charts(): ChartCollection {\n return (this._charts ??= new ChartCollection());\n }\n\n public get dxfEntries(): readonly DxfOptions[] {\n return this.dxfOptions;\n }\n\n public get pivotCacheRefs(): readonly PivotCacheReference[] {\n return this._pivotCacheRefs;\n }\n\n public registerPivotCache(cacheId: number, rId: string): void {\n this._pivotCacheRefs.push({ cacheId, rId });\n }\n\n public get worksheetConfigs(): readonly WorksheetOptions[] {\n return this.worksheetOptions;\n }\n\n public get worksheets(): readonly Worksheet[] {\n if (!this._worksheets) {\n this._worksheets = this.worksheetOptions.map((ws) => new Worksheet(ws));\n }\n return this._worksheets;\n }\n\n public get fileRelationships(): Relationships {\n if (!this._fileRels) {\n this._fileRels = new Relationships();\n this._fileRels.addRelationship(\n 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\",\n \"xl/workbook.xml\",\n );\n this._fileRels.addRelationship(\n 2,\n \"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\",\n \"docProps/core.xml\",\n );\n this._fileRels.addRelationship(\n 3,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\",\n \"docProps/app.xml\",\n );\n }\n return this._fileRels;\n }\n\n public get workbookRelationships(): Relationships {\n if (!this._workbookRels) {\n this._workbookRels = new Relationships();\n let rid = 1;\n for (let i = 0; i < this.worksheetOptions.length; i++) {\n this._workbookRels.addRelationship(\n rid++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet\",\n `worksheets/sheet${i + 1}.xml`,\n );\n }\n this._workbookRels.addRelationship(\n rid++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\",\n \"styles.xml\",\n );\n this._workbookRels.addRelationship(\n rid++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\",\n \"theme/theme1.xml\",\n );\n this._workbookRels.addRelationship(\n rid++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings\",\n \"sharedStrings.xml\",\n );\n }\n return this._workbookRels;\n }\n}\n","import { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport { escapeXml } from \"@office-open/xml\";\n\nimport type { CommentOptions } from \"./worksheet\";\n\n/**\n * Generates xl/comments{n}.xml — cell comment data.\n *\n * @module\n */\nexport class Comments extends BaseXmlComponent {\n public constructor(private readonly entries: readonly CommentOptions[]) {\n super(\"comments\");\n }\n\n public override toXml(_context: Context): string {\n const authors = this.collectAuthors();\n const p: string[] = [\n '<comments xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">',\n `<authors>`,\n ];\n\n for (const author of authors) {\n p.push(`<author>${escapeXml(author)}</author>`);\n }\n\n p.push(\"</authors><commentList>\");\n\n for (const entry of this.entries) {\n const authorId = authors.indexOf(entry.author);\n p.push(\n `<comment ref=\"${entry.cell}\" authorId=\"${authorId}\"><text><t>${escapeXml(entry.text)}</t></text></comment>`,\n );\n }\n\n p.push(\"</commentList></comments>\");\n return p.join(\"\");\n }\n\n private collectAuthors(): string[] {\n const seen = new Set<string>();\n const result: string[] = [];\n for (const entry of this.entries) {\n if (!seen.has(entry.author)) {\n seen.add(entry.author);\n result.push(entry.author);\n }\n }\n return result.length > 0 ? result : [\"\"];\n }\n}\n","/**\n * XLSX Drawing component — generates xl/drawings/drawing{n}.xml.\n *\n * Uses the spreadsheetDrawing namespace (default, no prefix) for anchoring\n * images and charts to worksheet cells.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\n\nexport interface ImageOptions {\n /** 1-based column */\n readonly col: number;\n /** Column offset in EMU (default 0) */\n readonly colOffset?: number;\n /** 1-based row */\n readonly row: number;\n /** Row offset in EMU (default 0) */\n readonly rowOffset?: number;\n /** Relationship ID for the image */\n readonly rId: string;\n}\n\nexport interface ChartAnchorOptions {\n /** 1-based column */\n readonly col: number;\n /** Column offset in EMU (default 0) */\n readonly colOffset?: number;\n /** 1-based row */\n readonly row: number;\n /** Row offset in EMU (default 0) */\n readonly rowOffset?: number;\n /** Relationship ID for the chart */\n readonly rId: string;\n}\n\nconst XDR_NS = \"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\";\nconst A_NS = \"http://schemas.openxmlformats.org/drawingml/2006/main\";\nconst R_NS = \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\";\nconst C_URI = \"http://schemas.openxmlformats.org/drawingml/2006/chart\";\n\nexport class Drawing extends BaseXmlComponent {\n private readonly images: readonly ImageOptions[];\n private readonly charts: readonly ChartAnchorOptions[];\n\n public constructor(images: readonly ImageOptions[], charts: readonly ChartAnchorOptions[] = []) {\n super(\"wsDr\");\n this.images = images;\n this.charts = charts;\n }\n\n public override toXml(_context: Context): string {\n const p: string[] = [`<wsDr xmlns=\"${XDR_NS}\" xmlns:a=\"${A_NS}\" xmlns:r=\"${R_NS}\">`];\n let id = 1;\n for (const img of this.images) {\n p.push(\n `<twoCellAnchor editAs=\"oneCell\"><from><col>${img.col - 1}</col><colOff>${img.colOffset ?? 0}</colOff><row>${img.row - 1}</row><rowOff>${img.rowOffset ?? 0}</rowOff></from>`,\n `<to><col>${img.col}</col><colOff>0</colOff><row>${img.row}</row><rowOff>0</rowOff></to>`,\n `<pic><nvPicPr><cNvPr id=\"${id}\" name=\"Picture ${id}\"/><cNvPicPr preferRelativeResize=\"1\"/></nvPicPr>`,\n `<blipFill><a:blip r:embed=\"${img.rId}\"/><a:stretch><a:fillRect/></a:stretch></blipFill>`,\n `<spPr><a:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"400000\" cy=\"300000\"/></a:xfrm><a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom></spPr></pic>`,\n `<clientData/></twoCellAnchor>`,\n );\n id++;\n }\n for (const chart of this.charts) {\n p.push(\n `<twoCellAnchor editAs=\"oneCell\"><from><col>${chart.col - 1}</col><colOff>${chart.colOffset ?? 0}</colOff><row>${chart.row - 1}</row><rowOff>${chart.rowOffset ?? 0}</rowOff></from>`,\n `<to><col>${chart.col + 8}</col><colOff>0</colOff><row>${chart.row + 15}</row><rowOff>0</rowOff></to>`,\n `<graphicFrame><nvGraphicFramePr><cNvPr id=\"${id}\" name=\"Chart ${id}\"/><cNvGraphicFramePr><a:graphicFrameLocks noGrp=\"1\"/></cNvGraphicFramePr></nvGraphicFramePr>`,\n `<xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"0\" cy=\"0\"/></xfrm>`,\n `<a:graphic><a:graphicData uri=\"${C_URI}\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"${R_NS}\" r:id=\"${chart.rId}\"/></a:graphicData></a:graphic></graphicFrame>`,\n `<clientData/></twoCellAnchor>`,\n );\n id++;\n }\n p.push(\"</wsDr>\");\n return p.join(\"\");\n }\n}\n","/**\n * Pivot table utility types and helper functions.\n *\n * @module\n */\n\n/** Aggregation function for data fields (maps to ST_DataConsolidateFunction). */\nexport const ConsolidateFunction = {\n SUM: \"sum\",\n COUNT: \"count\",\n AVERAGE: \"average\",\n MAX: \"max\",\n MIN: \"min\",\n PRODUCT: \"product\",\n COUNT_NUMS: \"countNums\",\n STD_DEV: \"stdDev\",\n STD_DEV_P: \"stdDevp\",\n VAR: \"var\",\n VAR_P: \"varp\",\n} as const;\n\nexport type ConsolidateFunction = (typeof ConsolidateFunction)[keyof typeof ConsolidateFunction];\n\n/** A data field definition for pivot table aggregation. */\nexport interface PivotDataField {\n /** Source column name to aggregate */\n readonly field: string;\n /** Aggregation function (default: \"sum\") */\n readonly summarize?: ConsolidateFunction;\n /** Custom name for the data field (default: \"Sum of {field}\") */\n readonly name?: string;\n}\n\n/** Options for a single pivot table on a worksheet. */\nexport interface PivotTableOptions {\n /** Pivot table name (default: \"PivotTable{N}\") */\n readonly name?: string;\n /** Source data range, e.g. \"A1:D11\" — must be on the same or a different sheet */\n readonly source: string;\n /** Source sheet name (default: current sheet) */\n readonly sourceSheet?: string;\n /** Target cell for the pivot table output (default: \"A3\") */\n readonly location?: string;\n /** Field names to use as row labels */\n readonly rows: readonly string[];\n /** Field names to use as column labels */\n readonly columns?: readonly string[];\n /** Data fields with aggregation settings */\n readonly data: readonly PivotDataField[];\n /** Pivot style name (default: \"PivotStyleLight16\") */\n readonly style?: string;\n}\n\n/** Parsed source data for pivot cache generation. */\nexport interface PivotSourceData {\n readonly fieldNames: readonly string[];\n readonly records: readonly (string | number)[][];\n}\n\n/**\n * Extract unique values from source data for a given field index.\n */\nexport function collectUniqueValues(\n records: readonly (string | number)[][],\n fieldIdx: number,\n): (string | number)[] {\n const seen = new Set<string>();\n const result: (string | number)[] = [];\n for (const row of records) {\n const val = row[fieldIdx];\n const key = String(val);\n if (!seen.has(key)) {\n seen.add(key);\n result.push(val);\n }\n }\n return result;\n}\n\n/**\n * Check if a field is numeric (all non-empty values are numbers).\n */\nexport function isNumericField(records: readonly (string | number)[][], fieldIdx: number): boolean {\n for (const row of records) {\n const val = row[fieldIdx];\n if (typeof val === \"string\" && val !== \"\") return false;\n }\n return true;\n}\n\n/**\n * Aggregate values using the specified function.\n */\nexport function aggregate(values: readonly number[], func: ConsolidateFunction): number {\n if (values.length === 0) return 0;\n switch (func) {\n case \"sum\":\n return values.reduce((a, b) => a + b, 0);\n case \"count\":\n case \"countNums\":\n return values.length;\n case \"average\":\n return values.reduce((a, b) => a + b, 0) / values.length;\n case \"max\":\n return Math.max(...values);\n case \"min\":\n return Math.min(...values);\n case \"product\":\n return values.reduce((a, b) => a * b, 1);\n case \"var\":\n return sampleVariance(values);\n case \"varp\":\n return populationVariance(values);\n case \"stdDev\":\n return Math.sqrt(sampleVariance(values));\n case \"stdDevp\":\n return Math.sqrt(populationVariance(values));\n default:\n return values.reduce((a, b) => a + b, 0);\n }\n}\n\nfunction populationVariance(values: readonly number[]): number {\n const mean = values.reduce((a, b) => a + b, 0) / values.length;\n return values.reduce((sum, v) => sum + (v - mean) ** 2, 0) / values.length;\n}\n\nfunction sampleVariance(values: readonly number[]): number {\n if (values.length < 2) return 0;\n const mean = values.reduce((a, b) => a + b, 0) / values.length;\n return values.reduce((sum, v) => sum + (v - mean) ** 2, 0) / (values.length - 1);\n}\n","/**\n * PivotCacheDefinition XML generator.\n *\n * Generates xl/pivotCache/pivotCacheDefinition{N}.xml.\n * Follows CT_PivotCacheDefinition from sml.xsd.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport { escapeXml } from \"@office-open/xml\";\n\nimport type { PivotSourceData } from \"./pivot-utils\";\nimport { collectUniqueValues, isNumericField } from \"./pivot-utils\";\n\nexport class PivotCacheDefinitionXml extends BaseXmlComponent {\n private readonly sourceRef: string;\n private readonly sourceSheet: string;\n private readonly sourceData: PivotSourceData;\n private readonly recordsRid: string;\n\n public constructor(\n _cacheIdx: number,\n sourceRef: string,\n sourceSheet: string,\n sourceData: PivotSourceData,\n recordsRid: string,\n ) {\n super(\"pivotCacheDefinition\");\n this.sourceRef = sourceRef;\n this.sourceSheet = sourceSheet;\n this.sourceData = sourceData;\n this.recordsRid = recordsRid;\n }\n\n public override toXml(_context: Context): string {\n const p: string[] = [];\n\n p.push(\n '<pivotCacheDefinition xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"' +\n ' xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"' +\n ` r:id=\"${escapeXml(this.recordsRid)}\"` +\n ` recordCount=\"${this.sourceData.records.length}\"` +\n ` createdVersion=\"6\" refreshedVersion=\"6\" minRefreshableVersion=\"3\">`,\n );\n\n // cacheSource\n p.push(\n `<cacheSource type=\"worksheet\">` +\n `<worksheetSource ref=\"${escapeXml(this.sourceRef)}\" sheet=\"${escapeXml(this.sourceSheet)}\"/>` +\n `</cacheSource>`,\n );\n\n // cacheFields\n const fields = this.sourceData.fieldNames;\n p.push(`<cacheFields count=\"${fields.length}\">`);\n\n for (let i = 0; i < fields.length; i++) {\n const fieldName = fields[i];\n const numeric = isNumericField(this.sourceData.records, i);\n const uniqueVals = collectUniqueValues(this.sourceData.records, i);\n\n if (numeric) {\n // Numeric field: sharedItems with type metadata only, no inline values\n let min = Infinity;\n let max = -Infinity;\n for (const row of this.sourceData.records) {\n const v = row[i];\n if (typeof v === \"number\") {\n if (v < min) min = v;\n if (v > max) max = v;\n }\n }\n if (!isFinite(min)) {\n min = 0;\n max = 0;\n }\n const allInteger = this.sourceData.records.every(\n (row) => typeof row[i] === \"number\" && Number.isInteger(row[i]),\n );\n p.push(\n `<cacheField name=\"${escapeXml(fieldName)}\" numFmtId=\"0\">` +\n `<sharedItems containsSemiMixedTypes=\"0\" containsString=\"0\"` +\n ` containsNumber=\"1\" containsInteger=\"${allInteger ? \"1\" : \"0\"}\"` +\n ` minValue=\"${min}\" maxValue=\"${max}\" count=\"${uniqueVals.length}\"/>` +\n `</cacheField>`,\n );\n } else {\n // String/categorical field: list unique values in sharedItems\n p.push(\n `<cacheField name=\"${escapeXml(fieldName)}\" numFmtId=\"0\"><sharedItems count=\"${uniqueVals.length}\">`,\n );\n for (const v of uniqueVals) {\n p.push(`<s v=\"${escapeXml(String(v))}\"/>`);\n }\n p.push(\"</sharedItems></cacheField>\");\n }\n }\n\n p.push(\"</cacheFields>\");\n p.push(\"</pivotCacheDefinition>\");\n\n return p.join(\"\");\n }\n}\n","/**\n * PivotCacheRecords XML generator.\n *\n * Generates xl/pivotCache/pivotCacheRecords{N}.xml.\n * Follows CT_PivotCacheRecords from sml.xsd.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\n\nimport type { PivotSourceData } from \"./pivot-utils\";\nimport { collectUniqueValues, isNumericField } from \"./pivot-utils\";\n\nexport class PivotCacheRecordsXml extends BaseXmlComponent {\n private readonly sourceData: PivotSourceData;\n private readonly numericFields: readonly boolean[];\n /** For string fields: value → sharedItems index */\n private readonly fieldIndexMaps: readonly Map<string, number>[];\n\n public constructor(sourceData: PivotSourceData) {\n super(\"pivotCacheRecords\");\n this.sourceData = sourceData;\n this.numericFields = sourceData.fieldNames.map((_, i) => isNumericField(sourceData.records, i));\n this.fieldIndexMaps = sourceData.fieldNames.map((_, i) => {\n if (this.numericFields[i]) return new Map<string, number>();\n const unique = collectUniqueValues(sourceData.records, i);\n const map = new Map<string, number>();\n for (let j = 0; j < unique.length; j++) {\n map.set(String(unique[j]), j);\n }\n return map;\n });\n }\n\n public override toXml(_context: Context): string {\n const p: string[] = [];\n\n p.push(\n '<pivotCacheRecords xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"' +\n ` count=\"${this.sourceData.records.length}\">`,\n );\n\n for (const row of this.sourceData.records) {\n p.push(\"<r>\");\n for (let i = 0; i < row.length; i++) {\n const val = row[i];\n if (this.numericFields[i]) {\n p.push(`<n v=\"${val}\"/>`);\n } else {\n const idx = this.fieldIndexMaps[i].get(String(val)) ?? 0;\n p.push(`<x v=\"${idx}\"/>`);\n }\n }\n p.push(\"</r>\");\n }\n\n p.push(\"</pivotCacheRecords>\");\n return p.join(\"\");\n }\n}\n","/**\n * PivotTableDefinition XML generator.\n *\n * Generates xl/pivotTables/pivotTable{N}.xml.\n * Follows CT_pivotTableDefinition from sml.xsd.\n *\n * @module\n */\nimport { BaseXmlComponent } from \"@file/xml-components\";\nimport type { Context } from \"@file/xml-components\";\nimport { escapeXml } from \"@office-open/xml\";\n\nimport type { PivotSourceData } from \"./pivot-utils\";\nimport type { PivotTableOptions, PivotDataField } from \"./pivot-utils\";\nimport { collectUniqueValues } from \"./pivot-utils\";\n\nexport class PivotTableXml extends BaseXmlComponent {\n private readonly options: PivotTableOptions;\n private readonly sourceData: PivotSourceData;\n private readonly cacheId: number;\n\n public constructor(options: PivotTableOptions, sourceData: PivotSourceData, cacheId: number) {\n super(\"pivotTableDefinition\");\n this.options = options;\n this.sourceData = sourceData;\n this.cacheId = cacheId;\n }\n\n public override toXml(_context: Context): string {\n const o = this.options;\n const sd = this.sourceData;\n const fields = sd.fieldNames;\n const rowFieldNames = o.rows;\n const colFieldNames = o.columns ?? [];\n const dataFields = o.data;\n const style = o.style ?? \"PivotStyleLight16\";\n const location = o.location ?? \"A3\";\n const name = o.name ?? \"PivotTable1\";\n\n // Compute field indices\n const rowFieldIndices = rowFieldNames.map((n) => fields.indexOf(n));\n const colFieldIndices = colFieldNames.map((n) => fields.indexOf(n));\n const dataFieldIndices = dataFields.map((df) => fields.indexOf(df.field));\n\n // Build pivotFields\n const pivotFieldsXml = this.buildPivotFields(\n rowFieldIndices,\n colFieldIndices,\n dataFieldIndices,\n );\n\n // Build rowFields + rowItems\n const rowFieldsXml = this.buildRowFields(rowFieldIndices);\n const rowItemsXml = this.buildRowItems(rowFieldIndices);\n\n // Build colFields + colItems\n const colFieldsXml = this.buildColFields(colFieldIndices);\n const colItemsXml = this.buildColItems(colFieldIndices, dataFields);\n\n // Build dataFields\n const dataFieldsXml = this.buildDataFields(dataFields, dataFieldIndices);\n\n // Compute location ref\n const locationRef = this.computeLocationRef(\n location,\n rowFieldIndices,\n colFieldIndices,\n dataFields,\n );\n\n const p: string[] = [];\n p.push(\n `<pivotTableDefinition xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"` +\n ` name=\"${escapeXml(name)}\" cacheId=\"${this.cacheId}\"` +\n ` dataCaption=\"Values\" updatedVersion=\"6\" minRefreshableVersion=\"3\" createdVersion=\"6\"` +\n ` applyNumberFormats=\"0\" applyBorderFormats=\"0\" applyFontFormats=\"0\"` +\n ` applyPatternFormats=\"0\" applyAlignmentFormats=\"0\" applyWidthHeightFormats=\"1\"` +\n ` autoFormatId=\"0\" useAutoFormatting=\"1\" itemPrintTitles=\"1\" indent=\"0\"` +\n ` outline=\"1\" outlineData=\"1\" compact=\"1\" compactData=\"1\" rowGrandTotals=\"1\" colGrandTotals=\"1\">`,\n );\n\n // location\n p.push(\n `<location ref=\"${escapeXml(locationRef)}\" firstHeaderRow=\"1\" firstDataRow=\"${colFieldIndices.length + 1}\" firstDataCol=\"${rowFieldIndices.length}\"/>`,\n );\n\n // pivotFields\n p.push(pivotFieldsXml);\n\n // rowFields\n p.push(rowFieldsXml);\n\n // rowItems\n p.push(rowItemsXml);\n\n // colFields (only when column fields exist)\n if (colFieldIndices.length > 0) {\n p.push(colFieldsXml);\n }\n\n // colItems (always present)\n p.push(colItemsXml);\n\n // dataFields\n if (dataFields.length > 0) {\n p.push(dataFieldsXml);\n }\n\n // style\n p.push(\n `<pivotTableStyleInfo name=\"${escapeXml(style)}\" showRowHeaders=\"1\" showColHeaders=\"1\" showRowStripes=\"0\" showColStripes=\"0\" showLastColumn=\"1\"/>`,\n );\n\n p.push(\"</pivotTableDefinition>\");\n return p.join(\"\");\n }\n\n private buildPivotFields(\n rowIndices: readonly number[],\n colIndices: readonly number[],\n dataIndices: readonly number[],\n ): string {\n const fields = this.sourceData.fieldNames;\n const parts: string[] = [`<pivotFields count=\"${fields.length}\">`];\n\n for (let i = 0; i < fields.length; i++) {\n const isRow = rowIndices.includes(i);\n const isCol = colIndices.includes(i);\n const isData = dataIndices.includes(i);\n\n if (isData) {\n parts.push(`<pivotField dataField=\"1\" showAll=\"0\"/>`);\n } else if (isRow) {\n const uniqueVals = collectUniqueValues(this.sourceData.records, i);\n parts.push(`<pivotField axis=\"axisRow\" showAll=\"0\">`);\n parts.push(`<items count=\"${uniqueVals.length + 1}\">`);\n for (let j = 0; j < uniqueVals.length; j++) {\n parts.push(`<item x=\"${j}\"/>`);\n }\n parts.push(`<item t=\"default\"/>`);\n parts.push(\"</items></pivotField>\");\n } else if (isCol) {\n const uniqueVals = collectUniqueValues(this.sourceData.records, i);\n parts.push(`<pivotField axis=\"axisCol\" showAll=\"0\">`);\n parts.push(`<items count=\"${uniqueVals.length + 1}\">`);\n for (let j = 0; j < uniqueVals.length; j++) {\n parts.push(`<item x=\"${j}\"/>`);\n }\n parts.push(`<item t=\"default\"/>`);\n parts.push(\"</items></pivotField>\");\n } else {\n parts.push(`<pivotField showAll=\"0\"/>`);\n }\n }\n\n parts.push(\"</pivotFields>\");\n return parts.join(\"\");\n }\n\n private buildRowFields(rowIndices: readonly number[]): string {\n if (rowIndices.length === 0) return '<rowFields count=\"0\"/>';\n const parts: string[] = [`<rowFields count=\"${rowIndices.length}\">`];\n for (const idx of rowIndices) {\n parts.push(`<field x=\"${idx}\"/>`);\n }\n parts.push(\"</rowFields>\");\n return parts.join(\"\");\n }\n\n private buildRowItems(rowIndices: readonly number[]): string {\n if (rowIndices.length === 0) return '<rowItems count=\"1\"><i/></rowItems>';\n\n const allUniqueCounts: number[] = [];\n for (const idx of rowIndices) {\n const vals = collectUniqueValues(this.sourceData.records, idx);\n allUniqueCounts.push(vals.length);\n }\n\n // Simple case: single row field\n if (rowIndices.length === 1) {\n const count = allUniqueCounts[0];\n const parts: string[] = [`<rowItems count=\"${count + 1}\">`];\n for (let i = 0; i < count; i++) {\n parts.push(`<i><x v=\"${i}\"/></i>`);\n }\n parts.push(`<i t=\"grand\"><x/></i>`);\n parts.push(\"</rowItems>\");\n return parts.join(\"\");\n }\n\n // Multi-field: build cartesian product indices\n const combos = cartesianOfCounts(allUniqueCounts);\n const rowItems: string[] = [];\n for (const combo of combos) {\n const xParts = combo.map((v) => `<x v=\"${v}\"/>`).join(\"\");\n rowItems.push(`<i>${xParts}</i>`);\n }\n // Grand total\n rowItems.push(`<i t=\"grand\">${rowIndices.map(() => \"<x/>\").join(\"\")}</i>`);\n\n return `<rowItems count=\"${rowItems.length}\">${rowItems.join(\"\")}</rowItems>`;\n }\n\n private buildColFields(colIndices: readonly number[]): string {\n if (colIndices.length === 0) return '<colFields count=\"0\"/>';\n const parts: string[] = [`<colFields count=\"${colIndices.length}\">`];\n for (const idx of colIndices) {\n parts.push(`<field x=\"${idx}\"/>`);\n }\n parts.push(\"</colFields>\");\n return parts.join(\"\");\n }\n\n private buildColItems(\n colIndices: readonly number[],\n dataFields: readonly PivotDataField[],\n ): string {\n if (colIndices.length > 0) {\n const allUniqueCounts: number[] = [];\n for (const idx of colIndices) {\n const vals = collectUniqueValues(this.sourceData.records, idx);\n allUniqueCounts.push(vals.length);\n }\n\n const combos = cartesianOfCounts(allUniqueCounts);\n const items: string[] = [];\n for (const combo of combos) {\n const xParts = combo.map((v) => `<x v=\"${v}\"/>`).join(\"\");\n items.push(`<i>${xParts}</i>`);\n }\n items.push(`<i t=\"grand\">${colIndices.map(() => \"<x/>\").join(\"\")}</i>`);\n return `<colItems count=\"${items.length}\">${items.join(\"\")}</colItems>`;\n }\n\n // No column fields: if multiple data fields, each becomes a column\n if (dataFields.length > 1) {\n const items = dataFields.map((_, i) => `<i><x v=\"${i}\"/></i>`);\n return `<colItems count=\"${items.length}\">${items.join(\"\")}</colItems>`;\n }\n\n // Single or no data fields, no column fields\n return '<colItems count=\"1\"><i/></colItems>';\n }\n\n private buildDataFields(\n dataFields: readonly PivotDataField[],\n dataFieldIndices: readonly number[],\n ): string {\n if (dataFields.length === 0) return '<dataFields count=\"0\"/>';\n const parts: string[] = [`<dataFields count=\"${dataFields.length}\">`];\n for (let i = 0; i < dataFields.length; i++) {\n const df = dataFields[i];\n const subtotal = df.summarize ?? \"sum\";\n const name = df.name ?? `${subtotal === \"sum\" ? \"Sum\" : subtotal} of ${df.field}`;\n parts.push(\n `<dataField name=\"${escapeXml(name)}\" fld=\"${dataFieldIndices[i]}\" subtotal=\"${subtotal}\"/>`,\n );\n }\n parts.push(\"</dataFields>\");\n return parts.join(\"\");\n }\n\n private computeLocationRef(\n location: string,\n rowFieldIndices: readonly number[],\n colFieldIndices: readonly number[],\n dataFields: readonly PivotDataField[],\n ): string {\n const startCell = location.split(\":\")[0];\n const match = startCell.match(/^([A-Z]+)(\\d+)$/);\n if (!match) return location;\n\n const startCol = match[1];\n const startRow = parseInt(match[2], 10);\n\n // Count rows: unique row values + header + grand total\n let rowCount = 1; // header\n if (rowFieldIndices.length > 0) {\n rowCount += collectUniqueValues(this.sourceData.records, rowFieldIndices[0]).length;\n }\n rowCount += 1; // grand total\n\n // Count columns: row fields + column values or data fields\n let colCount = Math.max(rowFieldIndices.length, 1);\n if (colFieldIndices.length > 0) {\n colCount += collectUniqueValues(this.sourceData.records, colFieldIndices[0]).length;\n } else if (dataFields.length > 1) {\n colCount += dataFields.length - 1;\n }\n colCount += 1; // grand total column\n\n const endCol = colIndexToLetter(letterToColIndex(startCol) + colCount - 1);\n const endRow = startRow + rowCount - 1;\n\n return `${startCol}${startRow}:${endCol}${endRow}`;\n }\n}\n\nfunction letterToColIndex(letters: string): number {\n let col = 0;\n for (let i = 0; i < letters.length; i++) {\n col = col * 26 + (letters.charCodeAt(i) - 64);\n }\n return col;\n}\n\nfunction colIndexToLetter(col: number): string {\n let result = \"\";\n let n = col;\n while (n > 0) {\n n--;\n result = String.fromCharCode(65 + (n % 26)) + result;\n n = Math.floor(n / 26);\n }\n return result;\n}\n\n/** Cartesian product from counts: e.g. [2, 3] → [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2]] */\nfunction cartesianOfCounts(counts: readonly number[]): number[][] {\n if (counts.length === 0) return [[]];\n let result: number[][] = [[]];\n for (const count of counts) {\n const next: number[][] = [];\n for (const prefix of result) {\n for (let i = 0; i < count; i++) {\n next.push([...prefix, i]);\n }\n }\n result = next;\n }\n return result;\n}\n","/**\n * VML Notes — generates legacy VML drawing for worksheet comments.\n *\n * Excel requires a VML drawing file (xl/drawings/vmlDrawing{N}.vml)\n * referenced by <legacyDrawing r:id=\"...\"/> in the worksheet XML.\n *\n * @module\n */\nimport type { CommentOptions } from \"@file/worksheet\";\n\nexport class VmlNotes {\n public constructor(private readonly comments: readonly CommentOptions[]) {}\n\n public toXml(): string {\n const p: string[] = [\n '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>',\n '<xml xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\">',\n '<o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout>',\n '<v:shapetype id=\"_x0000_t202\" coordsize=\"21600,21600\" o:spt=\"202\" path=\"m,l,21600r21600,l21600,xe\">',\n '<v:stroke joinstyle=\"miter\"/>',\n '<v:path gradientshapeok=\"t\" o:connecttype=\"rect\"/>',\n \"</v:shapetype>\",\n ];\n\n for (let i = 0; i < this.comments.length; i++) {\n const c = this.comments[i];\n const col = c.cell.charCodeAt(0) - 65;\n const row = parseInt(c.cell.slice(1), 10) - 1;\n // 8-value anchor: fromCol, fromColOffset, fromRow, fromRowOffset, toCol, toColOffset, toRow, toRowOffset\n const anchor = `${col}, 0, ${row}, 0, ${col + 2}, 0, ${row + 2}, 0`;\n p.push(\n `<v:shape id=\"_x0000_s${1025 + i}\" type=\"#_x0000_t202\" ` +\n `style=\"position:absolute;margin-left:59.25pt;margin-top:1.5pt;width:108pt;height:59.25pt;` +\n `z-index:1;visibility:hidden\" fillcolor=\"infoBackground [80]\" strokecolor=\"none [81]\" o:insetmode=\"auto\">`,\n `<v:fill color2=\"infoBackground [80]\"/>`,\n `<v:shadow color=\"none [81]\" obscured=\"t\"/>`,\n `<v:path o:connecttype=\"none\"/>`,\n `<v:textbox style=\"mso-direction-alt:auto\"><div style=\"text-align:left\"/></v:textbox>`,\n `<x:ClientData ObjectType=\"Note\"><x:MoveWithCells/><x:SizeWithCells/>`,\n `<x:Anchor>${anchor}</x:Anchor>`,\n `<x:AutoFill>False</x:AutoFill>`,\n `<x:Row>${row}</x:Row>`,\n `<x:Column>${col}</x:Column>`,\n `</x:ClientData>`,\n `</v:shape>`,\n );\n }\n\n p.push(\"</xml>\");\n return p.join(\"\");\n }\n}\n","/**\n * XLSX Compiler — compiles a File object into a Zippable structure.\n *\n * @module\n */\nimport { Formatter } from \"@export/formatter\";\nimport { Comments } from \"@file/comments\";\nimport { Drawing, type ImageOptions, type ChartAnchorOptions } from \"@file/drawing/drawing\";\nimport type { File } from \"@file/file\";\nimport {\n PivotCacheDefinitionXml,\n PivotCacheRecordsXml,\n PivotTableXml,\n aggregate,\n} from \"@file/pivot\";\nimport type { PivotSourceData, PivotTableOptions } from \"@file/pivot\";\nimport { VmlNotes } from \"@file/vml-notes\";\nimport type { BaseXmlComponent, Context } from \"@file/xml-components\";\nimport {\n ChartSpace,\n Relationships,\n compileMapping,\n type XmlifyedFile,\n type Zippable,\n} from \"@office-open/core\";\n\nexport class Compiler {\n private readonly formatter = new Formatter();\n\n public compile(\n file: File,\n overrides: readonly XmlifyedFile[] = [],\n mediaLevel: number = 0,\n ): Zippable {\n const context: Context = { fileData: file, stack: [] };\n const f = this.formatter;\n\n const mapping: Record<string, { data: string; path: string }> = {};\n\n const fmt = (component: BaseXmlComponent) => f.formatToXml(component, context);\n\n // Core properties\n mapping[\"Properties\"] = {\n data: fmt(file.coreProperties),\n path: \"docProps/core.xml\",\n };\n\n // App properties\n mapping[\"AppProperties\"] = {\n data: fmt(file.appProperties),\n path: \"docProps/app.xml\",\n };\n\n // File-level relationships (_rels/.rels)\n mapping[\"FileRelationships\"] = {\n data: fmt(file.fileRelationships),\n path: \"_rels/.rels\",\n };\n\n // Worksheets — formatted BEFORE SharedStrings so strings are registered\n const worksheets = file.worksheets;\n let globalMediaIdx = 0;\n let globalChartIdx = 0;\n let globalPivotIdx = 0;\n let globalPivotCacheIdx = 0;\n const pivotCacheDataMap = new Map<string, { cacheId: number; cacheIdx: number }>();\n\n for (let i = 0; i < worksheets.length; i++) {\n const ws = worksheets[i];\n const imgOpts = ws.imageOptions;\n const chartOpts = ws.charts;\n const hlOpts = ws.hyperlinkOptions;\n const sheetName = file.worksheetConfigs[i]?.name ?? `Sheet${i + 1}`;\n\n // Worksheet uses toXml() fast path (zero-allocation string concat)\n let sheetXml = fmt(ws);\n\n const hasMedia = imgOpts.length > 0 || chartOpts.length > 0;\n const hasExternalHyperlinks = hlOpts.some((h) => h.target.type === \"external\");\n const commentOpts = ws.commentOptions;\n const hasComments = commentOpts.length > 0;\n const pivotOpts = ws.pivotTables;\n const hasPivots = pivotOpts.length > 0;\n\n // Worksheet-level relationships\n let wsRels: Relationships | undefined;\n let nextRid = 0;\n\n if (hasMedia || hasExternalHyperlinks || hasComments || hasPivots) {\n wsRels = new Relationships();\n }\n\n if (hasExternalHyperlinks) {\n for (const hl of hlOpts) {\n if (hl.target.type !== \"external\") continue;\n const rid = ++nextRid;\n wsRels!.addRelationship(\n rid,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\",\n hl.target.url,\n \"External\",\n );\n }\n }\n\n if (hasMedia) {\n const drawingImages: ImageOptions[] = [];\n const drawingCharts: ChartAnchorOptions[] = [];\n const drawingRels = new Relationships();\n let rid = 1;\n\n // Process images\n for (const img of imgOpts) {\n const mediaKey = `image_${globalMediaIdx}`;\n const ext = img.type === \"jpeg\" || img.type === \"jpg\" ? \"jpeg\" : \"png\";\n file.media.addImage(mediaKey, {\n fileName: `image${globalMediaIdx + 1}.${ext}`,\n type: ext,\n data: img.data,\n width: 0,\n height: 0,\n });\n\n drawingRels.addRelationship(\n rid,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\",\n `../media/image${globalMediaIdx + 1}.${ext}`,\n );\n\n drawingImages.push({\n col: img.col,\n row: img.row,\n rId: `rId${rid}`,\n });\n rid++;\n globalMediaIdx++;\n }\n\n // Process charts\n for (const chart of chartOpts) {\n const chartKey = `chart_${globalChartIdx}`;\n file.charts.addChart(chartKey, {\n key: chartKey,\n chartSpace: new ChartSpace(chart),\n });\n\n drawingRels.addRelationship(\n rid,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart\",\n `../charts/chart${globalChartIdx + 1}.xml`,\n );\n\n drawingCharts.push({\n col: chart.col,\n row: chart.row,\n rId: `rId${rid}`,\n });\n rid++;\n globalChartIdx++;\n }\n\n // Generate drawing XML\n const drawing = new Drawing(drawingImages, drawingCharts);\n const drawingIdx = i + 1;\n mapping[`Drawing${i}`] = {\n data: fmt(drawing),\n path: `xl/drawings/drawing${drawingIdx}.xml`,\n };\n\n // Drawing relationships\n mapping[`DrawingRels${i}`] = {\n data: fmt(drawingRels),\n path: `xl/drawings/_rels/drawing${drawingIdx}.xml.rels`,\n };\n\n // Insert drawing reference before the closing </worksheet> tag.\n const drawingRid = ++nextRid;\n const closingTag = \"</worksheet>\";\n sheetXml =\n sheetXml.slice(0, -closingTag.length) + `<drawing r:id=\"rId${drawingRid}\"/>` + closingTag;\n\n // Add drawing relationship to worksheet rels\n wsRels!.addRelationship(\n drawingRid,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing\",\n `../drawings/drawing${drawingIdx}.xml`,\n );\n\n file.contentTypes.addDrawing(drawingIdx);\n }\n\n // Comments\n if (hasComments) {\n const commentsIdx = i + 1;\n\n // Comments XML\n const commentsXml = new Comments(commentOpts);\n mapping[`Comments${i}`] = {\n data: fmt(commentsXml),\n path: `xl/comments${commentsIdx}.xml`,\n };\n\n // VML drawing (required by Excel for legacy comment rendering)\n const vmlNotes = new VmlNotes(commentOpts);\n mapping[`VmlDrawing${i}`] = {\n data: vmlNotes.toXml(),\n path: `xl/drawings/vmlDrawing${commentsIdx}.vml`,\n };\n\n // Worksheet rels: comments → comments XML, legacyDrawing → VML file\n const commentsRid = ++nextRid;\n wsRels!.addRelationship(\n commentsRid,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments\",\n `../comments${commentsIdx}.xml`,\n );\n\n const vmlRid = ++nextRid;\n wsRels!.addRelationship(\n vmlRid,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing\",\n `../drawings/vmlDrawing${commentsIdx}.vml`,\n );\n\n // Insert legacyDrawing reference before closing </worksheet>\n const closingTag = \"</worksheet>\";\n sheetXml =\n sheetXml.slice(0, -closingTag.length) +\n `<legacyDrawing r:id=\"rId${vmlRid}\"/>` +\n closingTag;\n\n // Register content types\n file.contentTypes.addComments(commentsIdx);\n file.contentTypes.addVmlDrawing();\n }\n\n // Pivot tables\n if (hasPivots) {\n for (const pt of pivotOpts) {\n globalPivotIdx++;\n const pivotIdx = globalPivotIdx;\n\n // Extract source data from source sheet\n const sourceSheet = pt.sourceSheet ?? sheetName;\n const sourceWsIdx = file.worksheetConfigs.findIndex(\n (ws) => (ws.name ?? `Sheet${file.worksheetConfigs.indexOf(ws) + 1}`) === sourceSheet,\n );\n if (sourceWsIdx === -1) continue;\n\n const sourceWs = worksheets[sourceWsIdx];\n const sourceData = extractPivotSourceData(sourceWs.worksheetRows, pt.source);\n\n // Deduplicate pivot caches by source reference\n const cacheKey = `${sourceSheet}:${pt.source}`;\n let cacheId: number;\n let cacheIdx: number;\n const existing = pivotCacheDataMap.get(cacheKey);\n if (existing) {\n cacheId = existing.cacheId;\n cacheIdx = existing.cacheIdx;\n } else {\n globalPivotCacheIdx++;\n cacheIdx = globalPivotCacheIdx;\n cacheId = cacheIdx - 1;\n pivotCacheDataMap.set(cacheKey, { cacheId, cacheIdx });\n\n // Generate pivotCacheDefinition\n const cacheDefRels = new Relationships();\n cacheDefRels.addRelationship(\n 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords\",\n \"pivotCacheRecords1.xml\",\n );\n\n const cacheDef = new PivotCacheDefinitionXml(\n cacheIdx,\n pt.source.split(\":\")[0] ? pt.source : \"A1\",\n sourceSheet,\n sourceData,\n \"rId1\",\n );\n\n mapping[`PivotCacheDef${cacheIdx}`] = {\n data: fmt(cacheDef),\n path: `xl/pivotCache/pivotCacheDefinition${cacheIdx}.xml`,\n };\n mapping[`PivotCacheDefRels${cacheIdx}`] = {\n data: fmt(cacheDefRels),\n path: `xl/pivotCache/_rels/pivotCacheDefinition${cacheIdx}.xml.rels`,\n };\n\n // Generate pivotCacheRecords\n const cacheRecords = new PivotCacheRecordsXml(sourceData);\n mapping[`PivotCacheRecords${cacheIdx}`] = {\n data: fmt(cacheRecords),\n path: `xl/pivotCache/pivotCacheRecords${cacheIdx}.xml`,\n };\n\n // Content types\n file.contentTypes.addPivotCacheDefinition(cacheIdx);\n file.contentTypes.addPivotCacheRecords(cacheIdx);\n\n // Register in workbook\n const wbPivotRid = file.workbookRelationships.relationshipCount + 1;\n file.workbookRelationships.addRelationship(\n wbPivotRid,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition\",\n `pivotCache/pivotCacheDefinition${cacheIdx}.xml`,\n );\n file.registerPivotCache(cacheId, `rId${wbPivotRid}`);\n }\n\n // Generate pivotTable\n const pivotTable = new PivotTableXml(pt, sourceData, cacheId);\n mapping[`PivotTable${pivotIdx}`] = {\n data: fmt(pivotTable),\n path: `xl/pivotTables/pivotTable${pivotIdx}.xml`,\n };\n\n // pivotTable rels → cacheDefinition\n const ptRels = new Relationships();\n ptRels.addRelationship(\n 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition\",\n `../pivotCache/pivotCacheDefinition${cacheIdx}.xml`,\n );\n mapping[`PivotTableRels${pivotIdx}`] = {\n data: fmt(ptRels),\n path: `xl/pivotTables/_rels/pivotTable${pivotIdx}.xml.rels`,\n };\n\n // Worksheet rels → pivotTable\n const ptRid = ++nextRid;\n wsRels!.addRelationship(\n ptRid,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable\",\n `../pivotTables/pivotTable${pivotIdx}.xml`,\n );\n\n file.contentTypes.addPivotTable(pivotIdx);\n }\n }\n\n // Pre-render pivot table data into sheetData\n if (hasPivots) {\n const rendered = renderPivotSheetData(\n pivotOpts,\n worksheets,\n file.sharedStrings,\n file.worksheetConfigs,\n sheetName,\n );\n if (rendered.sheetData.length > 0) {\n // Replace empty <sheetData/> or <sheetData></sheetData> with rendered data\n sheetXml = sheetXml.replace(/<sheetData\\/>|<sheetData><\\/sheetData>/, rendered.sheetData);\n // Inject <dimension> before <sheetViews> (XSD sequence order: dimension before sheetViews)\n if (!sheetXml.includes(\"<dimension\")) {\n sheetXml = sheetXml.replace(\n \"<sheetViews\",\n `<dimension ref=\"${rendered.dimensionRef}\"/><sheetViews`,\n );\n }\n }\n }\n\n // Write worksheet rels if needed\n if (wsRels) {\n mapping[`WorksheetRels${i}`] = {\n data: fmt(wsRels),\n path: `xl/worksheets/_rels/sheet${i + 1}.xml.rels`,\n };\n }\n\n mapping[`Worksheet${i}`] = {\n data: sheetXml,\n path: `xl/worksheets/sheet${i + 1}.xml`,\n };\n }\n\n // Workbook XML\n mapping[\"Workbook\"] = {\n data: fmt(file.workbookXml),\n path: \"xl/workbook.xml\",\n };\n\n // Workbook relationships\n mapping[\"WorkbookRelationships\"] = {\n data: fmt(file.workbookRelationships),\n path: \"xl/_rels/workbook.xml.rels\",\n };\n\n // Shared Strings — AFTER worksheets so all strings are collected\n const sharedStrings = file.sharedStrings;\n if (sharedStrings.count > 0) {\n mapping[\"SharedStrings\"] = {\n data: fmt(sharedStrings),\n path: \"xl/sharedStrings.xml\",\n };\n }\n\n // Register predefined DXFs before styles XML is generated\n for (const dxf of file.dxfEntries) {\n file.registerDxf(dxf);\n }\n\n // Styles\n mapping[\"Styles\"] = {\n data: fmt(file.styles),\n path: \"xl/styles.xml\",\n };\n\n // Theme\n mapping[\"Theme\"] = {\n data: fmt(file.theme),\n path: \"xl/theme/theme1.xml\",\n };\n\n // Charts — AFTER worksheets so charts are registered\n for (let i = 0; i < file.charts.array.length; i++) {\n const chartData = file.charts.array[i];\n mapping[`Chart${i}`] = {\n data: fmt(chartData.chartSpace),\n path: `xl/charts/chart${i + 1}.xml`,\n };\n file.contentTypes.addChart(i + 1);\n }\n\n // Register image content types\n const imageExts = new Set<string>();\n for (const img of file.media.array) {\n const ext = img.fileName.endsWith(\".png\") ? \"png\" : \"jpeg\";\n if (!imageExts.has(ext)) {\n imageExts.add(ext);\n file.contentTypes.addImageType(ext as \"png\" | \"jpeg\");\n }\n }\n\n // Content Types — must be last\n mapping[\"ContentTypes\"] = {\n data: fmt(file.contentTypes),\n path: \"[Content_Types].xml\",\n };\n\n // Convert mapping to Zippable\n const mediaFiles: Array<{ data: Uint8Array; path: string }> = [];\n for (const img of file.media.array) {\n mediaFiles.push({ data: img.data, path: `xl/media/${img.fileName}` });\n }\n\n return compileMapping(mapping, overrides, mediaFiles, mediaLevel);\n }\n}\n\n/**\n * Extract source data from worksheet rows for pivot cache generation.\n */\nfunction extractPivotSourceData(\n rows: readonly import(\"@file/worksheet\").RowOptions[],\n sourceRef: string,\n): PivotSourceData {\n // Parse source range like \"A1:D11\"\n const parts = sourceRef.split(\":\");\n const startMatch = parts[0]?.match(/^([A-Z]+)(\\d+)$/);\n const endMatch = parts[1]?.match(/^([A-Z]+)(\\d+)$/);\n if (!startMatch) {\n return { fieldNames: [], records: [] };\n }\n\n const startRow = parseInt(startMatch[2], 10) - 1;\n const endRow = endMatch ? parseInt(endMatch[2], 10) - 1 : startRow;\n const startCol = colLetterToIndex(startMatch[1]);\n const endCol = endMatch ? colLetterToIndex(endMatch[1]) : startCol;\n const colCount = endCol - startCol + 1;\n\n // First row is headers\n const headerRow = rows[startRow];\n const fieldNames: string[] = [];\n if (headerRow?.cells) {\n for (let c = startCol; c <= endCol && c < headerRow.cells.length; c++) {\n fieldNames.push(String(headerRow.cells[c]?.value ?? `Col${c}`));\n }\n }\n\n // Remaining rows are data\n const records: (string | number)[][] = [];\n for (let r = startRow + 1; r <= endRow; r++) {\n const row = rows[r];\n if (!row?.cells) continue;\n const record: (string | number)[] = [];\n for (let c = startCol; c <= endCol; c++) {\n const val = row.cells[c]?.value;\n if (typeof val === \"number\") {\n record.push(val);\n } else if (val instanceof Date) {\n record.push(val.getTime());\n } else {\n record.push(String(val ?? \"\"));\n }\n }\n if (record.length === colCount) {\n records.push(record);\n }\n }\n\n return { fieldNames, records };\n}\n\nfunction colLetterToIndex(letters: string): number {\n let col = 0;\n for (let i = 0; i < letters.length; i++) {\n col = col * 26 + (letters.charCodeAt(i) - 64);\n }\n return col - 1;\n}\n\n/**\n * Pre-render pivot table output as sheetData cells.\n * Excel requires this so the pivot table is visible on open without manual refresh.\n */\nfunction renderPivotSheetData(\n pivotOpts: readonly PivotTableOptions[],\n worksheets: readonly import(\"@file/worksheet\").Worksheet[],\n sharedStrings: import(\"@file/shared-strings\").SharedStrings,\n worksheetConfigs: readonly import(\"@file/worksheet\").WorksheetOptions[],\n currentSheetName: string,\n): { sheetData: string; dimensionRef: string } {\n // Collect cells by row number to merge cells from different pivot tables on the same row\n const rowCells = new Map<number, string[]>();\n let maxRow = 0;\n let maxCol = 0;\n let minRow = Infinity;\n let minCol = Infinity;\n\n for (const pt of pivotOpts) {\n const location = pt.location ?? \"A3\";\n const locMatch = location.match(/^([A-Z]+)(\\d+)$/);\n if (!locMatch) continue;\n\n const startCol = colLetterToIndex(locMatch[1]);\n const startRow = parseInt(locMatch[2], 10);\n const rowFieldNames = pt.rows;\n const dataFields = pt.data;\n\n const sourceSheetName = pt.sourceSheet ?? currentSheetName;\n const sourceWsIdx = worksheetConfigs.findIndex(\n (ws) => (ws.name ?? `Sheet${worksheetConfigs.indexOf(ws) + 1}`) === sourceSheetName,\n );\n if (sourceWsIdx === -1) continue;\n\n const sourceRows = worksheets[sourceWsIdx]?.worksheetRows ?? [];\n const sourceData = extractPivotSourceData(sourceRows, pt.source);\n if (sourceData.fieldNames.length === 0) continue;\n\n const fields = sourceData.fieldNames;\n const rowFieldIndices = rowFieldNames.map((n) => fields.indexOf(n));\n const dataFieldIndices = dataFields.map((df) => fields.indexOf(df.field));\n\n if (rowFieldIndices.some((idx) => idx === -1)) continue;\n if (dataFieldIndices.some((idx) => idx === -1)) continue;\n\n // Group records by row field values\n const groupMap = new Map<string, { keys: (string | number)[]; values: number[][] }>();\n for (const record of sourceData.records) {\n const groupKey = rowFieldIndices.map((fi) => String(record[fi])).join(\"|\");\n let group = groupMap.get(groupKey);\n if (!group) {\n group = {\n keys: rowFieldIndices.map((fi) => record[fi]),\n values: dataFieldIndices.map(() => []),\n };\n groupMap.set(groupKey, group);\n }\n for (let di = 0; di < dataFieldIndices.length; di++) {\n const val = record[dataFieldIndices[di]];\n if (typeof val === \"number\") {\n group.values[di].push(val);\n }\n }\n }\n\n const endCol = startCol + rowFieldNames.length + dataFields.length - 1;\n minCol = Math.min(minCol, startCol);\n maxCol = Math.max(maxCol, endCol);\n\n // Helper to add cells to a row\n const addCells = (rowIdx: number, cells: string[]) => {\n let arr = rowCells.get(rowIdx);\n if (!arr) {\n arr = [];\n rowCells.set(rowIdx, arr);\n }\n arr.push(...cells);\n minRow = Math.min(minRow, rowIdx);\n maxRow = Math.max(maxRow, rowIdx);\n };\n\n // Header row\n const headerCells: string[] = [];\n for (const rfName of rowFieldNames) {\n const cellRef = colIndexToLetterCompiler(startCol + headerCells.length) + startRow;\n const strIdx = sharedStrings.register(rfName);\n headerCells.push(`<c r=\"${cellRef}\" t=\"s\"><v>${strIdx}</v></c>`);\n }\n for (const df of dataFields) {\n const cellRef = colIndexToLetterCompiler(startCol + headerCells.length) + startRow;\n const subtotal = df.summarize ?? \"sum\";\n const dfName = df.name ?? `${subtotal === \"sum\" ? \"Sum\" : subtotal} of ${df.field}`;\n const strIdx = sharedStrings.register(dfName);\n headerCells.push(`<c r=\"${cellRef}\" t=\"s\"><v>${strIdx}</v></c>`);\n }\n addCells(startRow, headerCells);\n\n // Data rows\n let currentRow = startRow + 1;\n for (const [, group] of groupMap) {\n const cells: string[] = [];\n for (let ri = 0; ri < group.keys.length; ri++) {\n const cellRef = colIndexToLetterCompiler(startCol + ri) + currentRow;\n const strIdx = sharedStrings.register(String(group.keys[ri]));\n cells.push(`<c r=\"${cellRef}\" t=\"s\"><v>${strIdx}</v></c>`);\n }\n for (let di = 0; di < dataFields.length; di++) {\n const colOffset = rowFieldNames.length + di;\n const cellRef = colIndexToLetterCompiler(startCol + colOffset) + currentRow;\n const subtotal = dataFields[di].summarize ?? \"sum\";\n const result = aggregate(group.values[di], subtotal);\n cells.push(`<c r=\"${cellRef}\"><v>${result}</v></c>`);\n }\n addCells(currentRow, cells);\n currentRow++;\n }\n\n // Grand total row\n const gtCells: string[] = [];\n const gtStrIdx = sharedStrings.register(\"Grand Total\");\n gtCells.push(\n `<c r=\"${colIndexToLetterCompiler(startCol)}${currentRow}\" t=\"s\"><v>${gtStrIdx}</v></c>`,\n );\n for (let di = 0; di < dataFields.length; di++) {\n const colOffset = rowFieldNames.length + di;\n const cellRef = colIndexToLetterCompiler(startCol + colOffset) + currentRow;\n const subtotal = dataFields[di].summarize ?? \"sum\";\n const allValues = sourceData.records\n .map((r) => r[dataFieldIndices[di]])\n .filter((v): v is number => typeof v === \"number\");\n const result = aggregate(allValues, subtotal);\n gtCells.push(`<c r=\"${cellRef}\"><v>${result}</v></c>`);\n }\n addCells(currentRow, gtCells);\n }\n\n if (rowCells.size === 0) return { sheetData: \"\", dimensionRef: \"\" };\n\n // Build sheetData — rows must be sorted by row number\n const parts: string[] = [\"<sheetData>\"];\n const sortedRows = [...rowCells.entries()].sort((a, b) => a[0] - b[0]);\n for (const [rowIdx, cells] of sortedRows) {\n parts.push(`<row r=\"${rowIdx}\" x14ac:dyDescent=\"0.25\">`);\n parts.push(...cells);\n parts.push(\"</row>\");\n }\n parts.push(\"</sheetData>\");\n\n const dimStartCol = colIndexToLetterCompiler(minCol === Infinity ? 0 : minCol);\n const dimStartRow = minRow === Infinity ? 1 : minRow;\n const dimensionRef = `${dimStartCol}${dimStartRow}:${colIndexToLetterCompiler(maxCol)}${maxRow}`;\n return { sheetData: parts.join(\"\"), dimensionRef };\n}\n\nfunction colIndexToLetterCompiler(col: number): string {\n let result = \"\";\n let n = col + 1; // 0-indexed to 1-indexed\n while (n > 0) {\n n--;\n result = String.fromCharCode(65 + (n % 26)) + result;\n n = Math.floor(n / 26);\n }\n return result;\n}\n","import type { File } from \"@file/file\";\n/**\n * Packer module — export API for XLSX files.\n *\n * @module\n */\nimport { createPacker, OoxmlMimeType } from \"@office-open/core\";\n\nimport { Compiler } from \"./next-compiler\";\n\nconst compiler = new Compiler();\n\nexport const Packer = createPacker<File>({\n compile: (file, overrides, mediaLevel) => compiler.compile(file, overrides, mediaLevel),\n mimeType: OoxmlMimeType.XLSX,\n});\n","/**\n * Convert a 1-based column number to Excel column letter(s).\n * 1 → \"A\", 26 → \"Z\", 27 → \"AA\", 28 → \"AB\"\n */\nexport function columnToLetter(col: number): string {\n let result = \"\";\n let n = col;\n while (n > 0) {\n const remainder = (n - 1) % 26;\n result = String.fromCharCode(65 + remainder) + result;\n n = Math.floor((n - 1) / 26);\n }\n return result;\n}\n\n/**\n * Convert Excel column letter(s) to a 1-based column number.\n * \"A\" → 1, \"Z\" → 26, \"AA\" → 27\n */\nexport function letterToColumn(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n result = result * 26 + (s.charCodeAt(i) - 64);\n }\n return result;\n}\n\n/**\n * Convert a JavaScript Date to an Excel serial number.\n * Excel epoch: January 1, 1900 = 1 (with the 1900 leap year bug).\n */\nexport function dateToSerialNumber(date: Date): number {\n // Excel treats 1900 as a leap year (bug inherited from Lotus 1-2-3).\n // The epoch is effectively December 30, 1899 = 0.\n const epoch = new Date(1899, 11, 30);\n const msPerDay = 86400000;\n const diff = date.getTime() - epoch.getTime();\n return diff / msPerDay;\n}\n","/**\n * XLSX parsing — parse .xlsx files into structured data.\n *\n * @module\n */\nimport { parseArchive, parseCorePropsElement } from \"@office-open/core\";\nimport type { ParsedArchive } from \"@office-open/core\";\nimport type { Element } from \"@office-open/xml\";\nimport { attr, attrNum, findChild, textOf } from \"@office-open/xml\";\nimport { toUint8Array } from \"undio\";\nimport type { DataType } from \"undio\";\n\nimport type { WorkbookOptions } from \"./file/file\";\nimport type {\n WorksheetOptions,\n RowOptions,\n CellOptions,\n ColumnOptions,\n MergeCellOptions,\n} from \"./file/worksheet\";\nimport { letterToColumn } from \"./util\";\n\nexport { parseArchive };\n\n// ── Low-level parse result ──\n\nexport interface XlsxPartRefs {\n worksheets: string[];\n charts: string[];\n media: string[];\n drawings: string[];\n}\n\nexport interface XlsxDocument {\n doc: ParsedArchive;\n /** xl/workbook.xml root element */\n workbook?: Element;\n /** Worksheet paths (xl/worksheets/sheet{n}.xml) */\n worksheets: string[];\n /** xl/styles.xml root element */\n styles?: Element;\n /** xl/sharedStrings.xml root element */\n sharedStrings?: Element;\n partRefs: XlsxPartRefs;\n /** docProps/core.xml path */\n coreProps?: string;\n /** docProps/app.xml path */\n appProps?: string;\n}\n\nfunction sortByNumber(paths: string[]): string[] {\n return paths.sort((a, b) => {\n const numA = parseInt(a.match(/(\\d+)/)?.[1] ?? \"0\", 10);\n const numB = parseInt(b.match(/(\\d+)/)?.[1] ?? \"0\", 10);\n return numA - numB;\n });\n}\n\n/**\n * Parse raw .xlsx data into a low-level XlsxDocument.\n */\nexport function parseXlsx(data: DataType): XlsxDocument {\n const uint8 = toUint8Array(data);\n const doc = parseArchive(uint8);\n\n const workbook = doc.get(\"xl/workbook.xml\");\n const styles = doc.get(\"xl/styles.xml\");\n const sharedStrings = doc.get(\"xl/sharedStrings.xml\");\n\n // Resolve worksheet paths from workbook rels\n const worksheets: string[] = [];\n const charts: string[] = [];\n const drawings: string[] = [];\n const media: string[] = [];\n\n const wbRels = doc.get(\"xl/_rels/workbook.xml.rels\");\n if (wbRels) {\n for (const child of wbRels.elements ?? []) {\n if (child.name !== \"Relationship\") continue;\n const type = attr(child, \"Type\") ?? \"\";\n const target = attr(child, \"Target\") ?? \"\";\n if (!target) continue;\n\n if (type.includes(\"/worksheet\")) {\n worksheets.push(target.startsWith(\"/\") ? target.slice(1) : `xl/${target}`);\n }\n }\n }\n sortByNumber(worksheets);\n\n // Scan for drawings, charts, media\n drawings.push(...doc.keys(\"xl/drawings/\").filter((k) => k.endsWith(\".xml\")));\n charts.push(...doc.keys(\"xl/charts/\").filter((k) => k.endsWith(\".xml\")));\n media.push(...doc.keys(\"xl/media/\"));\n sortByNumber(drawings);\n sortByNumber(charts);\n\n // Root rels → core/app props\n let coreProps: string | undefined;\n let appProps: string | undefined;\n const rootRels = doc.get(\"_rels/.rels\");\n if (rootRels) {\n for (const child of rootRels.elements ?? []) {\n if (child.name !== \"Relationship\") continue;\n const type = attr(child, \"Type\") ?? \"\";\n const target = attr(child, \"Target\") ?? \"\";\n if (type.includes(\"/core-properties\")) coreProps = target;\n else if (type.includes(\"/extended-properties\")) appProps = target;\n }\n }\n\n return {\n doc,\n workbook,\n worksheets,\n styles,\n sharedStrings,\n partRefs: { worksheets, charts, media, drawings },\n coreProps,\n appProps,\n };\n}\n\n// ── Shared strings helper ──\n\nfunction parseSharedStrings(el: Element | undefined): string[] {\n if (!el) return [];\n const strings: string[] = [];\n for (const si of el.elements ?? []) {\n if (si.name !== \"si\") continue;\n // Handle both <si><t>text</t></si> and <si><r><t>text</t></r>...</si>\n const t = findChild(si, \"t\");\n if (t) {\n strings.push(textOf(t) ?? \"\");\n } else {\n // Rich text: concatenate all <r><t> segments\n const parts: string[] = [];\n for (const r of si.elements ?? []) {\n if (r.name !== \"r\") continue;\n const rt = findChild(r, \"t\");\n if (rt) parts.push(textOf(rt) ?? \"\");\n }\n strings.push(parts.join(\"\"));\n }\n }\n return strings;\n}\n\n// ── Cell reference helpers ──\n\nfunction colFromRef(ref: string): number {\n const match = ref.match(/^([A-Z]+)/);\n return match ? letterToColumn(match[1]) : 1;\n}\n\nfunction rowFromRef(ref: string): number {\n const match = ref.match(/(\\d+)$/);\n return match ? parseInt(match[1], 10) : 1;\n}\n\n// ── Worksheet parsing ──\n\nfunction parseWorksheetElement(wsEl: Element, strings: string[]): WorksheetOptions {\n const opts: Record<string, unknown> = {};\n\n // Sheet name from the parent workbook's sheet element (not available here)\n // Caller should set it\n\n // Columns\n // Elements might be prefixed or unprefixed depending on how the XML parser handles default namespaces.\n const colsEl = findChild(wsEl, \"cols\") ?? findChildByLocalName(wsEl, \"cols\");\n if (colsEl) {\n const columns: ColumnOptions[] = [];\n for (const col of colsEl.elements ?? []) {\n if (localName(col) !== \"col\") continue;\n const min = attrNum(col, \"min\");\n const max = attrNum(col, \"max\");\n if (min === undefined || max === undefined) continue;\n const colOpts: Record<string, unknown> = { min, max };\n const width = attrNum(col, \"width\");\n if (width !== undefined) colOpts.width = width;\n if (attr(col, \"hidden\") === \"1\") colOpts.hidden = true;\n columns.push(colOpts as unknown as ColumnOptions);\n }\n if (columns.length > 0) opts.columns = columns;\n }\n\n // Freeze panes\n const sheetViews = findChildByLocalName(wsEl, \"sheetViews\");\n if (sheetViews) {\n const sheetView = findChildByLocalName(sheetViews, \"sheetView\");\n if (sheetView) {\n const pane = findChildByLocalName(sheetView, \"pane\");\n if (pane) {\n const state = attr(pane, \"state\");\n if (state === \"frozen\") {\n const freezePanes: Record<string, unknown> = {};\n const ySplit = attrNum(pane, \"ySplit\");\n const xSplit = attrNum(pane, \"xSplit\");\n if (ySplit && ySplit > 0) freezePanes.row = ySplit;\n if (xSplit && xSplit > 0) freezePanes.col = xSplit;\n if (Object.keys(freezePanes).length > 0) opts.freezePanes = freezePanes;\n }\n }\n }\n }\n\n // Sheet data (rows)\n const sheetData = findChildByLocalName(wsEl, \"sheetData\");\n const rows: RowOptions[] = [];\n if (sheetData) {\n for (const rowEl of sheetData.elements ?? []) {\n if (localName(rowEl) !== \"row\") continue;\n const rowNumber = attrNum(rowEl, \"r\");\n const rowOpts: Record<string, unknown> = {};\n if (rowNumber !== undefined) rowOpts.rowNumber = rowNumber;\n\n const ht = attrNum(rowEl, \"ht\");\n if (ht !== undefined) rowOpts.height = ht;\n if (attr(rowEl, \"hidden\") === \"1\") rowOpts.hidden = true;\n\n const cells: CellOptions[] = [];\n for (const cellEl of rowEl.elements ?? []) {\n if (localName(cellEl) !== \"c\") continue;\n const ref = attr(cellEl, \"r\");\n const type = attr(cellEl, \"t\");\n const cellOpts: Record<string, unknown> = {};\n if (ref) cellOpts.reference = ref;\n\n const styleIdx = attrNum(cellEl, \"s\");\n if (styleIdx !== undefined) cellOpts.styleIndex = styleIdx;\n\n // Cell value\n const vEl = findChildByLocalName(cellEl, \"v\");\n const isEl = findChildByLocalName(cellEl, \"is\");\n\n if (type === \"s\" && vEl) {\n // Shared string\n const idx = parseInt(textOf(vEl) ?? \"\", 10);\n cellOpts.value = strings[idx] ?? \"\";\n } else if (type === \"b\" && vEl) {\n cellOpts.value = textOf(vEl) === \"1\";\n } else if (type === \"inlineStr\" && isEl) {\n const t = findChildByLocalName(isEl, \"t\");\n cellOpts.value = textOf(t) ?? \"\";\n } else if (vEl) {\n const raw = textOf(vEl) ?? \"\";\n const num = Number(raw);\n cellOpts.value = isNaN(num) ? raw : num;\n }\n\n cells.push(cellOpts as CellOptions);\n }\n\n rowOpts.cells = cells;\n rows.push(rowOpts as RowOptions);\n }\n }\n opts.rows = rows;\n\n // Merge cells\n const mergeCellsEl = findChildByLocalName(wsEl, \"mergeCells\");\n if (mergeCellsEl) {\n const mergeCells: MergeCellOptions[] = [];\n for (const mc of mergeCellsEl.elements ?? []) {\n if (localName(mc) !== \"mergeCell\") continue;\n const ref = attr(mc, \"ref\");\n if (!ref) continue;\n const parts = ref.split(\":\");\n if (parts.length === 2) {\n mergeCells.push({\n from: { row: rowFromRef(parts[0]), col: colFromRef(parts[0]) },\n to: { row: rowFromRef(parts[1]), col: colFromRef(parts[1]) },\n });\n }\n }\n if (mergeCells.length > 0) opts.mergeCells = mergeCells;\n }\n\n // Auto filter\n const autoFilterEl = findChildByLocalName(wsEl, \"autoFilter\");\n if (autoFilterEl) {\n const ref = attr(autoFilterEl, \"ref\");\n if (ref) opts.autoFilter = ref;\n }\n\n return opts as WorksheetOptions;\n}\n\n// ── Helpers ──\n\nfunction localName(el: Element): string {\n const name = el.name ?? \"\";\n const colonIdx = name.indexOf(\":\");\n return colonIdx >= 0 ? name.slice(colonIdx + 1) : name;\n}\n\nfunction findChildByLocalName(parent: Element, name: string): Element | undefined {\n return (parent.elements ?? []).find((el) => localName(el) === name);\n}\n\n/**\n * Parse a .xlsx file and convert it into WorkbookOptions.\n *\n * The returned options can be passed to `new Workbook(parsed)`.\n */\nexport function parseWorkbook(data: DataType): WorkbookOptions {\n const xlsx = parseXlsx(data);\n\n const opts: Record<string, unknown> = {};\n\n // Core properties\n if (xlsx.coreProps) {\n const corePropsEl = xlsx.doc.get(xlsx.coreProps);\n if (corePropsEl) {\n const cp = parseCorePropsElement(corePropsEl);\n if (cp.title) opts.title = cp.title;\n if (cp.subject) opts.subject = cp.subject;\n if (cp.creator) opts.creator = cp.creator;\n if (cp.keywords) opts.keywords = cp.keywords;\n if (cp.description) opts.description = cp.description;\n if (cp.lastModifiedBy) opts.lastModifiedBy = cp.lastModifiedBy;\n if (cp.revision) opts.revision = parseInt(cp.revision, 10);\n }\n }\n\n // Shared strings\n const strings = parseSharedStrings(xlsx.sharedStrings);\n\n // Sheet names from workbook\n const sheetNames: string[] = [];\n if (xlsx.workbook) {\n const sheetsEl = findChildByLocalName(xlsx.workbook, \"sheets\");\n if (sheetsEl) {\n for (const s of sheetsEl.elements ?? []) {\n if (localName(s) !== \"sheet\") continue;\n sheetNames.push(attr(s, \"name\") ?? \"\");\n }\n }\n }\n\n // Parse worksheets\n const worksheets: WorksheetOptions[] = [];\n for (let i = 0; i < xlsx.worksheets.length; i++) {\n const wsPath = xlsx.worksheets[i];\n const wsEl = xlsx.doc.get(wsPath);\n if (!wsEl) continue;\n\n const wsOpts = parseWorksheetElement(wsEl, strings) as Record<string, unknown>;\n if (sheetNames[i]) wsOpts.name = sheetNames[i];\n worksheets.push(wsOpts as WorksheetOptions);\n }\n\n opts.worksheets = worksheets;\n return opts as WorkbookOptions;\n}\n","/**\n * XLSX patching — replace placeholders in existing .xlsx files.\n *\n * Unlike DOCX/PPTX (paragraph-based), XLSX patching targets cell values:\n * - Replaces placeholders in the shared strings table (most common)\n * - Replaces placeholders in inline strings within worksheet cells\n *\n * @module\n */\nimport { OoxmlMimeType, unzipSync, zipAndConvert, strFromU8, toJson } from \"@office-open/core\";\nimport type { OutputByType, OutputType } from \"@office-open/core\";\nimport { js2xml } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { toUint8Array } from \"undio\";\n\n/** Reusable TextEncoder (stateless, safe to share). */\nconst encoder = new TextEncoder();\n\nexport type InputDataType = Buffer | string | number[] | Uint8Array | ArrayBuffer | Blob;\n\nexport type PatchDocumentOutputType = OutputType;\n\nexport const PatchType = {\n CELL: \"cell\",\n} as const;\n\nexport interface CellPatch {\n /** Replacement value (string, number, boolean, or Date) */\n readonly value: string | number | boolean | Date;\n}\n\nexport type IPatch = CellPatch;\n\nexport interface PatchWorkbookOptions<T extends PatchDocumentOutputType = PatchDocumentOutputType> {\n readonly outputType: T;\n readonly data: InputDataType;\n readonly patches: Readonly<Record<string, IPatch>>;\n readonly placeholderDelimiters?: Readonly<{\n readonly start: string;\n readonly end: string;\n }>;\n}\n\n/**\n * Patch an existing .xlsx workbook by replacing placeholder text in cells.\n *\n * Placeholders are matched in shared strings and inline strings.\n * For string replacements, the shared string value is updated in-place.\n * For non-string replacements, the cell type and value are updated.\n */\nexport const patchWorkbook = async <T extends PatchDocumentOutputType = PatchDocumentOutputType>({\n outputType,\n data,\n patches,\n placeholderDelimiters = { start: \"{{\", end: \"}}\" } as const,\n}: PatchWorkbookOptions<T>): Promise<OutputByType[T]> => {\n const zipContent = unzipSync(toUint8Array(data));\n\n const xmlMap = new Map<string, Element>();\n const binaryMap = new Map<string, Uint8Array>();\n\n // Separate XML files from binary files\n for (const [key, value] of Object.entries(zipContent)) {\n if (key.endsWith(\".xml\") || key.endsWith(\".rels\")) {\n xmlMap.set(key, toJson(strFromU8(value)));\n } else {\n binaryMap.set(key, value);\n }\n }\n\n const { start, end } = placeholderDelimiters;\n\n // Build placeholder → patch map\n const patchMap = new Map<string, IPatch>();\n for (const [key, patch] of Object.entries(patches)) {\n patchMap.set(`${start}${key}${end}`, patch);\n }\n\n // 1. Patch shared strings\n const sst = xmlMap.get(\"xl/sharedStrings.xml\");\n if (sst) {\n patchSharedStrings(sst, patchMap);\n }\n\n // 2. Patch inline strings in worksheets\n const worksheetKeys = Object.keys(zipContent).filter(\n (k) => k.startsWith(\"xl/worksheets/sheet\") && k.endsWith(\".xml\"),\n );\n for (const wsKey of worksheetKeys) {\n const ws = xmlMap.get(wsKey);\n if (ws) patchWorksheetInlineStrings(ws, patchMap);\n }\n\n // Rebuild ZIP\n const files: Record<string, Uint8Array> = {};\n for (const [key, value] of xmlMap) {\n files[key] = encoder.encode(js2xml(value));\n }\n for (const [key, value] of binaryMap) {\n files[key] = value;\n }\n\n return await zipAndConvert(files, outputType, OoxmlMimeType.XLSX);\n};\n\nfunction patchSharedStrings(sst: Element, patchMap: Map<string, IPatch>): void {\n // toJson returns {elements: [{name: \"sst\", ...}]} — unwrap to actual root\n const root = sst.name ? sst : sst.elements?.[0];\n if (!root) return;\n\n for (const si of root.elements ?? []) {\n if (si.name !== \"si\") continue;\n\n // Simple: <si><t>text</t></si>\n const t = findLocalChild(si, \"t\");\n if (t) {\n patchTextElement(t, patchMap);\n } else {\n // Rich text: <si><r><t>text</t></r>...</si>\n for (const r of si.elements ?? []) {\n if (r.name !== \"r\") continue;\n const rt = findLocalChild(r, \"t\");\n if (rt) patchTextElement(rt, patchMap);\n }\n }\n }\n}\n\nfunction patchWorksheetInlineStrings(ws: Element, patchMap: Map<string, IPatch>): void {\n const root = ws.name ? ws : ws.elements?.[0];\n if (!root) return;\n\n const sheetData = findLocalChild(root, \"sheetData\");\n if (!sheetData) return;\n\n for (const row of sheetData.elements ?? []) {\n if (localName(row) !== \"row\") continue;\n for (const cell of row.elements ?? []) {\n if (localName(cell) !== \"c\") continue;\n\n // Check inline strings: <c t=\"inlineStr\"><is><t>text</t></is></c>\n const isEl = findLocalChild(cell, \"is\");\n if (isEl) {\n const t = findLocalChild(isEl, \"t\");\n if (t) patchTextElement(t, patchMap);\n }\n }\n }\n}\n\nfunction patchTextElement(tEl: Element, patchMap: Map<string, IPatch>): void {\n const text = tEl.elements?.[0]?.text;\n if (typeof text !== \"string\") return;\n\n for (const [placeholder, patch] of patchMap) {\n if (text.includes(placeholder)) {\n const newValue = String(patch.value);\n const replaced = text.replace(placeholder, newValue);\n if (tEl.elements) {\n tEl.elements[0] = { ...tEl.elements[0], text: replaced };\n }\n }\n }\n}\n\nfunction localName(el: Element): string {\n const name = el.name ?? \"\";\n const colonIdx = name.indexOf(\":\");\n return colonIdx >= 0 ? name.slice(colonIdx + 1) : name;\n}\n\nfunction findLocalChild(parent: Element, name: string): Element | undefined {\n return (parent.elements ?? []).find((el) => localName(el) === name);\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,YAAY;AAClB,MAAM,iBAAiB;AACvB,MAAM,cAAc;AACpB,MAAM,sBACJ;AACF,MAAM,aAAa;AACnB,MAAM,aAAa;AA+BnB,MAAM,aAAa;CApBjB;EACE,MAAM;EACN,aAAa;EACb,KAAK;CACP;CACA;EAAE,MAAM;EAAW,aAAa;EAAmB,KAAK;CAAM;CAC9D;EAAE,MAAM;EAAY,aAAa;EAAW,KAAK;CAAmB;CACpE;EACE,MAAM;EACN,aAAa;EACb,KAAK;CACP;CACA;EACE,MAAM;EACN,aAAa;EACb,KAAK;CACP;AAI8B,EAAE,KAAK,MACrC,EAAE,SAAS,YACP,yBAAyB,EAAE,YAAY,eAAe,EAAE,IAAI,OAC5D,0BAA0B,EAAE,YAAY,cAAc,EAAE,IAAI,IAClE,EAAE,KAAK,EAAE;AAET,IAAa,eAAb,cAAkC,iBAAiB;CACjD,iBAAkD,CAAC;CAEnD,cAAqB;EACnB,MA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