@shbernal/ts-xlsx 2.1.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/README.md +4 -1
  2. package/dist/bytes.d.ts +7 -0
  3. package/dist/bytes.js +22 -0
  4. package/dist/core/address.d.ts +60 -2
  5. package/dist/core/address.js +40 -24
  6. package/dist/core/autofilter.d.ts +5 -4
  7. package/dist/core/autofilter.js +34 -35
  8. package/dist/core/axis-handle.d.ts +10 -0
  9. package/dist/core/axis-handle.js +17 -0
  10. package/dist/core/cell.d.ts +25 -0
  11. package/dist/core/cell.js +9 -3
  12. package/dist/core/clone.d.ts +29 -0
  13. package/dist/core/clone.js +24 -0
  14. package/dist/core/color-resolution.js +2 -4
  15. package/dist/core/column.d.ts +5 -1
  16. package/dist/core/column.js +34 -35
  17. package/dist/core/comment-thread.js +2 -1
  18. package/dist/core/conditional-formatting-overlay.d.ts +2 -1
  19. package/dist/core/conditional-formatting-overlay.js +2 -2
  20. package/dist/core/conditional-formatting.d.ts +14 -6
  21. package/dist/core/conditional-formatting.js +45 -43
  22. package/dist/core/containers.d.ts +12 -0
  23. package/dist/core/containers.js +5 -0
  24. package/dist/core/data-validation-overlay.d.ts +2 -1
  25. package/dist/core/data-validation-overlay.js +4 -4
  26. package/dist/core/data-validation.d.ts +9 -3
  27. package/dist/core/data-validation.js +21 -18
  28. package/dist/core/date-format.d.ts +20 -0
  29. package/dist/core/date-format.js +160 -0
  30. package/dist/core/date.d.ts +43 -8
  31. package/dist/core/date.js +18 -2
  32. package/dist/core/formula.d.ts +26 -0
  33. package/dist/core/formula.js +20 -4
  34. package/dist/core/grid-edits.d.ts +2 -3
  35. package/dist/core/grid-edits.js +69 -70
  36. package/dist/core/grid-shift.d.ts +58 -9
  37. package/dist/core/grid-shift.js +26 -4
  38. package/dist/core/image.d.ts +14 -10
  39. package/dist/core/image.js +9 -9
  40. package/dist/core/internal.d.ts +8 -2
  41. package/dist/core/limits.d.ts +23 -0
  42. package/dist/core/limits.js +4 -0
  43. package/dist/core/merge-index.d.ts +31 -0
  44. package/dist/core/merge-index.js +60 -0
  45. package/dist/core/merge.d.ts +5 -14
  46. package/dist/core/merge.js +18 -27
  47. package/dist/core/page-setup.d.ts +72 -2
  48. package/dist/core/page-setup.js +34 -8
  49. package/dist/core/pivot-table.d.ts +1 -1
  50. package/dist/core/pivot-table.js +67 -53
  51. package/dist/core/protection.js +2 -11
  52. package/dist/core/range.js +34 -30
  53. package/dist/core/row-input.js +2 -2
  54. package/dist/core/row.d.ts +5 -1
  55. package/dist/core/row.js +22 -23
  56. package/dist/core/style.d.ts +134 -75
  57. package/dist/core/style.js +112 -53
  58. package/dist/core/table-style.d.ts +1 -1
  59. package/dist/core/table-style.js +4 -4
  60. package/dist/core/table.d.ts +28 -10
  61. package/dist/core/table.js +54 -39
  62. package/dist/core/theme.js +6 -5
  63. package/dist/core/used-extent.d.ts +44 -0
  64. package/dist/core/used-extent.js +102 -0
  65. package/dist/core/value.d.ts +9 -0
  66. package/dist/core/value.js +36 -34
  67. package/dist/core/workbook-media.d.ts +34 -0
  68. package/dist/core/workbook-media.js +44 -0
  69. package/dist/core/workbook-styles.d.ts +67 -1
  70. package/dist/core/workbook-vba.js +3 -2
  71. package/dist/core/workbook.d.ts +23 -2
  72. package/dist/core/workbook.js +24 -40
  73. package/dist/core/worksheet-comments.d.ts +2 -1
  74. package/dist/core/worksheet-comments.js +20 -13
  75. package/dist/core/worksheet-merges.d.ts +44 -0
  76. package/dist/core/worksheet-merges.js +59 -0
  77. package/dist/core/worksheet-model.d.ts +9 -1
  78. package/dist/core/worksheet-model.js +24 -9
  79. package/dist/core/worksheet.d.ts +72 -12
  80. package/dist/core/worksheet.js +68 -70
  81. package/dist/customui/ribbon.js +6 -7
  82. package/dist/entries/core.d.ts +18 -13
  83. package/dist/entries/core.js +12 -6
  84. package/dist/entries/xlsx.d.ts +1 -1
  85. package/dist/errors.d.ts +64 -0
  86. package/dist/errors.js +22 -0
  87. package/dist/hex.d.ts +8 -0
  88. package/dist/hex.js +3 -0
  89. package/dist/io/csv/delimiter.d.ts +9 -0
  90. package/dist/io/csv/delimiter.js +6 -0
  91. package/dist/io/csv/read.js +11 -4
  92. package/dist/io/csv/write.d.ts +9 -2
  93. package/dist/io/csv/write.js +9 -38
  94. package/dist/io/opc/inflate.js +15 -1
  95. package/dist/io/opc/namespaces.d.ts +16 -0
  96. package/dist/io/opc/namespaces.js +4 -0
  97. package/dist/io/opc/part-paths.d.ts +10 -0
  98. package/dist/io/opc/part-paths.js +16 -1
  99. package/dist/io/opc/read-opc.d.ts +69 -10
  100. package/dist/io/opc/read-opc.js +49 -55
  101. package/dist/io/opc/read-options.d.ts +5 -1
  102. package/dist/io/opc/rels.d.ts +1 -6
  103. package/dist/io/opc/rels.js +1 -4
  104. package/dist/io/opc/sniff-format.d.ts +3 -3
  105. package/dist/io/opc/sniff-format.js +2 -2
  106. package/dist/io/style/xf-style.d.ts +48 -2
  107. package/dist/io/style/xf-style.js +14 -0
  108. package/dist/io/xlsb/formula.d.ts +2 -2
  109. package/dist/io/xlsb/formula.js +49 -34
  110. package/dist/io/xlsb/primitives.js +8 -14
  111. package/dist/io/xlsb/ptg-functions.d.ts +19 -10
  112. package/dist/io/xlsb/ptg-functions.js +385 -596
  113. package/dist/io/xlsb/read-styles.js +50 -83
  114. package/dist/io/xlsb/read-worksheet.d.ts +20 -1
  115. package/dist/io/xlsb/read-worksheet.js +73 -89
  116. package/dist/io/xlsb/read.d.ts +6 -3
  117. package/dist/io/xlsb/read.js +47 -29
  118. package/dist/io/xlsb/record-stream.d.ts +30 -0
  119. package/dist/io/xlsb/record-stream.js +20 -0
  120. package/dist/io/xlsb/record-types.d.ts +1 -5
  121. package/dist/io/xlsb/record-types.js +1 -5
  122. package/dist/io/xlsx/cell-accumulator.d.ts +9 -2
  123. package/dist/io/xlsx/cell-accumulator.js +32 -9
  124. package/dist/io/xlsx/cell-style-resolution.d.ts +25 -0
  125. package/dist/io/xlsx/cell-style-resolution.js +29 -0
  126. package/dist/io/xlsx/cell-value.d.ts +5 -3
  127. package/dist/io/xlsx/cell-value.js +13 -15
  128. package/dist/io/xlsx/color-xml.js +3 -2
  129. package/dist/io/xlsx/column-budget.d.ts +26 -0
  130. package/dist/io/xlsx/column-budget.js +22 -0
  131. package/dist/io/xlsx/comments.d.ts +6 -2
  132. package/dist/io/xlsx/comments.js +36 -31
  133. package/dist/io/xlsx/conditional-formatting.d.ts +9 -5
  134. package/dist/io/xlsx/conditional-formatting.js +51 -46
  135. package/dist/io/xlsx/data-validation.d.ts +9 -7
  136. package/dist/io/xlsx/data-validation.js +38 -35
  137. package/dist/io/xlsx/edit-vba.d.ts +7 -2
  138. package/dist/io/xlsx/edit-vba.js +15 -29
  139. package/dist/io/xlsx/font-xml.d.ts +7 -0
  140. package/dist/io/xlsx/font-xml.js +104 -0
  141. package/dist/io/xlsx/hyperlinks.d.ts +41 -7
  142. package/dist/io/xlsx/hyperlinks.js +40 -28
  143. package/dist/io/xlsx/images.js +24 -25
  144. package/dist/io/xlsx/namespaces.d.ts +16 -0
  145. package/dist/io/xlsx/namespaces.js +7 -0
  146. package/dist/io/xlsx/package-plan.d.ts +23 -3
  147. package/dist/io/xlsx/package-plan.js +66 -25
  148. package/dist/io/xlsx/part-names.d.ts +41 -0
  149. package/dist/io/xlsx/part-names.js +46 -0
  150. package/dist/io/xlsx/pivot.js +8 -7
  151. package/dist/io/xlsx/read-parts.d.ts +59 -0
  152. package/dist/io/xlsx/read-parts.js +252 -0
  153. package/dist/io/xlsx/read-pivot.js +3 -1
  154. package/dist/io/xlsx/read-repair.d.ts +26 -0
  155. package/dist/io/xlsx/read-repair.js +39 -0
  156. package/dist/io/xlsx/{rich-runs.d.ts → read-rich-runs.d.ts} +1 -1
  157. package/dist/io/xlsx/{rich-runs.js → read-rich-runs.js} +7 -3
  158. package/dist/io/xlsx/read-rows.d.ts +18 -5
  159. package/dist/io/xlsx/read-rows.js +50 -37
  160. package/dist/io/xlsx/read-shared-strings.js +5 -3
  161. package/dist/io/xlsx/read-styles.d.ts +1 -6
  162. package/dist/io/xlsx/read-styles.js +65 -109
  163. package/dist/io/xlsx/read-workbook-xml.d.ts +36 -0
  164. package/dist/io/xlsx/read-workbook-xml.js +170 -0
  165. package/dist/io/xlsx/read-worksheet.d.ts +11 -1
  166. package/dist/io/xlsx/read-worksheet.js +51 -193
  167. package/dist/io/xlsx/read.d.ts +5 -13
  168. package/dist/io/xlsx/read.js +111 -436
  169. package/dist/io/xlsx/rich-text.js +1 -1
  170. package/dist/io/xlsx/row-position.d.ts +18 -0
  171. package/dist/io/xlsx/row-position.js +11 -0
  172. package/dist/io/xlsx/row-xml.d.ts +128 -0
  173. package/dist/io/xlsx/row-xml.js +203 -0
  174. package/dist/io/xlsx/shared-formulas.js +2 -2
  175. package/dist/io/xlsx/sheet-properties.d.ts +10 -1
  176. package/dist/io/xlsx/sheet-properties.js +166 -37
  177. package/dist/io/xlsx/style-elements.d.ts +43 -0
  178. package/dist/io/xlsx/style-elements.js +156 -0
  179. package/dist/io/xlsx/styles.d.ts +12 -3
  180. package/dist/io/xlsx/styles.js +5 -204
  181. package/dist/io/xlsx/tables.js +11 -14
  182. package/dist/io/xlsx/theme-xml.d.ts +26 -4
  183. package/dist/io/xlsx/theme-xml.js +107 -69
  184. package/dist/io/xlsx/threaded-comments.d.ts +8 -10
  185. package/dist/io/xlsx/threaded-comments.js +3 -1
  186. package/dist/io/xlsx/workbook-xml.d.ts +54 -4
  187. package/dist/io/xlsx/workbook-xml.js +84 -57
  188. package/dist/io/xlsx/worksheet-xml.d.ts +23 -70
  189. package/dist/io/xlsx/worksheet-xml.js +59 -242
  190. package/dist/io/xlsx/write-stream.d.ts +71 -16
  191. package/dist/io/xlsx/write-stream.js +79 -41
  192. package/dist/io/xlsx/write.d.ts +6 -2
  193. package/dist/io/xlsx/write.js +217 -153
  194. package/dist/rel-type.d.ts +16 -0
  195. package/dist/rel-type.js +6 -0
  196. package/dist/token-set.d.ts +28 -0
  197. package/dist/token-set.js +7 -0
  198. package/dist/vba/bytes.d.ts +14 -5
  199. package/dist/vba/bytes.js +16 -6
  200. package/dist/vba/cfb-format.d.ts +32 -0
  201. package/dist/vba/cfb-format.js +13 -0
  202. package/dist/vba/cfb-writer.d.ts +9 -0
  203. package/dist/vba/cfb-writer.js +28 -25
  204. package/dist/vba/cfb.d.ts +13 -1
  205. package/dist/vba/cfb.js +73 -57
  206. package/dist/vba/codepage.js +2 -1
  207. package/dist/vba/errors.d.ts +7 -0
  208. package/dist/vba/ms-ovba.js +79 -23
  209. package/dist/vba/project-editor.js +35 -40
  210. package/dist/vba/project.d.ts +11 -1
  211. package/dist/vba/project.js +40 -21
  212. package/dist/vba/vba-encoding.js +5 -6
  213. package/dist/xml/xml-attrs.d.ts +37 -0
  214. package/dist/xml/xml-attrs.js +30 -0
  215. package/dist/xml/xml-chars.d.ts +40 -0
  216. package/dist/xml/xml-chars.js +12 -0
  217. package/dist/xml/xml-namespaces.d.ts +31 -0
  218. package/dist/xml/xml-namespaces.js +50 -0
  219. package/dist/xml/xml-read.d.ts +128 -81
  220. package/dist/xml/xml-read.js +161 -178
  221. package/dist/xml/xml-scan.d.ts +78 -0
  222. package/dist/xml/xml-scan.js +180 -0
  223. package/dist/xml/xml.d.ts +29 -28
  224. package/dist/xml/xml.js +24 -24
  225. package/package.json +13 -9
@@ -1,13 +1,21 @@
1
- import { MAX_COLUMN, MAX_ROW, tryDecodeRange } from '../../core/address.js';
1
+ import { tryDecodeRange } from '../../core/address.js';
2
2
  import { isCustomFilterOperator, } from '../../core/autofilter.js';
3
3
  import { INTERNAL } from '../../core/internal.js';
4
- import { isPageOrder, isPageOrientation, } from '../../core/page-setup.js';
5
- import { SHEET_PROTECTION_FLAGS, } from '../../core/protection.js';
4
+ import { HEADER_FOOTER_ELEMENTS } from '../../core/page-setup.js';
6
5
  import { assignStyleFacets } from '../../core/style.js';
7
- import { boolPresent, boolStrict, boolTristate, decodeSpreadsheetText, enumToken, localName, numFinite, numInteger, parseXml, } from '../../xml/xml-read.js';
6
+ import { decodeSpreadsheetText, numFinite, numInteger } from '../../xml/xml-attrs.js';
7
+ import {} from '../../xml/xml-read.js';
8
+ import { boolPresent, boolStrict, localName } from '../../xml/xml-scan.js';
8
9
  import { CellAccumulator } from './cell-accumulator.js';
9
- import { parseColor } from './color-xml.js';
10
- const MARGIN_SIDES = ['left', 'right', 'top', 'bottom', 'header', 'footer'];
10
+ import { CellStyleResolver } from './cell-style-resolution.js';
11
+ import { ColumnRecordBudget, takeColumnSpan } from './column-budget.js';
12
+ import { admitting } from './read-repair.js';
13
+ import { RowPositionTracker } from './row-position.js';
14
+ import { applySheetProperties, PageBreakAccumulator, parseSheetProtection, } from './sheet-properties.js';
15
+ const HEADER_FOOTER_CHILDREN = new Set(HEADER_FOOTER_ELEMENTS);
16
+ function isHeaderFooterElement(local) {
17
+ return HEADER_FOOTER_CHILDREN.has(local);
18
+ }
11
19
  const WORKSHEET_EMPTY_CLOSES = new Set(['c', 'autoFilter']);
12
20
  function pendingFilterCriteria(values, blank, predicates, and) {
13
21
  if (values !== null && (values.length > 0 || blank)) {
@@ -18,31 +26,6 @@ function pendingFilterCriteria(values, blank, predicates, and) {
18
26
  }
19
27
  return null;
20
28
  }
21
- function parseSheetProtection(attrs) {
22
- if (attrs.sheet === '0' || attrs.sheet === 'false')
23
- return undefined;
24
- const flags = {};
25
- for (const { key } of SHEET_PROTECTION_FLAGS) {
26
- const raw = attrs[key];
27
- if (raw !== undefined)
28
- flags[key] = !boolStrict(raw);
29
- }
30
- const { algorithmName, hashValue, saltValue, spinCount } = attrs;
31
- const spin = numInteger(spinCount, 0);
32
- if (algorithmName !== undefined &&
33
- hashValue !== undefined &&
34
- saltValue !== undefined &&
35
- spin !== undefined) {
36
- const credential = {
37
- algorithmName,
38
- hashValue,
39
- saltValue,
40
- spinCount: spin,
41
- };
42
- return { flags, credential };
43
- }
44
- return { flags };
45
- }
46
29
  class AutoFilterAccumulator {
47
30
  #ref = null;
48
31
  #columns = [];
@@ -102,76 +85,48 @@ class AutoFilterAccumulator {
102
85
  this.#columns = [];
103
86
  }
104
87
  }
105
- class PageBreakAccumulator {
106
- #target = null;
107
- begin(target) {
108
- this.#target = target;
109
- }
110
- end() {
111
- this.#target = null;
112
- }
113
- add(attrs) {
114
- if (this.#target === null)
115
- return;
116
- const id = numInteger(attrs.id, 1);
117
- if (id === undefined)
118
- return;
119
- const brk = { id };
120
- const max = numInteger(attrs.max, 0);
121
- if (max !== undefined)
122
- brk.max = max;
123
- if (boolStrict(attrs.man))
124
- brk.man = true;
125
- this.#target.push(brk);
126
- }
127
- }
128
- export function parseWorksheet(xml, sheet, sharedStrings, xfStyles) {
129
- const cell = new CellAccumulator({ richRuns: true });
130
- let rowStyle = -1;
131
- let rowCustomFormat = false;
88
+ export function worksheetPass(sheet, sharedStrings, xfStyles, dateEpoch) {
89
+ const cell = new CellAccumulator({ richRuns: true, dateEpoch });
132
90
  const autoFilter = new AutoFilterAccumulator();
133
91
  const pageBreaks = new PageBreakAccumulator();
134
- const columnStyle = new Map();
92
+ const styleResolution = new CellStyleResolver();
93
+ const columnBudget = new ColumnRecordBudget();
94
+ const rowPosition = new RowPositionTracker();
135
95
  const finalizeCellFromState = () => {
136
- const styleIndex = cell.styleIndex >= 0
137
- ? cell.styleIndex
138
- : rowCustomFormat && rowStyle >= 0
139
- ? rowStyle
140
- : (columnStyle.get(cell.col) ?? -1);
96
+ const styleIndex = styleResolution.indexFor(cell.col, cell.styleIndex);
141
97
  const style = styleIndex >= 0 ? xfStyles[styleIndex] : xfStyles[0];
142
98
  cell.finalize(sheet, sharedStrings, style);
143
99
  };
144
- parseXml(xml, {
100
+ const handlers = {
145
101
  onOpen(name, attrs, selfClosing) {
146
102
  const local = localName(name);
147
103
  if (cell.openElement(local, attrs, selfClosing))
148
104
  return;
105
+ if (HEADER_FOOTER_CHILDREN.has(local)) {
106
+ cell.capture();
107
+ return;
108
+ }
149
109
  switch (local) {
150
110
  case 'col':
151
- applyColumn(sheet, attrs, xfStyles, columnStyle);
152
- break;
153
- case 'row':
154
- applyRow(sheet, attrs);
155
- rowStyle = numInteger(attrs.s, 0) ?? -1;
156
- rowCustomFormat = boolStrict(attrs.customFormat);
111
+ applyColumn(sheet, attrs, xfStyles, styleResolution, columnBudget);
157
112
  break;
158
- case 'oddHeader':
159
- case 'oddFooter':
160
- case 'evenHeader':
161
- case 'evenFooter':
162
- case 'firstHeader':
163
- case 'firstFooter':
164
- cell.capture();
113
+ case 'row': {
114
+ const { number, inGrid } = rowPosition.open(attrs);
115
+ if (inGrid)
116
+ applyRow(sheet, number, attrs);
117
+ cell.openRow(inGrid ? number : -1);
118
+ styleResolution.openRow(attrs);
165
119
  break;
120
+ }
166
121
  case 'mergeCell':
167
122
  if (attrs.ref !== undefined && attrs.ref !== '') {
168
- try {
169
- sheet.mergeCells(attrs.ref);
170
- }
171
- catch {
172
- }
123
+ const ref = attrs.ref;
124
+ admitting(() => {
125
+ sheet.mergeCells(ref);
126
+ });
173
127
  }
174
128
  break;
129
+ case 'sheetPr':
175
130
  case 'tabColor':
176
131
  case 'outlinePr':
177
132
  case 'sheetView':
@@ -229,18 +184,13 @@ export function parseWorksheet(xml, sheet, sharedStrings, xfStyles) {
229
184
  }
230
185
  if (claimed === 'claimed')
231
186
  return;
187
+ if (isHeaderFooterElement(local)) {
188
+ sheet.headerFooter[local] = decodeSpreadsheetText(cell.capturedText);
189
+ return;
190
+ }
232
191
  switch (local) {
233
- case 'oddHeader':
234
- case 'oddFooter':
235
- case 'evenHeader':
236
- case 'evenFooter':
237
- case 'firstHeader':
238
- case 'firstFooter':
239
- sheet.headerFooter[local] = decodeSpreadsheetText(cell.capturedText);
240
- break;
241
192
  case 'row':
242
- rowStyle = -1;
243
- rowCustomFormat = false;
193
+ styleResolution.closeRow();
244
194
  break;
245
195
  case 'filterColumn':
246
196
  autoFilter.endColumn();
@@ -256,58 +206,14 @@ export function parseWorksheet(xml, sheet, sharedStrings, xfStyles) {
256
206
  break;
257
207
  }
258
208
  },
259
- }, { closeEmptyElements: WORKSHEET_EMPTY_CLOSES });
260
- }
261
- function applySheetProperties(local, attrs, sheet) {
262
- switch (local) {
263
- case 'tabColor':
264
- sheet.tabColor = parseColor(attrs);
265
- break;
266
- case 'outlinePr':
267
- if (attrs.summaryBelow !== undefined)
268
- sheet.outline.summaryBelow = boolPresent(attrs.summaryBelow);
269
- if (attrs.summaryRight !== undefined)
270
- sheet.outline.summaryRight = boolPresent(attrs.summaryRight);
271
- break;
272
- case 'sheetView':
273
- if (attrs.showGridLines !== undefined && !boolPresent(attrs.showGridLines)) {
274
- sheet.view.showGridLines = false;
275
- }
276
- break;
277
- case 'pane':
278
- if (attrs.state === 'frozen' || attrs.state === 'frozenSplit') {
279
- sheet.view.state = 'frozen';
280
- const xSplit = numInteger(attrs.xSplit, 0);
281
- const ySplit = numInteger(attrs.ySplit, 0);
282
- if (xSplit !== undefined)
283
- sheet.view.xSplit = xSplit;
284
- if (ySplit !== undefined)
285
- sheet.view.ySplit = ySplit;
286
- if (attrs.topLeftCell !== undefined)
287
- sheet.view.topLeftCell = attrs.topLeftCell;
288
- }
289
- break;
290
- case 'pageSetUpPr':
291
- if (attrs.fitToPage !== undefined)
292
- sheet.pageSetup.fitToPage = boolPresent(attrs.fitToPage);
293
- break;
294
- case 'printOptions':
295
- applyPrintOptions(sheet.printOptions, attrs);
296
- break;
297
- case 'pageMargins':
298
- applyMargins(sheet.pageMargins, attrs);
299
- break;
300
- case 'pageSetup':
301
- applyPageSetup(sheet.pageSetup, attrs);
302
- break;
303
- }
209
+ };
210
+ return { handlers, closeEmptyElements: WORKSHEET_EMPTY_CLOSES };
304
211
  }
305
- function applyColumn(sheet, attrs, xfStyles, columnStyle) {
306
- const min = numInteger(attrs.min, 1);
307
- const max = numInteger(attrs.max, 1);
308
- if (min === undefined || max === undefined || min > MAX_COLUMN)
212
+ function applyColumn(sheet, attrs, xfStyles, styleResolution, budget) {
213
+ const span = takeColumnSpan(attrs, budget);
214
+ if (span === undefined)
309
215
  return;
310
- const last = Math.min(max, MAX_COLUMN);
216
+ const { first: min, last } = span;
311
217
  const width = numFinite(attrs.width);
312
218
  const hidden = boolStrict(attrs.hidden);
313
219
  const styleIndex = numInteger(attrs.style, 0) ?? -1;
@@ -325,14 +231,10 @@ function applyColumn(sheet, attrs, xfStyles, columnStyle) {
325
231
  column.collapsed = true;
326
232
  if (style !== undefined)
327
233
  assignStyleFacets(column, style);
328
- if (styleIndex >= 0)
329
- columnStyle.set(index, styleIndex);
330
234
  }
235
+ styleResolution.noteColumnSpan(min, last, attrs);
331
236
  }
332
- function applyRow(sheet, attrs) {
333
- const number = numInteger(attrs.r, 1);
334
- if (number === undefined || number > MAX_ROW)
335
- return;
237
+ function applyRow(sheet, number, attrs) {
336
238
  const row = sheet.getRow(number);
337
239
  const height = numFinite(attrs.ht);
338
240
  if (height !== undefined && boolPresent(attrs.customHeight))
@@ -345,47 +247,3 @@ function applyRow(sheet, attrs) {
345
247
  if (boolStrict(attrs.collapsed))
346
248
  row.collapsed = true;
347
249
  }
348
- function applyPrintOptions(printOptions, attrs) {
349
- const horizontalCentered = boolTristate(attrs.horizontalCentered);
350
- if (horizontalCentered !== undefined)
351
- printOptions.horizontalCentered = horizontalCentered;
352
- const verticalCentered = boolTristate(attrs.verticalCentered);
353
- if (verticalCentered !== undefined)
354
- printOptions.verticalCentered = verticalCentered;
355
- const headings = boolTristate(attrs.headings);
356
- if (headings !== undefined)
357
- printOptions.headings = headings;
358
- const gridLines = boolTristate(attrs.gridLines);
359
- if (gridLines !== undefined)
360
- printOptions.gridLines = gridLines;
361
- const gridLinesSet = boolTristate(attrs.gridLinesSet);
362
- if (gridLinesSet !== undefined)
363
- printOptions.gridLinesSet = gridLinesSet;
364
- }
365
- function applyMargins(margins, attrs) {
366
- for (const side of MARGIN_SIDES) {
367
- const value = numFinite(attrs[side]);
368
- if (value !== undefined)
369
- margins[side] = value;
370
- }
371
- }
372
- function applyPageSetup(pageSetup, attrs) {
373
- const paperSize = numInteger(attrs.paperSize, 0);
374
- if (paperSize !== undefined)
375
- pageSetup.paperSize = paperSize;
376
- const scale = numInteger(attrs.scale, 0);
377
- if (scale !== undefined)
378
- pageSetup.scale = scale;
379
- const fitToWidth = numInteger(attrs.fitToWidth, 0);
380
- if (fitToWidth !== undefined)
381
- pageSetup.fitToWidth = fitToWidth;
382
- const fitToHeight = numInteger(attrs.fitToHeight, 0);
383
- if (fitToHeight !== undefined)
384
- pageSetup.fitToHeight = fitToHeight;
385
- const pageOrder = enumToken(attrs.pageOrder, isPageOrder);
386
- if (pageOrder !== undefined)
387
- pageSetup.pageOrder = pageOrder;
388
- const orientation = enumToken(attrs.orientation, isPageOrientation);
389
- if (orientation !== undefined)
390
- pageSetup.orientation = orientation;
391
- }
@@ -1,10 +1,9 @@
1
- import { Workbook, type WorkbookView } from '../../core/workbook.ts';
2
- import { type WorksheetState } from '../../core/worksheet.ts';
3
- import { type ReadXlsxOptions } from '../opc/read-options.ts';
4
- export { parseRelationships, resolveWorkbookPart } from '../opc/read-opc.ts';
5
- export { DEFAULT_MAX_UNCOMPRESSED, type ReadXlsxOptions } from '../opc/read-options.ts';
1
+ import { Workbook } from '../../core/workbook.ts';
2
+ import type { ReadPackageOptions } from '../opc/read-options.ts';
3
+ export type { ReadPackageOptions } from '../opc/read-options.ts';
6
4
  export type { StyleTable, XfStyle } from '../style/xf-style.ts';
7
5
  export { parseStyleTable } from './read-styles.ts';
6
+ export { type SheetEntry, workbookPropertiesPass, workbookSheetsPass, workbookViewPass, } from './read-workbook-xml.ts';
8
7
  /**
9
8
  * Read a spreadsheet package into a {@link Workbook}.
10
9
  *
@@ -20,11 +19,4 @@ export { parseStyleTable } from './read-styles.ts';
20
19
  * @throws {PackageReadError} if the input is a ZIP that cannot be unpacked: a corrupt or
21
20
  * truncated archive, or one exceeding the inflate bound (a probable zip bomb).
22
21
  */
23
- export declare function readXlsx(data: Uint8Array, options?: ReadXlsxOptions): Workbook;
24
- export interface SheetEntry {
25
- readonly name: string;
26
- readonly relId: string;
27
- readonly state?: WorksheetState['state'];
28
- }
29
- export declare function parseWorkbookSheets(xml: string): SheetEntry[];
30
- export declare function applyWorkbookView(view: WorkbookView, xml: string): void;
22
+ export declare function readXlsx(data: Uint8Array, options?: ReadPackageOptions): Workbook;