@rowsncolumns/toolkit 24.4.2 → 24.4.4

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.
Files changed (166) hide show
  1. package/dist/cjs/excel-parser/cfb-decryptor.d.ts +6 -0
  2. package/dist/cjs/excel-parser/cfb-decryptor.d.ts.map +1 -1
  3. package/dist/cjs/excel-parser/cfb-decryptor.js +6 -0
  4. package/dist/cjs/excel-parser/helpers.d.ts +9 -1
  5. package/dist/cjs/excel-parser/helpers.d.ts.map +1 -1
  6. package/dist/cjs/excel-parser/helpers.js +37 -0
  7. package/dist/cjs/excel-parser/interface.d.ts +15 -2
  8. package/dist/cjs/excel-parser/interface.d.ts.map +1 -1
  9. package/dist/cjs/excel-parser/plugins/base/index.d.ts +2 -0
  10. package/dist/cjs/excel-parser/plugins/base/index.d.ts.map +1 -1
  11. package/dist/cjs/excel-parser/plugins/base/index.js +3 -0
  12. package/dist/cjs/excel-parser/plugins/ods/index.d.ts +19 -0
  13. package/dist/cjs/excel-parser/plugins/ods/index.d.ts.map +1 -1
  14. package/dist/cjs/excel-parser/plugins/ods/index.js +676 -304
  15. package/dist/cjs/excel-parser/plugins/ods/styles.d.ts +43 -1
  16. package/dist/cjs/excel-parser/plugins/ods/styles.d.ts.map +1 -1
  17. package/dist/cjs/excel-parser/plugins/ods/styles.js +343 -45
  18. package/dist/cjs/excel-parser/plugins/xls/index.d.ts +55 -1
  19. package/dist/cjs/excel-parser/plugins/xls/index.d.ts.map +1 -1
  20. package/dist/cjs/excel-parser/plugins/xls/index.js +518 -6
  21. package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts +4 -0
  22. package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
  23. package/dist/cjs/excel-parser/plugins/xlsb/index.js +33 -14
  24. package/dist/cjs/excel-parser/plugins/xlsx/chartex.d.ts +37 -0
  25. package/dist/cjs/excel-parser/plugins/xlsx/chartex.d.ts.map +1 -0
  26. package/dist/cjs/excel-parser/plugins/xlsx/chartex.js +244 -0
  27. package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts +10 -0
  28. package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
  29. package/dist/cjs/excel-parser/plugins/xlsx/charts.js +68 -9
  30. package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts +28 -1
  31. package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
  32. package/dist/cjs/excel-parser/plugins/xlsx/drawing.js +155 -20
  33. package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts +70 -0
  34. package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -0
  35. package/dist/cjs/excel-parser/plugins/xlsx/form-controls.js +295 -0
  36. package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +35 -2
  37. package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
  38. package/dist/cjs/excel-parser/plugins/xlsx/index.js +737 -257
  39. package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
  40. package/dist/cjs/excel-parser/plugins/xlsx/pivots.js +125 -37
  41. package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.d.ts +3 -0
  42. package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.d.ts.map +1 -1
  43. package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.js +4 -1
  44. package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts +15 -1
  45. package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
  46. package/dist/cjs/excel-parser/plugins/xlsx/styles.js +102 -6
  47. package/dist/cjs/excel-parser/registry.d.ts +7 -0
  48. package/dist/cjs/excel-parser/registry.d.ts.map +1 -1
  49. package/dist/cjs/excel-parser/registry.js +29 -0
  50. package/dist/cjs/excel-parser/types.d.ts +17 -2
  51. package/dist/cjs/excel-parser/types.d.ts.map +1 -1
  52. package/dist/cjs/excel-parser/workbook.d.ts +3 -0
  53. package/dist/cjs/excel-parser/workbook.d.ts.map +1 -1
  54. package/dist/cjs/excel-parser/workbook.js +24 -14
  55. package/dist/cjs/excel-parser/worker.js +131 -131
  56. package/dist/cjs/exporter/ods/ods-export.d.ts.map +1 -1
  57. package/dist/cjs/exporter/ods/ods-export.js +432 -175
  58. package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -1
  59. package/dist/cjs/exporter/xlsx/chart-builder.js +215 -39
  60. package/dist/cjs/exporter/xlsx/chartex-builder.d.ts +36 -0
  61. package/dist/cjs/exporter/xlsx/chartex-builder.d.ts.map +1 -0
  62. package/dist/cjs/exporter/xlsx/chartex-builder.js +109 -0
  63. package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts +61 -0
  64. package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts.map +1 -0
  65. package/dist/cjs/exporter/xlsx/form-controls-builder.js +197 -0
  66. package/dist/cjs/exporter/xlsx/pivot-builder.d.ts +8 -0
  67. package/dist/cjs/exporter/xlsx/pivot-builder.d.ts.map +1 -1
  68. package/dist/cjs/exporter/xlsx/pivot-builder.js +141 -42
  69. package/dist/cjs/exporter/xlsx/style-builder.js +9 -3
  70. package/dist/cjs/exporter/xlsx/threaded-comments-builder.d.ts +7 -1
  71. package/dist/cjs/exporter/xlsx/threaded-comments-builder.d.ts.map +1 -1
  72. package/dist/cjs/exporter/xlsx/threaded-comments-builder.js +15 -3
  73. package/dist/cjs/exporter/xlsx/xlsx-export.d.ts +11 -2
  74. package/dist/cjs/exporter/xlsx/xlsx-export.d.ts.map +1 -1
  75. package/dist/cjs/exporter/xlsx/xlsx-export.js +991 -297
  76. package/dist/cjs/helpers/implicit-intersection.d.ts +16 -0
  77. package/dist/cjs/helpers/implicit-intersection.d.ts.map +1 -0
  78. package/dist/cjs/helpers/implicit-intersection.js +197 -0
  79. package/dist/cjs/print-settings.d.ts +105 -0
  80. package/dist/cjs/print-settings.d.ts.map +1 -0
  81. package/dist/cjs/print-settings.js +494 -0
  82. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  83. package/dist/esm/excel-parser/cfb-decryptor.d.ts +6 -0
  84. package/dist/esm/excel-parser/cfb-decryptor.d.ts.map +1 -1
  85. package/dist/esm/excel-parser/cfb-decryptor.js +6 -0
  86. package/dist/esm/excel-parser/helpers.d.ts +9 -1
  87. package/dist/esm/excel-parser/helpers.d.ts.map +1 -1
  88. package/dist/esm/excel-parser/helpers.js +34 -0
  89. package/dist/esm/excel-parser/interface.d.ts +15 -2
  90. package/dist/esm/excel-parser/interface.d.ts.map +1 -1
  91. package/dist/esm/excel-parser/plugins/base/index.d.ts +2 -0
  92. package/dist/esm/excel-parser/plugins/base/index.d.ts.map +1 -1
  93. package/dist/esm/excel-parser/plugins/base/index.js +3 -0
  94. package/dist/esm/excel-parser/plugins/ods/index.d.ts +19 -0
  95. package/dist/esm/excel-parser/plugins/ods/index.d.ts.map +1 -1
  96. package/dist/esm/excel-parser/plugins/ods/index.js +347 -33
  97. package/dist/esm/excel-parser/plugins/ods/styles.d.ts +43 -1
  98. package/dist/esm/excel-parser/plugins/ods/styles.d.ts.map +1 -1
  99. package/dist/esm/excel-parser/plugins/ods/styles.js +276 -2
  100. package/dist/esm/excel-parser/plugins/xls/index.d.ts +55 -1
  101. package/dist/esm/excel-parser/plugins/xls/index.d.ts.map +1 -1
  102. package/dist/esm/excel-parser/plugins/xls/index.js +441 -3
  103. package/dist/esm/excel-parser/plugins/xlsb/index.d.ts +4 -0
  104. package/dist/esm/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
  105. package/dist/esm/excel-parser/plugins/xlsb/index.js +30 -9
  106. package/dist/esm/excel-parser/plugins/xlsx/chartex.d.ts +37 -0
  107. package/dist/esm/excel-parser/plugins/xlsx/chartex.d.ts.map +1 -0
  108. package/dist/esm/excel-parser/plugins/xlsx/chartex.js +199 -0
  109. package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts +10 -0
  110. package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
  111. package/dist/esm/excel-parser/plugins/xlsx/charts.js +69 -6
  112. package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts +28 -1
  113. package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
  114. package/dist/esm/excel-parser/plugins/xlsx/drawing.js +99 -0
  115. package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts +70 -0
  116. package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -0
  117. package/dist/esm/excel-parser/plugins/xlsx/form-controls.js +246 -0
  118. package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +35 -2
  119. package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
  120. package/dist/esm/excel-parser/plugins/xlsx/index.js +454 -32
  121. package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
  122. package/dist/esm/excel-parser/plugins/xlsx/pivots.js +86 -6
  123. package/dist/esm/excel-parser/plugins/xlsx/sheet-views.d.ts +3 -0
  124. package/dist/esm/excel-parser/plugins/xlsx/sheet-views.d.ts.map +1 -1
  125. package/dist/esm/excel-parser/plugins/xlsx/sheet-views.js +2 -0
  126. package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts +15 -1
  127. package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
  128. package/dist/esm/excel-parser/plugins/xlsx/styles.js +92 -2
  129. package/dist/esm/excel-parser/registry.d.ts +7 -0
  130. package/dist/esm/excel-parser/registry.d.ts.map +1 -1
  131. package/dist/esm/excel-parser/registry.js +19 -0
  132. package/dist/esm/excel-parser/types.d.ts +17 -2
  133. package/dist/esm/excel-parser/types.d.ts.map +1 -1
  134. package/dist/esm/excel-parser/workbook.d.ts +3 -0
  135. package/dist/esm/excel-parser/workbook.d.ts.map +1 -1
  136. package/dist/esm/excel-parser/workbook.js +19 -10
  137. package/dist/esm/excel-parser/worker.js +12 -18
  138. package/dist/esm/exporter/ods/ods-export.d.ts.map +1 -1
  139. package/dist/esm/exporter/ods/ods-export.js +306 -35
  140. package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -1
  141. package/dist/esm/exporter/xlsx/chart-builder.js +161 -28
  142. package/dist/esm/exporter/xlsx/chartex-builder.d.ts +36 -0
  143. package/dist/esm/exporter/xlsx/chartex-builder.d.ts.map +1 -0
  144. package/dist/esm/exporter/xlsx/chartex-builder.js +97 -0
  145. package/dist/esm/exporter/xlsx/form-controls-builder.d.ts +61 -0
  146. package/dist/esm/exporter/xlsx/form-controls-builder.d.ts.map +1 -0
  147. package/dist/esm/exporter/xlsx/form-controls-builder.js +173 -0
  148. package/dist/esm/exporter/xlsx/pivot-builder.d.ts +8 -0
  149. package/dist/esm/exporter/xlsx/pivot-builder.d.ts.map +1 -1
  150. package/dist/esm/exporter/xlsx/pivot-builder.js +104 -19
  151. package/dist/esm/exporter/xlsx/style-builder.js +9 -3
  152. package/dist/esm/exporter/xlsx/threaded-comments-builder.d.ts +7 -1
  153. package/dist/esm/exporter/xlsx/threaded-comments-builder.d.ts.map +1 -1
  154. package/dist/esm/exporter/xlsx/threaded-comments-builder.js +15 -3
  155. package/dist/esm/exporter/xlsx/xlsx-export.d.ts +11 -2
  156. package/dist/esm/exporter/xlsx/xlsx-export.d.ts.map +1 -1
  157. package/dist/esm/exporter/xlsx/xlsx-export.js +675 -64
  158. package/dist/esm/helpers/implicit-intersection.d.ts +16 -0
  159. package/dist/esm/helpers/implicit-intersection.d.ts.map +1 -0
  160. package/dist/esm/helpers/implicit-intersection.js +184 -0
  161. package/dist/esm/print-settings.d.ts +105 -0
  162. package/dist/esm/print-settings.d.ts.map +1 -0
  163. package/dist/esm/print-settings.js +422 -0
  164. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  165. package/package.json +3 -3
  166. package/xlsx.d.ts +14 -0
@@ -0,0 +1,197 @@
1
+ import { __read, __rest } from "tslib";
2
+ /**
3
+ * Excel form-control writers — the inverse of
4
+ * `excel-parser/plugins/xlsx/form-controls.ts`. A control is three parts:
5
+ * the worksheet `<controls><control>` entry (anchor + `<controlPr>`), its
6
+ * `xl/ctrlProps/ctrlPropN.xml` (`<formControlPr>`), and the legacy VML shape
7
+ * Excel actually draws (`<v:shape type="#_x0000_t201"><x:ClientData
8
+ * ObjectType="Checkbox">`). All three are written; Excel drops a control
9
+ * whose VML shape is missing.
10
+ */
11
+ export var CTRL_PROP_CONTENT_TYPE = "application/vnd.ms-excel.controlproperties+xml";
12
+ export var CTRL_PROP_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp";
13
+ export var FORM_CONTROL_NS = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
14
+ var MC_NS = "http://schemas.openxmlformats.org/markup-compatibility/2006";
15
+ var XDR_NS = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing";
16
+ var XML_DECLARATION = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
17
+ var escapeAttr = function (value) {
18
+ return value
19
+ .replace(/&/g, "&amp;")
20
+ .replace(/</g, "&lt;")
21
+ .replace(/>/g, "&gt;")
22
+ .replace(/"/g, "&quot;");
23
+ };
24
+ var escapeText = function (value) {
25
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
26
+ };
27
+ var attrsXml = function (attrs) {
28
+ return Object.entries(attrs !== null && attrs !== void 0 ? attrs : {})
29
+ .filter(function (_a) {
30
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
31
+ return key && value != null;
32
+ })
33
+ .map(function (_a) {
34
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
35
+ return " ".concat(key, "=\"").concat(escapeAttr(String(value)), "\"");
36
+ })
37
+ .join("");
38
+ };
39
+ /** `xl/ctrlProps/ctrlPropN.xml` body. */
40
+ export var buildCtrlPropXml = function (spec) {
41
+ var _a, _b;
42
+ var _c = (_a = spec.properties) !== null && _a !== void 0 ? _a : {}, _ignored = _c.objectType, rest = __rest(_c, ["objectType"]);
43
+ var items = ((_b = spec.listItems) !== null && _b !== void 0 ? _b : [])
44
+ .map(function (item) { return "<item val=\"".concat(escapeAttr(item), "\"/>"); })
45
+ .join("");
46
+ var body = items ? "<itemLst>".concat(items, "</itemLst>") : "";
47
+ var open = "<formControlPr xmlns=\"".concat(FORM_CONTROL_NS, "\" objectType=\"").concat(escapeAttr(spec.objectType), "\"").concat(attrsXml(rest));
48
+ return "".concat(XML_DECLARATION).concat(body ? "".concat(open, ">").concat(body, "</formControlPr>") : "".concat(open, "/>"));
49
+ };
50
+ var cellAnchorXml = function (tag, anchor) {
51
+ return "<".concat(tag, "><xdr:col>").concat(anchor.col, "</xdr:col><xdr:colOff>").concat(Math.round(anchor.colOff), "</xdr:colOff><xdr:row>").concat(anchor.row, "</xdr:row><xdr:rowOff>").concat(Math.round(anchor.rowOff), "</xdr:rowOff></").concat(tag, ">");
52
+ };
53
+ /** One `<control>` element (inside the `<controls>` wrapper). */
54
+ export var buildControlElementXml = function (_a) {
55
+ var _b;
56
+ var spec = _a.spec, relId = _a.relId, shapeId = _a.shapeId, from = _a.from, to = _a.to;
57
+ var name = (_b = spec.name) !== null && _b !== void 0 ? _b : "".concat(spec.objectType, " ").concat(shapeId);
58
+ var anchorAttrs = (spec.moveWithCells ? ' moveWithCells="1"' : "") +
59
+ (spec.sizeWithCells ? ' sizeWithCells="1"' : "");
60
+ return "<control shapeId=\"".concat(shapeId, "\" r:id=\"").concat(relId, "\" name=\"").concat(escapeAttr(name), "\"><controlPr").concat(attrsXml(spec.controlProperties), "><anchor").concat(anchorAttrs, ">").concat(cellAnchorXml("from", from)).concat(cellAnchorXml("to", to), "</anchor></controlPr></control>");
61
+ };
62
+ /**
63
+ * The worksheet `<controls>` element. Excel wraps controls in an
64
+ * `mc:AlternateContent` whose `Choice` requires the `x14` namespace; the
65
+ * namespaces the wrapper and the `xdr:` anchor cells need are declared on
66
+ * the element so the worksheet root stays untouched.
67
+ */
68
+ export var buildControlsXml = function (controlElements) {
69
+ if (!controlElements.length)
70
+ return "";
71
+ return "<controls xmlns:mc=\"".concat(MC_NS, "\" xmlns:xdr=\"").concat(XDR_NS, "\" xmlns:x14=\"").concat(FORM_CONTROL_NS, "\"><mc:AlternateContent><mc:Choice Requires=\"x14\">").concat(controlElements.join(""), "</mc:Choice></mc:AlternateContent></controls>");
72
+ };
73
+ /** `formControlPr/@objectType` → VML `x:ClientData/@ObjectType`. */
74
+ var VML_OBJECT_TYPE = {
75
+ CheckBox: "Checkbox",
76
+ EditBox: "Edit",
77
+ };
78
+ var truthy = function (value) {
79
+ return value === "1" || value === "true";
80
+ };
81
+ /**
82
+ * `x:ClientData` children derived from the `formControlPr` / `controlPr`
83
+ * attributes — Excel reads the control's state (checked, linked cell, list
84
+ * range, selection, scroll values) from the VML, the ctrlProp part is the
85
+ * x14 mirror.
86
+ */
87
+ var clientDataChildrenXml = function (spec) {
88
+ var _a, _b;
89
+ var p = (_a = spec.properties) !== null && _a !== void 0 ? _a : {};
90
+ var c = (_b = spec.controlProperties) !== null && _b !== void 0 ? _b : {};
91
+ var out = [];
92
+ var push = function (tag, value) {
93
+ if (value === undefined)
94
+ out.push("<x:".concat(tag, "/>"));
95
+ else
96
+ out.push("<x:".concat(tag, ">").concat(escapeText(value), "</x:").concat(tag, ">"));
97
+ };
98
+ if (spec.moveWithCells)
99
+ push("MoveWithCells");
100
+ if (spec.sizeWithCells)
101
+ push("SizeWithCells");
102
+ // Anchor is inserted by the caller (needs sheet geometry).
103
+ out.push("__ANCHOR__");
104
+ if (c.locked === "0")
105
+ push("Locked", "False");
106
+ if (c.defaultSize === "0")
107
+ push("DefaultSize", "False");
108
+ if (c.print === "0")
109
+ push("PrintObject", "False");
110
+ if (c.autoFill === "0")
111
+ push("AutoFill", "False");
112
+ if (c.autoLine === "0")
113
+ push("AutoLine", "False");
114
+ if (c.autoPict === "0")
115
+ push("AutoPict", "False");
116
+ if (c.macro)
117
+ push("FmlaMacro", c.macro);
118
+ if (p.textHAlign)
119
+ push("TextHAlign", p.textHAlign);
120
+ if (p.textVAlign)
121
+ push("TextVAlign", p.textVAlign);
122
+ if (truthy(p.lockText))
123
+ push("LockText");
124
+ if (truthy(p.justLastX))
125
+ push("JustLastX");
126
+ if (truthy(p.passwordEdit))
127
+ push("SecretEdit");
128
+ if (truthy(p.multiLine))
129
+ push("MultiLine");
130
+ if (truthy(p.verticalBar))
131
+ push("VScroll");
132
+ if (p.fmlaRange)
133
+ push("FmlaRange", p.fmlaRange);
134
+ if (p.widthMin)
135
+ push("WidthMin", p.widthMin);
136
+ if (p.sel)
137
+ push("Sel", p.sel);
138
+ if (p.seltype)
139
+ push("SelType", p.seltype);
140
+ if (p.multiSel)
141
+ push("MultiSel", p.multiSel);
142
+ if (p.dropStyle)
143
+ push("DropStyle", p.dropStyle);
144
+ if (truthy(p.colored))
145
+ push("Colored");
146
+ if (p.dropLines)
147
+ push("DropLines", p.dropLines);
148
+ if (p.checked === "Checked")
149
+ push("Checked", "1");
150
+ else if (p.checked === "Mixed")
151
+ push("Checked", "2");
152
+ if (p.fmlaLink)
153
+ push("FmlaLink", p.fmlaLink);
154
+ if (truthy(p.noThreeD))
155
+ push("NoThreeD");
156
+ if (truthy(p.firstButton))
157
+ push("FirstButton");
158
+ if (p.fmlaGroup)
159
+ push("FmlaGroup", p.fmlaGroup);
160
+ if (p.val)
161
+ push("Val", p.val);
162
+ if (p.min)
163
+ push("Min", p.min);
164
+ if (p.max)
165
+ push("Max", p.max);
166
+ if (p.inc)
167
+ push("Inc", p.inc);
168
+ if (p.page)
169
+ push("Page", p.page);
170
+ if (truthy(p.horiz))
171
+ push("Horiz");
172
+ if (p.dx)
173
+ push("Dx", p.dx);
174
+ return out.join("");
175
+ };
176
+ /** VML `<v:shapetype>` every form control references (`#_x0000_t201`). */
177
+ export var FORM_CONTROL_VML_SHAPETYPE = "<v:shapetype id=\"_x0000_t201\" coordsize=\"21600,21600\" o:spt=\"201\" path=\"m,l,21600r21600,l21600,xe\"><v:stroke joinstyle=\"miter\"/><v:path shadowok=\"f\" o:extrusionok=\"f\" strokeok=\"f\" fillok=\"f\" o:connecttype=\"rect\"/><o:lock v:ext=\"edit\" shapetype=\"t\"/></v:shapetype>";
178
+ var toPt = function (px) { return "".concat((px * 0.75).toFixed(2).replace(/\.?0+$/, ""), "pt"); };
179
+ /** One `<v:shape>` drawing a form control. */
180
+ export var buildFormControlVmlShape = function (_a) {
181
+ var _b;
182
+ var spec = _a.spec, shapeId = _a.shapeId, zIndex = _a.zIndex, geometry = _a.geometry;
183
+ var objectType = (_b = VML_OBJECT_TYPE[spec.objectType]) !== null && _b !== void 0 ? _b : spec.objectType;
184
+ var caption = spec.text
185
+ ? "<div style=\"text-align:left\"><font face=\"Tahoma\" size=\"160\" color=\"auto\">".concat(escapeText(spec.text), "</font></div>")
186
+ : "";
187
+ var clientData = clientDataChildrenXml(spec).replace("__ANCHOR__", "<x:Anchor>".concat(geometry.anchor.join(", "), "</x:Anchor>"));
188
+ var style = "position:absolute;margin-left:".concat(toPt(geometry.leftPx), ";margin-top:").concat(toPt(geometry.topPx), ";width:").concat(toPt(geometry.widthPx), ";height:").concat(toPt(geometry.heightPx), ";z-index:").concat(zIndex, ";mso-wrap-style:tight");
189
+ return "<v:shape id=\"_x0000_s".concat(shapeId, "\" type=\"#_x0000_t201\" style=\"").concat(style, "\" filled=\"f\" fillcolor=\"window [65]\" stroked=\"f\" strokecolor=\"windowText [64]\" o:insetmode=\"auto\"><v:path shadowok=\"f\" o:extrusionok=\"f\" strokeok=\"f\" fillok=\"f\" o:connecttype=\"rect\"/><v:textbox style=\"mso-direction-alt:auto\" o:singleclick=\"f\">").concat(caption, "</v:textbox><x:ClientData ObjectType=\"").concat(escapeAttr(objectType), "\">").concat(clientData, "</x:ClientData></v:shape>");
190
+ };
191
+ /** Wrap note + control shapes into one `vmlDrawing` part. */
192
+ export var buildVmlDrawingXml = function (_a) {
193
+ var shapeTypes = _a.shapeTypes, shapes = _a.shapes;
194
+ if (!shapes.length)
195
+ return undefined;
196
+ return "<xml xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\"><o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout>".concat(shapeTypes.join("")).concat(shapes.join(""), "</xml>");
197
+ };
@@ -26,6 +26,14 @@
26
26
  * + ~100 lines in xlsx-export.ts) is the closest reference template.
27
27
  */
28
28
  import type { PivotTable } from "@rowsncolumns/spreadsheet";
29
+ /**
30
+ * Distinct source fields a calculated-field formula references —
31
+ * single-quoted names (`'Unit Price'`, `''` escapes a quote) or bare
32
+ * identifiers; numeric literals (incl. `1e5`) and operators are skipped.
33
+ * Mirrors `@rowsncolumns/pivot`'s tokenizer without pulling in the
34
+ * DuckDB-backed pivot package.
35
+ */
36
+ export declare const calculatedFieldReferences: (formula: string) => string[];
29
37
  /**
30
38
  * Build pivotCacheDefinition XML for a pivot. The cacheSource
31
39
  * points at the live worksheet range; `refreshOnLoad="1"` makes
@@ -1 +1 @@
1
- {"version":3,"file":"pivot-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/pivot-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AA4D5D;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GACvC,OAAO,UAAU,EACjB,WAAW,MAAM,EACjB,YAAY,MAAM,EAAE,KACnB,MAAM,GAAG,IAgCX,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,UAAU,EACjB,SAAS,MAAM,EACf,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAChC,MAAM,GAAG,IAkHX,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,MAAM,EAChB,aAAa,MAAM,KAClB,MAcF,CAAC"}
1
+ {"version":3,"file":"pivot-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/pivot-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,2BAA2B,CAAC;AAqBxE;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,MAAM,KAAG,MAAM,EAYjE,CAAC;AA2DF;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GACvC,OAAO,UAAU,EACjB,WAAW,MAAM,EACjB,YAAY,MAAM,EAAE,KACnB,MAAM,GAAG,IAuCX,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,UAAU,EACjB,SAAS,MAAM,EACf,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAChC,MAAM,GAAG,IA2JX,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,MAAM,EAChB,aAAa,MAAM,KAClB,MAcF,CAAC"}
@@ -1,5 +1,55 @@
1
1
  import { __read, __spreadArray, __values } from "tslib";
2
2
  import { XMLBuilder } from "fast-xml-parser";
3
+ /**
4
+ * `PivotValue.showAs` → `dataField@showDataAs` (ECMA-376) or, for the
5
+ * rank modes Excel only knows through its 2010 extension,
6
+ * `x14:dataField@pivotShowAs`.
7
+ */
8
+ var SHOW_DATA_AS = {
9
+ pct_of_total: "percentOfTotal",
10
+ pct_of_row: "percentOfRow",
11
+ pct_of_column: "percentOfCol",
12
+ running_total: "runTotal",
13
+ };
14
+ var X14_PIVOT_SHOW_AS = {
15
+ rank_asc: "rankAscending",
16
+ rank_desc: "rankDescending",
17
+ };
18
+ var X14_DATA_FIELD_EXT_URI = "{E15A36E0-9728-4e99-A89B-3F7291B0FE68}";
19
+ var X14_NS = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
20
+ /**
21
+ * Distinct source fields a calculated-field formula references —
22
+ * single-quoted names (`'Unit Price'`, `''` escapes a quote) or bare
23
+ * identifiers; numeric literals (incl. `1e5`) and operators are skipped.
24
+ * Mirrors `@rowsncolumns/pivot`'s tokenizer without pulling in the
25
+ * DuckDB-backed pivot package.
26
+ */
27
+ export var calculatedFieldReferences = function (formula) {
28
+ var e_1, _a;
29
+ var out = [];
30
+ var push = function (name) {
31
+ if (name && !out.includes(name))
32
+ out.push(name);
33
+ };
34
+ var re = /'((?:[^']|'')*)'|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?|([A-Za-z_\u00C0-\uFFFF][A-Za-z0-9_.\u00C0-\uFFFF]*)/g;
35
+ try {
36
+ for (var _b = __values(formula.replace(/^\s*=/, "").matchAll(re)), _c = _b.next(); !_c.done; _c = _b.next()) {
37
+ var m = _c.value;
38
+ if (m[1] !== undefined)
39
+ push(m[1].replace(/''/g, "'"));
40
+ else if (m[2] !== undefined)
41
+ push(m[2]);
42
+ }
43
+ }
44
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
45
+ finally {
46
+ try {
47
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
48
+ }
49
+ finally { if (e_1) throw e_1.error; }
50
+ }
51
+ return out;
52
+ };
3
53
  var xmlBuilder = new XMLBuilder({
4
54
  ignoreAttributes: false,
5
55
  attributeNamePrefix: "@_",
@@ -55,13 +105,19 @@ var aggToSubtotal = function (agg) {
55
105
  * @param fieldNames All source column headers (becomes <cacheFields>)
56
106
  */
57
107
  export var buildPivotCacheDefinitionXml = function (pivot, sheetName, fieldNames) {
108
+ var _a;
58
109
  if (!pivot.source)
59
110
  return null;
60
111
  var sourceRef = rangeRef(pivot.source);
61
- var cacheFields = fieldNames.map(function (name) { return ({
62
- "@_name": name,
63
- sharedItems: { "@_count": "0" },
64
- }); });
112
+ // Calculated fields are cache fields too (`databaseField="0"` +
113
+ // `formula`), listed after the source columns like Excel does.
114
+ var calculatedByName = new Map(((_a = pivot.calculatedFields) !== null && _a !== void 0 ? _a : []).map(function (c) { return [c.name, c.formula]; }));
115
+ var cacheFields = fieldNames.map(function (name) {
116
+ var formula = calculatedByName.get(name);
117
+ return formula !== undefined
118
+ ? { "@_name": name, "@_formula": formula, "@_databaseField": "0" }
119
+ : { "@_name": name, sharedItems: { "@_count": "0" } };
120
+ });
65
121
  var doc = {
66
122
  "?xml": { "@_version": "1.0", "@_encoding": "UTF-8", "@_standalone": "yes" },
67
123
  pivotCacheDefinition: {
@@ -96,112 +152,155 @@ export var buildPivotCacheDefinitionXml = function (pivot, sheetName, fieldNames
96
152
  * @param fieldIndices Maps row/col/value field names → cacheField indices
97
153
  */
98
154
  export var buildPivotTableXml = function (pivot, cacheId, fieldIndices) {
99
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
100
- var _e, _f, _g, _h, _j, _k, _l;
155
+ var e_2, _a, e_3, _b, e_4, _c, e_5, _d;
156
+ var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
101
157
  if (!pivot.pivotRange)
102
158
  return null;
103
159
  var ref = rangeRef(pivot.pivotRange);
104
- // pivotFields: one entry per cacheField, with axis attribute
105
- // (axisRow / axisCol / dataField). Order = cacheField order.
160
+ // pivotFields: one entry per cacheField, with the axis attribute
161
+ // (axisRow / axisCol) and/or `dataField="1"` for value fields
162
+ // (`ST_Axis` has no "dataField" value — a field can sit on an axis
163
+ // AND be a data field). Order = cacheField order.
106
164
  var pivotFields = [];
107
165
  // We don't know the full field universe here without the source
108
166
  // schema. Best-effort: declare entries for the union of row/col/
109
167
  // value fields and tag with the appropriate axis.
110
168
  var fieldAxis = new Map();
111
169
  try {
112
- for (var _m = __values((_e = pivot.rows) !== null && _e !== void 0 ? _e : []), _o = _m.next(); !_o.done; _o = _m.next()) {
113
- var r = _o.value;
170
+ for (var _t = __values((_e = pivot.rows) !== null && _e !== void 0 ? _e : []), _u = _t.next(); !_u.done; _u = _t.next()) {
171
+ var r = _u.value;
114
172
  var idx = fieldIndices.get(r.field);
115
173
  if (idx != null)
116
174
  fieldAxis.set(idx, "axisRow");
117
175
  }
118
176
  }
119
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
177
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
120
178
  finally {
121
179
  try {
122
- if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
180
+ if (_u && !_u.done && (_a = _t.return)) _a.call(_t);
123
181
  }
124
- finally { if (e_1) throw e_1.error; }
182
+ finally { if (e_2) throw e_2.error; }
125
183
  }
126
184
  try {
127
- for (var _p = __values((_f = pivot.columns) !== null && _f !== void 0 ? _f : []), _q = _p.next(); !_q.done; _q = _p.next()) {
128
- var c = _q.value;
185
+ for (var _v = __values((_f = pivot.columns) !== null && _f !== void 0 ? _f : []), _w = _v.next(); !_w.done; _w = _v.next()) {
186
+ var c = _w.value;
129
187
  var idx = fieldIndices.get(c.field);
130
188
  if (idx != null)
131
189
  fieldAxis.set(idx, "axisCol");
132
190
  }
133
191
  }
134
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
192
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
135
193
  finally {
136
194
  try {
137
- if (_q && !_q.done && (_b = _p.return)) _b.call(_p);
195
+ if (_w && !_w.done && (_b = _v.return)) _b.call(_v);
138
196
  }
139
- finally { if (e_2) throw e_2.error; }
197
+ finally { if (e_3) throw e_3.error; }
140
198
  }
199
+ var dataFieldIndices = new Set();
141
200
  try {
142
- for (var _r = __values((_g = pivot.values) !== null && _g !== void 0 ? _g : []), _s = _r.next(); !_s.done; _s = _r.next()) {
143
- var v = _s.value;
201
+ for (var _x = __values((_g = pivot.values) !== null && _g !== void 0 ? _g : []), _y = _x.next(); !_y.done; _y = _x.next()) {
202
+ var v = _y.value;
144
203
  var idx = fieldIndices.get(v.field);
145
204
  if (idx != null)
146
- fieldAxis.set(idx, "dataField");
205
+ dataFieldIndices.add(idx);
147
206
  }
148
207
  }
149
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
208
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
150
209
  finally {
151
210
  try {
152
- if (_s && !_s.done && (_c = _r.return)) _c.call(_r);
211
+ if (_y && !_y.done && (_c = _x.return)) _c.call(_x);
153
212
  }
154
- finally { if (e_3) throw e_3.error; }
213
+ finally { if (e_4) throw e_4.error; }
155
214
  }
215
+ var calculatedNames = new Set(((_h = pivot.calculatedFields) !== null && _h !== void 0 ? _h : []).map(function (c) { return c.name; }));
156
216
  // Need to emit one <pivotField> per cacheField in order, even
157
217
  // for unused fields (Excel requires the array shapes match).
158
218
  // Caller passes us the full field set via fieldIndices.
159
219
  var sortedFieldIndices = __spreadArray([], __read(fieldIndices.entries()), false).sort(function (a, b) { return a[1] - b[1]; });
160
220
  try {
161
221
  for (var sortedFieldIndices_1 = __values(sortedFieldIndices), sortedFieldIndices_1_1 = sortedFieldIndices_1.next(); !sortedFieldIndices_1_1.done; sortedFieldIndices_1_1 = sortedFieldIndices_1.next()) {
162
- var _t = __read(sortedFieldIndices_1_1.value, 2), idx = _t[1];
222
+ var _z = __read(sortedFieldIndices_1_1.value, 2), name_1 = _z[0], idx = _z[1];
163
223
  var axis = fieldAxis.get(idx);
164
- if (axis) {
165
- pivotFields.push({ "@_axis": axis, "@_compact": "0", items: {} });
224
+ var entry = {};
225
+ if (axis)
226
+ entry["@_axis"] = axis;
227
+ if (dataFieldIndices.has(idx))
228
+ entry["@_dataField"] = "1";
229
+ if (calculatedNames.has(name_1)) {
230
+ // Excel pins calculated fields to the values area.
231
+ entry["@_dragToRow"] = "0";
232
+ entry["@_dragToCol"] = "0";
233
+ entry["@_dragToPage"] = "0";
234
+ entry["@_showAll"] = "0";
235
+ entry["@_defaultSubtotal"] = "0";
166
236
  }
167
237
  else {
168
- pivotFields.push({ "@_compact": "0" });
238
+ entry["@_compact"] = "0";
239
+ if (axis)
240
+ entry.items = {};
169
241
  }
242
+ pivotFields.push(entry);
170
243
  }
171
244
  }
172
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
245
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
173
246
  finally {
174
247
  try {
175
248
  if (sortedFieldIndices_1_1 && !sortedFieldIndices_1_1.done && (_d = sortedFieldIndices_1.return)) _d.call(sortedFieldIndices_1);
176
249
  }
177
- finally { if (e_4) throw e_4.error; }
250
+ finally { if (e_5) throw e_5.error; }
178
251
  }
179
- var rowFields = ((_h = pivot.rows) !== null && _h !== void 0 ? _h : [])
252
+ var rowFields = ((_j = pivot.rows) !== null && _j !== void 0 ? _j : [])
180
253
  .map(function (r) { return fieldIndices.get(r.field); })
181
254
  .filter(function (i) { return i != null; })
182
255
  .map(function (i) { return ({ "@_x": String(i) }); });
183
- var colFields = ((_j = pivot.columns) !== null && _j !== void 0 ? _j : [])
256
+ var colFields = ((_k = pivot.columns) !== null && _k !== void 0 ? _k : [])
184
257
  .map(function (c) { return fieldIndices.get(c.field); })
185
258
  .filter(function (i) { return i != null; })
186
259
  .map(function (i) { return ({ "@_x": String(i) }); });
187
- var dataFields = ((_k = pivot.values) !== null && _k !== void 0 ? _k : [])
260
+ // Running totals need a base field: Excel defaults to the first row
261
+ // field (falls back to the first column field / field 0).
262
+ var runTotalBase = (_p = (_m = (_l = rowFields[0]) === null || _l === void 0 ? void 0 : _l["@_x"]) !== null && _m !== void 0 ? _m : (_o = colFields[0]) === null || _o === void 0 ? void 0 : _o["@_x"]) !== null && _p !== void 0 ? _p : "0";
263
+ var dataFields = ((_q = pivot.values) !== null && _q !== void 0 ? _q : [])
188
264
  .map(function (v) {
189
265
  var _a;
190
266
  var idx = fieldIndices.get(v.field);
191
267
  if (idx == null)
192
268
  return null;
193
- return {
269
+ var entry = {
194
270
  "@_name": (_a = v.displayName) !== null && _a !== void 0 ? _a : "".concat(v.aggFunc, " of ").concat(v.field),
195
271
  "@_fld": String(idx),
196
- "@_subtotal": aggToSubtotal(v.aggFunc),
272
+ "@_subtotal": calculatedNames.has(v.field)
273
+ ? "sum"
274
+ : aggToSubtotal(v.aggFunc),
197
275
  };
276
+ var showDataAs = v.showAs ? SHOW_DATA_AS[v.showAs] : undefined;
277
+ if (showDataAs) {
278
+ entry["@_showDataAs"] = showDataAs;
279
+ if (showDataAs === "runTotal")
280
+ entry["@_baseField"] = runTotalBase;
281
+ }
282
+ var pivotShowAs = v.showAs ? X14_PIVOT_SHOW_AS[v.showAs] : undefined;
283
+ if (pivotShowAs) {
284
+ entry.extLst = {
285
+ ext: {
286
+ "@_uri": X14_DATA_FIELD_EXT_URI,
287
+ "@_xmlns:x14": X14_NS,
288
+ "x14:dataField": { "@_pivotShowAs": pivotShowAs },
289
+ },
290
+ };
291
+ }
292
+ return entry;
198
293
  })
199
294
  .filter(function (d) { return d !== null; });
295
+ var styleInfo = (_r = pivot.styleInfo) !== null && _r !== void 0 ? _r : {};
296
+ var styleFlag = function (value, fallback) {
297
+ return value === undefined ? fallback : value ? "1" : "0";
298
+ };
200
299
  var doc = {
201
300
  "?xml": { "@_version": "1.0", "@_encoding": "UTF-8", "@_standalone": "yes" },
202
301
  pivotTableDefinition: {
203
302
  "@_xmlns": "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
204
- "@_name": (_l = pivot.name) !== null && _l !== void 0 ? _l : "PivotTable".concat(pivot.pivotId),
303
+ "@_name": (_s = pivot.name) !== null && _s !== void 0 ? _s : "PivotTable".concat(pivot.pivotId),
205
304
  "@_cacheId": String(cacheId),
206
305
  "@_dataOnRows": "0",
207
306
  "@_applyNumberFormats": "0",
@@ -242,12 +341,12 @@ export var buildPivotTableXml = function (pivot, cacheId, fieldIndices) {
242
341
  ? { "@_count": String(dataFields.length), dataField: dataFields }
243
342
  : undefined,
244
343
  pivotTableStyleInfo: {
245
- "@_name": "PivotStyleLight16",
246
- "@_showRowHeaders": "1",
247
- "@_showColHeaders": "1",
248
- "@_showRowStripes": "0",
249
- "@_showColStripes": "0",
250
- "@_showLastColumn": "1",
344
+ "@_name": styleInfo.name || "PivotStyleLight16",
345
+ "@_showRowHeaders": styleFlag(styleInfo.showRowHeaders, "1"),
346
+ "@_showColHeaders": styleFlag(styleInfo.showColHeaders, "1"),
347
+ "@_showRowStripes": styleFlag(styleInfo.showRowStripes, "0"),
348
+ "@_showColStripes": styleFlag(styleInfo.showColStripes, "0"),
349
+ "@_showLastColumn": styleFlag(styleInfo.showLastColumn, "1"),
251
350
  },
252
351
  },
253
352
  };
@@ -716,10 +716,16 @@ var serializeAlignment = function (record) {
716
716
  attrs.push("relativeIndent=\"".concat(record.relativeIndent, "\""));
717
717
  }
718
718
  if (record.textRotation !== undefined && record.textRotation !== null) {
719
- // Excel encodes "vertical (stacked)" text as the magic value 255.
720
- var rotation = record.textRotation === "vertical" ? 255 : record.textRotation;
719
+ // Excel encodes "vertical (stacked)" text as the magic value 255 and
720
+ // clockwise rotation as 90 + degrees (91–180); the engine keeps signed
721
+ // counter-clockwise degrees.
722
+ var rotation = record.textRotation === "vertical"
723
+ ? 255
724
+ : record.textRotation < 0
725
+ ? 90 - record.textRotation
726
+ : record.textRotation;
721
727
  if (Number.isFinite(rotation) && rotation !== 0) {
722
- attrs.push("textRotation=\"".concat(rotation, "\""));
728
+ attrs.push("textRotation=\"".concat(Math.round(rotation), "\""));
723
729
  }
724
730
  }
725
731
  if (record.shrinkToFit) {
@@ -10,6 +10,7 @@ export declare const PERSON_CONTENT_TYPE = "application/vnd.ms-excel.person+xml"
10
10
  * scoping author/comment ids within a single workbook.
11
11
  */
12
12
  export declare const deterministicGuid: (seed: string) => string;
13
+ export declare const isBracedGuid: (id: string) => boolean;
13
14
  /**
14
15
  * Workbook-scoped author registry. Shared across every sheet's collector so
15
16
  * an author who comments on multiple sheets maps to a single `person` entry
@@ -35,7 +36,12 @@ export declare class ThreadedCommentsCollector {
35
36
  /** Anchor a thread to a cell. No-op if the id is unknown or empty. */
36
37
  addCell(address: string, threadId: string | number | null | undefined): void;
37
38
  isEmpty(): boolean;
38
- /** Braced root GUID for a thread — used as both the root `id` and `tc=`. */
39
+ /**
40
+ * Braced root GUID for a thread — used as both the root `id` and `tc=`.
41
+ * An id that already is a braced GUID (what Excel and both importers
42
+ * produce) passes through, so a re-exported thread keeps the identity
43
+ * Excel assigned it; anything else is hashed deterministically.
44
+ */
39
45
  private rootGuid;
40
46
  /**
41
47
  * Legacy `xl/comments{N}.xml` mirror entries. Feed these into the existing
@@ -1 +1 @@
1
- {"version":3,"file":"threaded-comments-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/threaded-comments-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAyBhE,eAAO,MAAM,yBAAyB,8EACuC,CAAC;AAC9E,eAAO,MAAM,eAAe,qEACwC,CAAC;AACrE,eAAO,MAAM,8BAA8B,kDACM,CAAC;AAClD,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AAsBzE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,MAiBhD,CAAC;AAEF;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAGlB;IAEJ,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS;IAWtE,OAAO;IAIP,KAAK;CAYN;AAQD;;;;GAIG;AACH,qBAAa,yBAAyB;IAMlC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;IACxD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;gBAG3C,OAAO,EAAE,aAAa,EAAE,GAAG,SAAS,EACnB,OAAO,EAAE,cAAc;IAO1C,sEAAsE;IACtE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS;IAQrE,OAAO;IAIP,4EAA4E;IAC5E,OAAO,CAAC,QAAQ;IAIhB;;;;;OAKG;IACH,aAAa,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE;IAcpE;;;;OAIG;IACH,KAAK,IAAI,MAAM,GAAG,SAAS;CA+B5B"}
1
+ {"version":3,"file":"threaded-comments-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/threaded-comments-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAyBhE,eAAO,MAAM,yBAAyB,8EACuC,CAAC;AAC9E,eAAO,MAAM,eAAe,qEACwC,CAAC;AACrE,eAAO,MAAM,8BAA8B,kDACM,CAAC;AAClD,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AAsBzE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,MAiBhD,CAAC;AAKF,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,YAAyB,CAAC;AAEjE;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAGlB;IAEJ,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS;IAWtE,OAAO;IAIP,KAAK;CAYN;AAQD;;;;GAIG;AACH,qBAAa,yBAAyB;IAMlC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;IACxD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;gBAG3C,OAAO,EAAE,aAAa,EAAE,GAAG,SAAS,EACnB,OAAO,EAAE,cAAc;IAO1C,sEAAsE;IACtE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS;IAQrE,OAAO;IAIP;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;IAMhB;;;;;OAKG;IACH,aAAa,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE;IAcpE;;;;OAIG;IACH,KAAK,IAAI,MAAM,GAAG,SAAS;CAiC5B"}
@@ -62,6 +62,9 @@ export var deterministicGuid = function (seed) {
62
62
  var p5 = all.slice(20, 32);
63
63
  return "{".concat(p1, "-").concat(p2, "-").concat(p3, "-").concat(p4, "-").concat(p5, "}");
64
64
  };
65
+ /** `{8-4-4-4-12}` hex, the braced RFC-4122 form Excel writes for comment and person ids. */
66
+ var BRACED_GUID = /^\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\}$/;
67
+ export var isBracedGuid = function (id) { return BRACED_GUID.test(id); };
65
68
  /**
66
69
  * Workbook-scoped author registry. Shared across every sheet's collector so
67
70
  * an author who comments on multiple sheets maps to a single `person` entry
@@ -125,9 +128,16 @@ var ThreadedCommentsCollector = /** @class */ (function () {
125
128
  ThreadedCommentsCollector.prototype.isEmpty = function () {
126
129
  return this.placed.length === 0;
127
130
  };
128
- /** Braced root GUID for a thread — used as both the root `id` and `tc=`. */
131
+ /**
132
+ * Braced root GUID for a thread — used as both the root `id` and `tc=`.
133
+ * An id that already is a braced GUID (what Excel and both importers
134
+ * produce) passes through, so a re-exported thread keeps the identity
135
+ * Excel assigned it; anything else is hashed deterministically.
136
+ */
129
137
  ThreadedCommentsCollector.prototype.rootGuid = function (thread) {
130
- return deterministicGuid("tc:".concat(thread.id));
138
+ return isBracedGuid(thread.id)
139
+ ? thread.id.toUpperCase()
140
+ : deterministicGuid("tc:".concat(thread.id));
131
141
  };
132
142
  /**
133
143
  * Legacy `xl/comments{N}.xml` mirror entries. Feed these into the existing
@@ -169,7 +179,9 @@ var ThreadedCommentsCollector = /** @class */ (function () {
169
179
  var personId = _this.persons.register(msg.authorId, msg.authorName);
170
180
  var id = index === 0
171
181
  ? root
172
- : deterministicGuid("c:".concat(thread.id, ":").concat(msg.id));
182
+ : isBracedGuid(msg.id)
183
+ ? msg.id.toUpperCase()
184
+ : deterministicGuid("c:".concat(thread.id, ":").concat(msg.id));
173
185
  var parent = index === 0 ? "" : " parentId=\"".concat(root, "\"");
174
186
  // Resolved state rides on the root as `done="1"` (MS-XLSX);
175
187
  // replies never carry it.
@@ -1,5 +1,5 @@
1
1
  import type { CellData, Citation, CommentThread, DataValidationRuleRecord, IterativeCalculationOptions, SheetData, TextFormat } from "@rowsncolumns/common-types";
2
- import type { Color, ConditionalFormatRule, EmbeddedChart, EmbeddedObject, NamedRange, PivotTable, Sheet, Slicer, SpreadsheetTheme, TableView } from "@rowsncolumns/spreadsheet";
2
+ import type { Color, ConditionalFormatRule, EmbeddedChart, EmbeddedObject, NamedRange, PivotTable, ProtectedRange, Sheet, Slicer, SpreadsheetTheme, TableView } from "@rowsncolumns/spreadsheet";
3
3
  import type { CellXfs, SharedStrings as SharedStringsType } from "@rowsncolumns/spreadsheet-state";
4
4
  import type { PowerQueryParts } from "../../power-query";
5
5
  import type { ExternalLink, WorkbookProperties } from "../../excel-parser/types";
@@ -32,6 +32,15 @@ export type ExportExcelProps<S extends Sheet, T extends CellData, C extends Cita
32
32
  pivotTables?: PivotTable[];
33
33
  externalLinks?: ExternalLink[];
34
34
  namedRanges?: NamedRange[];
35
+ /**
36
+ * Allow-edit ranges (`useSpreadsheetState`'s `protectedRanges`), written as
37
+ * `<protectedRanges>/<protectedRange sqref name>` on the sheet each range's
38
+ * `range.sheetId` names. Sheet-level protection is read from
39
+ * `Sheet.sheetProtection` and written as `<sheetProtection …>`; both sit
40
+ * right after `<sheetData>` per `CT_Worksheet`, the position the parser and
41
+ * `rnc-import` read them back from.
42
+ */
43
+ protectedRanges?: ProtectedRange[];
35
44
  /**
36
45
  * Workbook-wide named cell styles to round-trip into the
37
46
  * `<cellStyles>` block of styles.xml. Parsed by the importer as
@@ -109,7 +118,7 @@ export type ExportExcelProps<S extends Sheet, T extends CellData, C extends Cita
109
118
  */
110
119
  properties?: WorkbookProperties;
111
120
  };
112
- export declare const createExcelFile: <S extends Sheet, T extends CellData, C extends Citation>({ conditionalFormats: _conditionalFormats, dataValidations: _dataValidations, sheets, sheetData, sharedStrings: sourceSharedStrings, tables: _tables, cellXfs, theme, defaultFont, embeds, charts, slicers, pivotTables, externalLinks, namedRanges, namedCellStyles, customTableStyles, iterativeCalculationOptions, ignoreFormulaPatterns, citations, comments, password, locale, use1904, properties, powerQuery, }: ExportExcelProps<S, T, C>) => Promise<Uint8Array<ArrayBufferLike>>;
121
+ export declare const createExcelFile: <S extends Sheet, T extends CellData, C extends Citation>({ conditionalFormats: _conditionalFormats, dataValidations: _dataValidations, sheets, sheetData, sharedStrings: sourceSharedStrings, tables: _tables, cellXfs, theme, defaultFont, embeds, charts, slicers, pivotTables, externalLinks, namedRanges, protectedRanges, namedCellStyles, customTableStyles, iterativeCalculationOptions, ignoreFormulaPatterns, citations, comments, password, locale, use1904, properties, powerQuery, }: ExportExcelProps<S, T, C>) => Promise<Uint8Array<ArrayBufferLike>>;
113
122
  /**
114
123
  * Normalize a dataValidation sqref list: collapse degenerate ranges
115
124
  * (`C7:C7` → `C7`), drop exact duplicates, and drop members fully contained