@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
@@ -1 +1 @@
1
- {"version":3,"file":"pivots.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/pivots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AASrE,KAAK,aAAa,GAAG;IACnB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA6OF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS;IACP,SAAS,EAAE,kBAAkB,CAAC;IAC9B,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,mEAAmE;IACnE,WAAW,EAAE,MAAM,MAAM,CAAC;IAC1B,kDAAkD;IAClD,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACtD,cAAc,EAAE,MAAM,CAAC;CACxB,KACA,OAAO,CAAC,UAAU,EAAE,CAoEtB,CAAC"}
1
+ {"version":3,"file":"pivots.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/pivots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAEV,UAAU,EAGX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAoErE,KAAK,aAAa,GAAG;IACnB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAkQF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS;IACP,SAAS,EAAE,kBAAkB,CAAC;IAC9B,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,mEAAmE;IACnE,WAAW,EAAE,MAAM,MAAM,CAAC;IAC1B,kDAAkD;IAClD,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACtD,cAAc,EAAE,MAAM,CAAC;CACxB,KACA,OAAO,CAAC,UAAU,EAAE,CAsEtB,CAAC"}
@@ -1,4 +1,88 @@
1
- import { __awaiter, __generator, __read, __values } from "tslib";
1
+ import { __assign, __awaiter, __generator, __read, __values } from "tslib";
2
+ var attr = function (node, name) {
3
+ var _a, _b;
4
+ var v = (_b = (_a = node === null || node === void 0 ? void 0 : node.a$) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : node === null || node === void 0 ? void 0 : node["@_".concat(name)];
5
+ return v === undefined || v === null ? undefined : String(v);
6
+ };
7
+ /**
8
+ * `dataField@showDataAs` (ECMA-376) + the `x14:dataField@pivotShowAs`
9
+ * extension Excel uses for the newer modes → `PivotValue.showAs`.
10
+ * Modes without an engine equivalent (difference, % of parent, index…)
11
+ * degrade to the plain aggregate.
12
+ */
13
+ var readShowAs = function (dataField) {
14
+ var e_1, _a;
15
+ var _b, _c;
16
+ var extLst = (_b = dataField === null || dataField === void 0 ? void 0 : dataField.extLst) !== null && _b !== void 0 ? _b : dataField === null || dataField === void 0 ? void 0 : dataField["x:extLst"];
17
+ var exts = asArray((_c = extLst === null || extLst === void 0 ? void 0 : extLst.ext) !== null && _c !== void 0 ? _c : extLst === null || extLst === void 0 ? void 0 : extLst["x:ext"]);
18
+ try {
19
+ for (var exts_1 = __values(exts), exts_1_1 = exts_1.next(); !exts_1_1.done; exts_1_1 = exts_1.next()) {
20
+ var ext = exts_1_1.value;
21
+ var x14 = ext === null || ext === void 0 ? void 0 : ext["x14:dataField"];
22
+ var pivotShowAs = attr(x14, "pivotShowAs");
23
+ if (pivotShowAs === "rankAscending")
24
+ return "rank_asc";
25
+ if (pivotShowAs === "rankDescending")
26
+ return "rank_desc";
27
+ }
28
+ }
29
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
30
+ finally {
31
+ try {
32
+ if (exts_1_1 && !exts_1_1.done && (_a = exts_1.return)) _a.call(exts_1);
33
+ }
34
+ finally { if (e_1) throw e_1.error; }
35
+ }
36
+ switch (attr(dataField, "showDataAs")) {
37
+ case "percentOfTotal":
38
+ return "pct_of_total";
39
+ case "percentOfRow":
40
+ return "pct_of_row";
41
+ case "percentOfCol":
42
+ return "pct_of_column";
43
+ case "runTotal":
44
+ return "running_total";
45
+ default:
46
+ return undefined;
47
+ }
48
+ };
49
+ var readStyleInfo = function (pt) {
50
+ var e_2, _a;
51
+ var _b;
52
+ var node = (_b = pt === null || pt === void 0 ? void 0 : pt.pivotTableStyleInfo) !== null && _b !== void 0 ? _b : pt === null || pt === void 0 ? void 0 : pt["x:pivotTableStyleInfo"];
53
+ if (!node)
54
+ return undefined;
55
+ var flag = function (name) {
56
+ var v = attr(node, name);
57
+ return v === undefined ? undefined : v !== "0" && v !== "false";
58
+ };
59
+ var info = {};
60
+ var name = attr(node, "name");
61
+ if (name)
62
+ info.name = name;
63
+ try {
64
+ for (var _c = __values([
65
+ "showRowHeaders",
66
+ "showColHeaders",
67
+ "showRowStripes",
68
+ "showColStripes",
69
+ "showLastColumn",
70
+ ]), _d = _c.next(); !_d.done; _d = _c.next()) {
71
+ var key = _d.value;
72
+ var v = flag(key);
73
+ if (v !== undefined)
74
+ info[key] = v;
75
+ }
76
+ }
77
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
78
+ finally {
79
+ try {
80
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
81
+ }
82
+ finally { if (e_2) throw e_2.error; }
83
+ }
84
+ return Object.keys(info).length ? info : undefined;
85
+ };
2
86
  var asArray = function (value) {
3
87
  if (value === undefined || value === null)
4
88
  return [];
@@ -29,7 +113,7 @@ var parseA1Range = function (a1) {
29
113
  };
30
114
  };
31
115
  var parseA1Cell = function (cell) {
32
- var e_1, _a;
116
+ var e_3, _a;
33
117
  var m = cell.match(/^([A-Za-z]+)(\d+)$/);
34
118
  if (!m)
35
119
  return null;
@@ -40,12 +124,12 @@ var parseA1Cell = function (cell) {
40
124
  col = col * 26 + (ch.charCodeAt(0) - 64);
41
125
  }
42
126
  }
43
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
127
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
44
128
  finally {
45
129
  try {
46
130
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
47
131
  }
48
- finally { if (e_1) throw e_1.error; }
132
+ finally { if (e_3) throw e_3.error; }
49
133
  }
50
134
  return { col: col, row: Number(m[2]) };
51
135
  };
@@ -84,10 +168,13 @@ var parsePivotCacheDefinition = function (cacheXml) {
84
168
  var cacheSource = (_b = cacheDef.cacheSource) !== null && _b !== void 0 ? _b : cacheDef["x:cacheSource"];
85
169
  var wsSource = (_c = cacheSource === null || cacheSource === void 0 ? void 0 : cacheSource.worksheetSource) !== null && _c !== void 0 ? _c : cacheSource === null || cacheSource === void 0 ? void 0 : cacheSource["x:worksheetSource"];
86
170
  var sourceRef = ((_d = wsSource === null || wsSource === void 0 ? void 0 : wsSource.a$) === null || _d === void 0 ? void 0 : _d.ref) || (wsSource === null || wsSource === void 0 ? void 0 : wsSource["@_ref"]);
171
+ // Excel writes the source sheet as `worksheetSource@sheet` (the ref is
172
+ // then sheet-less); a `Sheet!A1:D9` prefix on the ref also occurs.
173
+ var sourceSheet = attr(wsSource, "sheet");
87
174
  var cacheFields = (_e = cacheDef.cacheFields) !== null && _e !== void 0 ? _e : cacheDef["x:cacheFields"];
88
175
  var rawFieldList = asArray((_f = cacheFields === null || cacheFields === void 0 ? void 0 : cacheFields.cacheField) !== null && _f !== void 0 ? _f : cacheFields === null || cacheFields === void 0 ? void 0 : cacheFields["x:cacheField"]);
89
176
  var fields = rawFieldList.map(function (cf) {
90
- var e_2, _a, e_3, _b, e_4, _c;
177
+ var e_4, _a, e_5, _b, e_6, _c;
91
178
  var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
92
179
  var name = ((_d = cf.a$) === null || _d === void 0 ? void 0 : _d.name) || cf["@_name"] || "";
93
180
  var sharedItemsNode = (_e = cf.sharedItems) !== null && _e !== void 0 ? _e : cf["x:sharedItems"];
@@ -99,12 +186,12 @@ var parsePivotCacheDefinition = function (cacheXml) {
99
186
  items.push(String((_j = (_h = (_g = s.a$) === null || _g === void 0 ? void 0 : _g.v) !== null && _h !== void 0 ? _h : s["@_v"]) !== null && _j !== void 0 ? _j : ""));
100
187
  }
101
188
  }
102
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
189
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
103
190
  finally {
104
191
  try {
105
192
  if (_r && !_r.done && (_a = _q.return)) _a.call(_q);
106
193
  }
107
- finally { if (e_2) throw e_2.error; }
194
+ finally { if (e_4) throw e_4.error; }
108
195
  }
109
196
  try {
110
197
  for (var _s = __values(asArray((_k = sharedItemsNode.n) !== null && _k !== void 0 ? _k : sharedItemsNode["x:n"])), _t = _s.next(); !_t.done; _t = _s.next()) {
@@ -112,12 +199,12 @@ var parsePivotCacheDefinition = function (cacheXml) {
112
199
  items.push(Number((_o = (_m = (_l = n.a$) === null || _l === void 0 ? void 0 : _l.v) !== null && _m !== void 0 ? _m : n["@_v"]) !== null && _o !== void 0 ? _o : 0));
113
200
  }
114
201
  }
115
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
202
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
116
203
  finally {
117
204
  try {
118
205
  if (_t && !_t.done && (_b = _s.return)) _b.call(_s);
119
206
  }
120
- finally { if (e_3) throw e_3.error; }
207
+ finally { if (e_5) throw e_5.error; }
121
208
  }
122
209
  try {
123
210
  for (var _u = __values(asArray((_p = sharedItemsNode.m) !== null && _p !== void 0 ? _p : sharedItemsNode["x:m"])), _v = _u.next(); !_v.done; _v = _u.next()) {
@@ -125,17 +212,18 @@ var parsePivotCacheDefinition = function (cacheXml) {
125
212
  items.push(null);
126
213
  }
127
214
  }
128
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
215
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
129
216
  finally {
130
217
  try {
131
218
  if (_v && !_v.done && (_c = _u.return)) _c.call(_u);
132
219
  }
133
- finally { if (e_4) throw e_4.error; }
220
+ finally { if (e_6) throw e_6.error; }
134
221
  }
135
222
  }
136
- return { name: name, sharedItems: items.length > 0 ? items : undefined };
223
+ var formula = attr(cf, "formula");
224
+ return __assign({ name: name, sharedItems: items.length > 0 ? items : undefined }, (formula !== undefined ? { formula: formula } : {}));
137
225
  });
138
- return { sourceRef: sourceRef, fields: fields };
226
+ return { sourceRef: sourceRef, sourceSheet: sourceSheet, fields: fields };
139
227
  };
140
228
  /**
141
229
  * Parse a single pivotTable.xml into a PivotTable record. Needs the
@@ -172,7 +260,8 @@ var parsePivotTableXml = function (pivotXml, cacheDef, getSheetId, defaultSheetI
172
260
  // Source range from cacheDef
173
261
  var source;
174
262
  if (cacheDef.sourceRef) {
175
- var _l = stripSheetPrefix(cacheDef.sourceRef), sheet = _l.sheet, a1 = _l.a1;
263
+ var _l = stripSheetPrefix(cacheDef.sourceRef), prefixSheet = _l.sheet, a1 = _l.a1;
264
+ var sheet = prefixSheet !== null && prefixSheet !== void 0 ? prefixSheet : cacheDef.sourceSheet;
176
265
  var sourceRange = parseA1Range(a1);
177
266
  if (sourceRange) {
178
267
  var resolved = sheet ? getSheetId(sheet) : undefined;
@@ -214,35 +303,32 @@ var parsePivotTableXml = function (pivotXml, cacheDef, getSheetId, defaultSheetI
214
303
  .map(function (field) { return ({ field: field, displayName: field }); });
215
304
  var values = dataFieldList
216
305
  .map(function (d) {
217
- var _a, _b, _c, _d;
306
+ var _a, _b, _c, _d, _e;
218
307
  var idx = Number((_b = (_a = d.a$) === null || _a === void 0 ? void 0 : _a.fld) !== null && _b !== void 0 ? _b : d["@_fld"]);
219
308
  var field = fieldNameAt(idx);
220
309
  if (!field)
221
310
  return null;
222
- var aggFunc = normalizeAggFunc(((_c = d.a$) === null || _c === void 0 ? void 0 : _c.subtotal) || d["@_subtotal"]);
223
- var displayName = ((_d = d.a$) === null || _d === void 0 ? void 0 : _d.name) || d["@_name"] || "".concat(aggFunc, " of ").concat(field);
224
- return { field: field, displayName: displayName, aggFunc: aggFunc };
311
+ // Excel always summarizes a calculated field with Sum.
312
+ var aggFunc = ((_c = cacheDef.fields[idx]) === null || _c === void 0 ? void 0 : _c.formula) !== undefined
313
+ ? "sum"
314
+ : normalizeAggFunc(((_d = d.a$) === null || _d === void 0 ? void 0 : _d.subtotal) || d["@_subtotal"]);
315
+ var displayName = ((_e = d.a$) === null || _e === void 0 ? void 0 : _e.name) || d["@_name"] || "".concat(aggFunc, " of ").concat(field);
316
+ var showAs = readShowAs(d);
317
+ return __assign({ field: field, displayName: displayName, aggFunc: aggFunc }, (showAs ? { showAs: showAs } : {}));
225
318
  })
226
319
  .filter(function (v) { return v !== null; });
320
+ var calculatedFields = cacheDef.fields
321
+ .filter(function (f) { return f.formula !== undefined && f.name !== ""; })
322
+ .map(function (f) { return ({ name: f.name, formula: f.formula }); });
323
+ var styleInfo = readStyleInfo(pt);
227
324
  // Display toggles (Phase A1 — round-trip these so the editor
228
325
  // checkboxes pick up the imported values).
229
326
  // XLSX: rowGrandTotals / colGrandTotals default to "1" (true).
230
327
  var showRowGT = ((_h = (_g = pt.a$) === null || _g === void 0 ? void 0 : _g.rowGrandTotals) !== null && _h !== void 0 ? _h : pt["@_rowGrandTotals"]) !== "0";
231
328
  var showColGT = ((_k = (_j = pt.a$) === null || _j === void 0 ? void 0 : _j.colGrandTotals) !== null && _k !== void 0 ? _k : pt["@_colGrandTotals"]) !== "0";
232
- return {
233
- pivotId: pivotId,
234
- name: name,
235
- source: source,
236
- targetPosition: targetPosition,
237
- pivotRange: pivotRange,
238
- rows: rows,
239
- columns: columns,
240
- values: values,
241
- showRowGrandTotals: showRowGT,
242
- showColumnGrandTotals: showColGT,
329
+ return __assign(__assign({ pivotId: pivotId, name: name, source: source, targetPosition: targetPosition, pivotRange: pivotRange, rows: rows, columns: columns, values: values, showRowGrandTotals: showRowGT, showColumnGrandTotals: showColGT,
243
330
  // Subtotal default on individual fields → leave true.
244
- showSubtotals: true,
245
- };
331
+ showSubtotals: true }, (calculatedFields.length ? { calculatedFields: calculatedFields } : {})), (styleInfo ? { styleInfo: styleInfo } : {}));
246
332
  };
247
333
  /**
248
334
  * Top-level: parse every pivotTable referenced by a worksheet's
@@ -250,8 +336,8 @@ var parsePivotTableXml = function (pivotXml, cacheDef, getSheetId, defaultSheetI
250
336
  * to the host's `pivotTables` state).
251
337
  */
252
338
  export var parsePivotTablesForSheet = function (options) { return __awaiter(void 0, void 0, void 0, function () {
253
- var zipParser, xmlParser, sheetRels, nextPivotId, getSheetId, defaultSheetId, out, sheetRels_1, sheetRels_1_1, rel, pivotTablePath, pivotTableXmlText, pivotXml, pivotDir, fileName, pivotRelsPath, pivotRelsText, cacheDef, pivotRels, relList, cacheRel, cachePath, cacheText, _a, pivot, e_5_1;
254
- var e_5, _b;
339
+ var zipParser, xmlParser, sheetRels, nextPivotId, getSheetId, defaultSheetId, out, sheetRels_1, sheetRels_1_1, rel, pivotTablePath, pivotTableXmlText, pivotXml, pivotDir, fileName, pivotRelsPath, pivotRelsText, cacheDef, pivotRels, relList, cacheRel, cachePath, cacheText, _a, pivot, e_7_1;
340
+ var e_7, _b;
255
341
  var _c, _d;
256
342
  return __generator(this, function (_e) {
257
343
  switch (_e.label) {
@@ -283,7 +369,9 @@ export var parsePivotTablesForSheet = function (options) { return __awaiter(void
283
369
  return [4 /*yield*/, zipParser.getText(pivotRelsPath)];
284
370
  case 4:
285
371
  pivotRelsText = _e.sent();
286
- cacheDef = { fields: [] };
372
+ cacheDef = {
373
+ fields: [],
374
+ };
287
375
  if (!pivotRelsText) return [3 /*break*/, 8];
288
376
  pivotRels = xmlParser.parse(pivotRelsText);
289
377
  relList = asArray((_c = pivotRels === null || pivotRels === void 0 ? void 0 : pivotRels.Relationships) === null || _c === void 0 ? void 0 : _c.Relationship);
@@ -327,14 +415,14 @@ export var parsePivotTablesForSheet = function (options) { return __awaiter(void
327
415
  return [3 /*break*/, 2];
328
416
  case 10: return [3 /*break*/, 13];
329
417
  case 11:
330
- e_5_1 = _e.sent();
331
- e_5 = { error: e_5_1 };
418
+ e_7_1 = _e.sent();
419
+ e_7 = { error: e_7_1 };
332
420
  return [3 /*break*/, 13];
333
421
  case 12:
334
422
  try {
335
423
  if (sheetRels_1_1 && !sheetRels_1_1.done && (_b = sheetRels_1.return)) _b.call(sheetRels_1);
336
424
  }
337
- finally { if (e_5) throw e_5.error; }
425
+ finally { if (e_7) throw e_7.error; }
338
426
  return [7 /*endfinally*/];
339
427
  case 13: return [2 /*return*/, out];
340
428
  }
@@ -5,6 +5,7 @@
5
5
  * - showRowColHeaders (row/column header visibility)
6
6
  * - showZeros (whether zero values render in cells)
7
7
  * - zoomScale (integer percent, 10-400; undefined = use Excel default 100)
8
+ * - rightToLeft (the sheet displays right-to-left; only surfaced when set)
8
9
  *
9
10
  * Works with both single sheet view and multiple sheet views.
10
11
  *
@@ -21,6 +22,8 @@ export type SheetViewProperties = {
21
22
  showRowColHeaders: boolean;
22
23
  showZeros: boolean;
23
24
  zoomScale?: number;
25
+ /** `<sheetView rightToLeft="1">` — column A on the right. Absent = LTR. */
26
+ rightToLeft?: true;
24
27
  };
25
28
  export declare function extractSheetViewProperties(sheetViewData: any): SheetViewProperties;
26
29
  //# sourceMappingURL=sheet-views.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sheet-views.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/sheet-views.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAKF,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,GAAG,GACjB,mBAAmB,CAqErB"}
1
+ {"version":3,"file":"sheet-views.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/sheet-views.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,IAAI,CAAC;CACpB,CAAC;AAQF,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,GAAG,GACjB,mBAAmB,CAsErB"}
@@ -2,6 +2,9 @@ import { __assign } from "tslib";
2
2
  var isFalseAttr = function (val) {
3
3
  return val === "0" || val === "false" || val === false;
4
4
  };
5
+ var isTrueAttr = function (val) {
6
+ return val === "1" || val === "true" || val === true;
7
+ };
5
8
  export function extractSheetViewProperties(sheetViewData) {
6
9
  var defaults = {
7
10
  frozenRowCount: 0,
@@ -55,5 +58,5 @@ export function extractSheetViewProperties(sheetViewData) {
55
58
  zoomScale = parsed;
56
59
  }
57
60
  }
58
- return __assign(__assign(__assign({ frozenRowCount: frozenRowCount, frozenColumnCount: frozenColumnCount }, (paneTopLeftCell ? { paneTopLeftCell: paneTopLeftCell } : {})), { showGridLines: !isFalseAttr(viewAttrs.showGridLines), showRowColHeaders: !isFalseAttr(viewAttrs.showRowColHeaders), showZeros: !isFalseAttr(viewAttrs.showZeros) }), (zoomScale !== undefined ? { zoomScale: zoomScale } : {}));
61
+ return __assign(__assign(__assign(__assign({ frozenRowCount: frozenRowCount, frozenColumnCount: frozenColumnCount }, (paneTopLeftCell ? { paneTopLeftCell: paneTopLeftCell } : {})), { showGridLines: !isFalseAttr(viewAttrs.showGridLines), showRowColHeaders: !isFalseAttr(viewAttrs.showRowColHeaders), showZeros: !isFalseAttr(viewAttrs.showZeros) }), (zoomScale !== undefined ? { zoomScale: zoomScale } : {})), (isTrueAttr(viewAttrs.rightToLeft) ? { rightToLeft: true } : {}));
59
62
  }
@@ -1,4 +1,4 @@
1
- import type { GridRange } from "@rowsncolumns/common-types";
1
+ import type { GridRange, NamedCellStyle } from "@rowsncolumns/common-types";
2
2
  import type { CellData, Color, ExtendedValue, TextFormat } from "@rowsncolumns/spreadsheet";
3
3
  import type { WorkBook } from "../../workbook";
4
4
  import type { WorkbookStyles } from "./index";
@@ -12,6 +12,13 @@ type MergeCellContext = {
12
12
  * @param {WorkBook} workbook - The workbook object containing shared strings
13
13
  * @returns {Object} Object containing value and cellFormat properties
14
14
  */
15
+ /** Days between the 1900 and 1904 date systems' serial 0. */
16
+ export declare const DATE_1904_OFFSET_DAYS = 1462;
17
+ /**
18
+ * Number formats whose serials move with the workbook's date system. Pure
19
+ * time-of-day values (`TIME`) are the same fraction in both systems.
20
+ */
21
+ export declare const isEpochShiftedFormat: (type: string | undefined) => boolean;
15
22
  export declare function getCellValueAndFormat(cell: any, workbook: WorkBook, enableCellXfsRegistry?: boolean, enableSharedStrings?: boolean, activeSheetName?: string, mergeContext?: MergeCellContext): CellData | null;
16
23
  /**
17
24
  * Build a format-only CellData for a style index that a cell inherits from
@@ -31,6 +38,13 @@ export declare function extractCellProtection(cell: any, workbookStyles: Workboo
31
38
  locked?: boolean;
32
39
  hidden?: boolean;
33
40
  } | undefined;
41
+ /**
42
+ * Resolve the workbook's named cell styles (`<cellStyles>`) to cell formats
43
+ * by reading each entry's `cellStyleXfs[xfId]` — the same extraction a cell
44
+ * xf goes through, minus merge-anchor border merging. Powers the toolbar's
45
+ * "Workbook styles" gallery; entries whose xf is missing keep no `format`.
46
+ */
47
+ export declare function resolveNamedCellStyles(workbookStyles: WorkbookStyles | undefined | null): NamedCellStyle[];
34
48
  /**
35
49
  * Parse a raw styles.xml `<font>` node into a TextFormat. Also used for the
36
50
  * workbook default font (fonts[0]) so the exporter can round-trip it.
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAS,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAGV,QAAQ,EAER,KAAK,EAEL,aAAa,EAIb,UAAU,EACX,MAAM,2BAA2B,CAAC;AAKnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAuD9C,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,SAAS,CAAC;IACjB,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;GAKG;AAEH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,GAAG,EACT,QAAQ,EAAE,QAAQ,EAClB,qBAAqB,UAAQ,EAC7B,mBAAmB,UAAQ,EAC3B,eAAe,CAAC,EAAE,MAAM,EACxB,YAAY,CAAC,EAAE,gBAAgB,GAC9B,QAAQ,GAAG,IAAI,CAwJjB;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,QAAQ,EAClB,qBAAqB,UAAQ,GAC5B,QAAQ,GAAG,IAAI,CAoBjB;AAED,eAAO,MAAM,gBAAgB,GAAI,UAAU,GAAG,KAAG,aAAa,GAAG,SAShE,CAAC;AAuTF;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,GAAG,EACT,cAAc,EAAE,cAAc,GAC7B;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAUpD;AAuMD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,GAAG,EACT,cAAc,EAAE,cAAc,GAC7B,UAAU,GAAG,IAAI,CAwFnB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,GAAG,EACb,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GACxC,KAAK,GAAG,SAAS,GAAG,IAAI,CA8C1B"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAET,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAGV,QAAQ,EAER,KAAK,EAEL,aAAa,EAIb,UAAU,EACX,MAAM,2BAA2B,CAAC;AAMnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAuD9C,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,SAAS,CAAC;IACjB,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;GAKG;AAEH,6DAA6D;AAC7D,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,OACvB,CAAC;AAE1C,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,GAAG,EACT,QAAQ,EAAE,QAAQ,EAClB,qBAAqB,UAAQ,EAC7B,mBAAmB,UAAQ,EAC3B,eAAe,CAAC,EAAE,MAAM,EACxB,YAAY,CAAC,EAAE,gBAAgB,GAC9B,QAAQ,GAAG,IAAI,CAqKjB;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,QAAQ,EAClB,qBAAqB,UAAQ,GAC5B,QAAQ,GAAG,IAAI,CAoBjB;AAED,eAAO,MAAM,gBAAgB,GAAI,UAAU,GAAG,KAAG,aAAa,GAAG,SAShE,CAAC;AA2TF;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,GAAG,EACT,cAAc,EAAE,cAAc,GAC7B;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAUpD;AAgCD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI,GAChD,cAAc,EAAE,CAuBlB;AA4ND;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,GAAG,EACT,cAAc,EAAE,cAAc,GAC7B,UAAU,GAAG,IAAI,CAwFnB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,GAAG,EACb,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GACxC,KAAK,GAAG,SAAS,GAAG,IAAI,CA8C1B"}
@@ -2,6 +2,7 @@ import { __assign, __read, __values } from "tslib";
2
2
  import { formulaToRelativeReference } from "@rowsncolumns/calculator";
3
3
  import { IndexedColors } from "@rowsncolumns/utils";
4
4
  import { addressToCell, ssfFormat } from "@rowsncolumns/utils";
5
+ import { decodeImplicitIntersection } from "../../../helpers/implicit-intersection";
5
6
  import { standardExcelFormatCodeById } from "./numfmt";
6
7
  import { detectValueTypeAndPattern } from "./value-type-detection";
7
8
  var getNode = function (node) {
@@ -77,15 +78,24 @@ var getInlineStringValue = function (cell) {
77
78
  * @param {WorkBook} workbook - The workbook object containing shared strings
78
79
  * @returns {Object} Object containing value and cellFormat properties
79
80
  */
81
+ /** Days between the 1900 and 1904 date systems' serial 0. */
82
+ export var DATE_1904_OFFSET_DAYS = 1462;
83
+ /**
84
+ * Number formats whose serials move with the workbook's date system. Pure
85
+ * time-of-day values (`TIME`) are the same fraction in both systems.
86
+ */
87
+ export var isEpochShiftedFormat = function (type) {
88
+ return type === "DATE" || type === "DATE_TIME";
89
+ };
80
90
  export function getCellValueAndFormat(cell, workbook, enableCellXfsRegistry, enableSharedStrings, activeSheetName, mergeContext) {
81
- var _a, _b;
91
+ var _a, _b, _c;
82
92
  if (enableCellXfsRegistry === void 0) { enableCellXfsRegistry = false; }
83
93
  if (enableSharedStrings === void 0) { enableSharedStrings = false; }
84
94
  if (!cell) {
85
95
  return null;
86
96
  }
87
97
  // Extract raw value
88
- var _c = extractCellValue(cell, workbook, activeSheetName), extractedRawValue = _c.rawValue, formulaValue = _c.formulaValue, sharedStringIndex = _c.sharedStringIndex, isError = _c.isError, arrayFormulaRef = _c.arrayFormulaRef, sharedFormulaSpec = _c.sharedFormulaSpec;
98
+ var _d = extractCellValue(cell, workbook, activeSheetName), extractedRawValue = _d.rawValue, formulaValue = _d.formulaValue, sharedStringIndex = _d.sharedStringIndex, isError = _d.isError, arrayFormulaRef = _d.arrayFormulaRef, sharedFormulaSpec = _d.sharedFormulaSpec;
89
99
  var rawValue = extractedRawValue;
90
100
  // Extract cell format
91
101
  var cellFormat = extractCellFormat(cell, workbook.workbookStyles, mergeContext);
@@ -117,7 +127,7 @@ export function getCellValueAndFormat(cell, workbook, enableCellXfsRegistry, ena
117
127
  if (!cellFormat.numberFormat &&
118
128
  typeof rawValue === "string" &&
119
129
  formulaValue === null) {
120
- var _d = __read(detectValueTypeAndPattern(rawValue, undefined), 4), detectedValueType = _d[0], detectedNumberFormatType = _d[1], detectedNumberValue = _d[2], detectedPattern = _d[3];
130
+ var _e = __read(detectValueTypeAndPattern(rawValue, undefined), 4), detectedValueType = _e[0], detectedNumberFormatType = _e[1], detectedNumberValue = _e[2], detectedPattern = _e[3];
121
131
  if (detectedValueType === "numberValue" &&
122
132
  detectedNumberFormatType &&
123
133
  detectedNumberValue !== undefined) {
@@ -129,6 +139,16 @@ export function getCellValueAndFormat(cell, workbook, enableCellXfsRegistry, ena
129
139
  var styleId = workbook.registerFormat(cellFormat);
130
140
  ef = { sid: styleId };
131
141
  }
142
+ // A 1904-system workbook stores its date serials 1462 days below the 1900
143
+ // system the calculation engine, the formatter and the exporter run on.
144
+ // Date / datetime-formatted numbers (literals and cached formula results)
145
+ // are converted here, as `rnc-import` does, so they display and compute as
146
+ // the same calendar dates; time-of-day serials are epoch-independent.
147
+ if (typeof rawValue === "number" &&
148
+ isEpochShiftedFormat((_a = cellFormat.numberFormat) === null || _a === void 0 ? void 0 : _a.type) &&
149
+ workbook.getUse1904Epoch()) {
150
+ rawValue += DATE_1904_OFFSET_DAYS;
151
+ }
132
152
  // User entered value
133
153
  var ue;
134
154
  var ev;
@@ -167,7 +187,7 @@ export function getCellValueAndFormat(cell, workbook, enableCellXfsRegistry, ena
167
187
  if (!hasRawValue && !hasValue) {
168
188
  return hasFormat ? { uf: ef } : null;
169
189
  }
170
- var pattern = (_b = (_a = cellFormat === null || cellFormat === void 0 ? void 0 : cellFormat.numberFormat) === null || _a === void 0 ? void 0 : _a.pattern) !== null && _b !== void 0 ? _b : "GENERAL";
190
+ var pattern = (_c = (_b = cellFormat === null || cellFormat === void 0 ? void 0 : cellFormat.numberFormat) === null || _b === void 0 ? void 0 : _b.pattern) !== null && _c !== void 0 ? _c : "GENERAL";
171
191
  // Skip persisting `fv` for formula cells — the renderer derives the
172
192
  // formatted value at paint time from the formula's effective value and
173
193
  // the precedent-derived number format. Excel ships a cached `fv` in the
@@ -311,7 +331,9 @@ function extractCellValue(cell, workbook, activeSheetName) {
311
331
  }
312
332
  }
313
333
  if (formulaValue) {
314
- formulaValue = normalizeFormulaSheetNames(formulaValue);
334
+ // Excel 365 persists the implicit-intersection operator `@` as
335
+ // `_xlfn.SINGLE(...)`; show it the way Excel does.
336
+ formulaValue = decodeImplicitIntersection(normalizeFormulaSheetNames(formulaValue));
315
337
  }
316
338
  switch (cellType) {
317
339
  case "s": {
@@ -522,6 +544,73 @@ function extractCellFormat(cell, workbookStyles, mergeContext) {
522
544
  var xfId = xfIdStr !== undefined ? parseInt(xfIdStr) : 0;
523
545
  var parentXf = xfId > 0 ? workbookStyles.getCellStyleXf(xfId) : null;
524
546
  var xf = buildEffectiveXf(cellXf, parentXf);
547
+ return extractCellFormatFromXf(xf, workbookStyles, cell, mergeContext);
548
+ }
549
+ /**
550
+ * Resolve the workbook's named cell styles (`<cellStyles>`) to cell formats
551
+ * by reading each entry's `cellStyleXfs[xfId]` — the same extraction a cell
552
+ * xf goes through, minus merge-anchor border merging. Powers the toolbar's
553
+ * "Workbook styles" gallery; entries whose xf is missing keep no `format`.
554
+ */
555
+ export function resolveNamedCellStyles(workbookStyles) {
556
+ if (!workbookStyles)
557
+ return [];
558
+ return workbookStyles.namedCellStyles.map(function (entry) {
559
+ var xf = workbookStyles.getCellStyleXf(entry.xfId);
560
+ if (!xf)
561
+ return __assign({}, entry);
562
+ // Drop empty slots and the default General number format — a style that
563
+ // carries nothing else is format-less as far as the gallery is concerned.
564
+ var format = Object.fromEntries(Object.entries(extractCellFormatFromXf(maskCellStyleXf(xf), workbookStyles)).filter(function (_a) {
565
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
566
+ return value != null &&
567
+ !(key === "numberFormat" &&
568
+ value.type === "GENERAL" &&
569
+ (!value.pattern ||
570
+ value.pattern === "General"));
571
+ }));
572
+ return Object.keys(format).length ? __assign(__assign({}, entry), { format: format }) : __assign({}, entry);
573
+ });
574
+ }
575
+ var isApplyFlagOff = function (value) { return value === "0" || value === "false"; };
576
+ /**
577
+ * A `cellStyleXfs` entry only *includes* an attribute when its `applyX` flag
578
+ * is not off (OOXML §18.8.45): Excel writes `applyFont="0" applyFill="0"
579
+ * applyBorder="0" applyAlignment="0"` on `Percent` / `Comma` / `Currency`,
580
+ * whose Style dialog has only "Number" ticked, so applying them must change
581
+ * the number format alone — extracting their `fontId="0"` as a real font
582
+ * would reset the cell's font family / size and un-bold it. Strip the
583
+ * excluded attributes before extraction. (Cell `cellXfs` entries follow the
584
+ * inverse rule and go through `buildEffectiveXf` instead.)
585
+ */
586
+ function maskCellStyleXf(xf) {
587
+ var _a;
588
+ var attrs = (_a = xf === null || xf === void 0 ? void 0 : xf.a$) !== null && _a !== void 0 ? _a : {};
589
+ var masked = __assign(__assign({}, xf), { a$: __assign({}, attrs) });
590
+ if (isApplyFlagOff(attrs.applyNumberFormat))
591
+ delete masked.a$.numFmtId;
592
+ if (isApplyFlagOff(attrs.applyFont))
593
+ delete masked.a$.fontId;
594
+ if (isApplyFlagOff(attrs.applyFill))
595
+ delete masked.a$.fillId;
596
+ if (isApplyFlagOff(attrs.applyBorder))
597
+ delete masked.a$.borderId;
598
+ if (isApplyFlagOff(attrs.applyAlignment)) {
599
+ delete masked.alignment;
600
+ delete masked["x:alignment"];
601
+ }
602
+ if (isApplyFlagOff(attrs.applyProtection)) {
603
+ delete masked.protection;
604
+ delete masked["x:protection"];
605
+ }
606
+ return masked;
607
+ }
608
+ /**
609
+ * Extract a cell format from a resolved `<xf>` node. `cell` / `mergeContext`
610
+ * only matter for merge-anchor border merging and may be omitted.
611
+ */
612
+ function extractCellFormatFromXf(xf, workbookStyles, cell, mergeContext) {
613
+ var cellFormat = {};
525
614
  // Extract number format
526
615
  var numberFormat = extractNumberFormat(xf, workbookStyles);
527
616
  if (!((numberFormat === null || numberFormat === void 0 ? void 0 : numberFormat.type) === "GENERAL" && !numberFormat.pattern)) {
@@ -566,7 +655,14 @@ function extractCellFormat(cell, workbookStyles, mergeContext) {
566
655
  cellFormat.relativeIndent = relativeIndent;
567
656
  if (alignment.textRotation) {
568
657
  var rotation = parseInt(alignment.textRotation);
569
- cellFormat.textRotation = rotation === 255 ? "vertical" : rotation;
658
+ // Excel encodes clockwise rotation as 90 + degrees (91–180); the engine
659
+ // keeps signed counter-clockwise degrees (-90…90) like the renderer.
660
+ cellFormat.textRotation =
661
+ rotation === 255
662
+ ? "vertical"
663
+ : rotation > 90
664
+ ? 90 - rotation
665
+ : rotation;
570
666
  }
571
667
  if (alignment.shrinkToFit === "1" || alignment.shrinkToFit === "true") {
572
668
  cellFormat.shrinkToFit = true;
@@ -2,4 +2,11 @@ import type { IWorkbookPlugin } from "./interface";
2
2
  export type PluginFactory = () => IWorkbookPlugin;
3
3
  export declare const PARSER_REGISTRY: Record<string, PluginFactory>;
4
4
  export declare function getPluginForFile(file: File | string): IWorkbookPlugin;
5
+ /**
6
+ * Content-aware plugin resolution. The extension picks the parser, except:
7
+ * an OOXML zip saved with a `.xls` name opens through the xlsx parser (Excel
8
+ * opens those too), and a BIFF (CFB) container opens through the `.xls`
9
+ * reader whatever its name says.
10
+ */
11
+ export declare function resolvePluginForBuffer(file: File | string, buffer: ArrayBuffer | File): Promise<IWorkbookPlugin>;
5
12
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../excel-parser/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAMnD,MAAM,MAAM,aAAa,GAAG,MAAM,eAAe,CAAC;AAElD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAKzD,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,eAAe,CAWrE"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../excel-parser/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAanD,MAAM,MAAM,aAAa,GAAG,MAAM,eAAe,CAAC;AAElD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAMzD,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,eAAe,CAWrE;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,GAAG,MAAM,EACnB,MAAM,EAAE,WAAW,GAAG,IAAI,GACzB,OAAO,CAAC,eAAe,CAAC,CAU1B"}
@@ -1,4 +1,6 @@
1
+ import { __awaiter, __generator } from "tslib";
1
2
  import { OdsPlugin } from "./plugins/ods/index";
3
+ import { CFB_SIGNATURE, readHeader, startsWith, XlsPlugin, ZIP_SIGNATURE, } from "./plugins/xls/index";
2
4
  import { XlsbPlugin } from "./plugins/xlsb/index";
3
5
  import { XlsmPlugin } from "./plugins/xlsm/index";
4
6
  import { XlsxPlugin } from "./plugins/xlsx/index";
@@ -6,6 +8,7 @@ export var PARSER_REGISTRY = {
6
8
  xlsx: function () { return new XlsxPlugin(); },
7
9
  xlsm: function () { return new XlsmPlugin(); },
8
10
  xlsb: function () { return new XlsbPlugin(); },
11
+ xls: function () { return new XlsPlugin(); },
9
12
  ods: function () { return new OdsPlugin(); },
10
13
  };
11
14
  export function getPluginForFile(file) {
@@ -19,3 +22,29 @@ export function getPluginForFile(file) {
19
22
  // Current behavior assumes everything is xlsx-like
20
23
  return new XlsxPlugin();
21
24
  }
25
+ /**
26
+ * Content-aware plugin resolution. The extension picks the parser, except:
27
+ * an OOXML zip saved with a `.xls` name opens through the xlsx parser (Excel
28
+ * opens those too), and a BIFF (CFB) container opens through the `.xls`
29
+ * reader whatever its name says.
30
+ */
31
+ export function resolvePluginForBuffer(file, buffer) {
32
+ return __awaiter(this, void 0, void 0, function () {
33
+ var header, plugin;
34
+ return __generator(this, function (_a) {
35
+ switch (_a.label) {
36
+ case 0: return [4 /*yield*/, readHeader(buffer, CFB_SIGNATURE.length)];
37
+ case 1:
38
+ header = _a.sent();
39
+ if (startsWith(header, CFB_SIGNATURE)) {
40
+ return [2 /*return*/, new XlsPlugin()];
41
+ }
42
+ plugin = getPluginForFile(file);
43
+ if (plugin instanceof XlsPlugin && startsWith(header, ZIP_SIGNATURE)) {
44
+ return [2 /*return*/, new XlsxPlugin()];
45
+ }
46
+ return [2 /*return*/, plugin];
47
+ }
48
+ });
49
+ });
50
+ }