xls-codec 4.2.3 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,6 +21,7 @@ Under active development, with real, tested **read and write** support. Built an
21
21
  - **Cell decoration** — a cell's background fill (every named `FillPattern` value, solid and pattern alike) and per-side borders, read from and written to `XF`'s trailing `CellXF` payload plus the workbook's own `Palette` record, in both directions and verified against real LibreOffice-produced BIFF8, not just this package's own round trip (see [Cell decoration](#cell-decoration)).
22
22
  - **Print settings** — every field of `ContentSheetPrintSettings`: page size and orientation, all four margins, gridline and row/column-header printing, page order, print scale or fit-to-page counts, manual page breaks, the print range, and the repeated header rows and columns — read from and written to the nine worksheet-substream records and the two built-in defined names that carry them, in both directions and verified against real LibreOffice-produced BIFF8 (see [Print settings](#print-settings)).
23
23
  - **Cell alignment** — a cell's own horizontal (`left`/`center`/`right`/`justify`) and vertical (`top`/`middle`) alignment, read from and written to `XF`'s trailing `CellXF`/`StyleXF` payload's own leading word, in both directions and verified against real LibreOffice-produced BIFF8 (see [Cell alignment](#cell-alignment)).
24
+ - **Data validation, read-only (ExaDev/documents.js#1098)** — a sheet's own `Dv` records (`src/workbook/data-validation.ts`) into `ContentSheet.dataValidations`: type, comparison operator, one or two formulas (via the same `Ptg` reader `Formula` records already use), allow-blank/show-input/show-error flags, error style, and prompt/error titles and messages, resolved directly against [MS-XLS]'s own published `Dv`/`DVal`/`DVParsedFormula`/`SqRefU` field layouts rather than a producer-specific convention.
24
25
 
25
26
  Verified primarily by round trip (`src/write.test.ts`, plus a dedicated `test/workers/write.test.ts` proving the whole write path inside a real `workerd` isolate, not just Node): build a `ContentDocument`, write it, read it back through this package's own independently-pinned reader, and check the result. Every record's own byte layout is additionally cited to its [MS-XLS] section in the writer's source, matching the reader's own convention.
26
27
 
@@ -34,7 +35,8 @@ What `writeXlsContent`/`writeXls` cover: every `ContentCellValue` kind a real `.
34
35
  | Per-cell font | The reader does not read one back: `ContentSheetCell` has no cell-level font field at all (`ooxml.js`'s xlsx reader makes the identical font-scope choice), so writing a real value here would be unverifiable by round trip. Every `XF` this writer emits still references the same single font. |
35
36
  | `MulBlank`/`RK`/`MulRk` | Pure compaction optimisations over information a plain `Blank`/`Number`/`LabelSst`/`BoolErr` record already carries losslessly. (`Blank` itself _is_ written, for a formatted empty cell — see the `empty` row below.) |
36
37
  | An `empty`-kind cell carrying no formatting | Written as nothing at all, which is what round-trips: `content.ts`'s reader drops an unformatted blank cell it reads, and a merged range's empty anchor is independently reconstructed from `MergeCells` alone. A formatted one (a fill, a border, or a non-default alignment) is the opposite case — its formatting exists only in the `XF` a cell record names, so it gets a real `Blank` record ([MS-XLS] 2.4.20) and round-trips with that formatting intact. |
37
- | Images, embedded objects, data validation, conditional formatting, defined names (`Lbl`) | Not read either (see below); there is no round trip to verify a writer for them against. |
38
+ | Images, embedded objects, conditional formatting, defined names (`Lbl`) | Not read either (see below); there is no round trip to verify a writer for them against. |
39
+ | Data validation (`Dv`/`DVal`) | The reader now recovers a sheet's own validation rules (see Read-side gaps below), but writing them back out is its own separate mechanism -- re-encoding a formula's own text back into `Ptg` tokens for `Dv`'s two `DVParsedFormula` fields, the same "not folded into recovering the read side" split this table already draws for `Formula` records. A `ContentSheet.dataValidations` is silently ignored on write. |
38
40
  | Cell comments (`Note`/`Txo`) | The reader now recovers a cell's comment (see Read-side gaps below), but writing one back out is its own separate mechanism -- a `Note`/`Obj`/`Txo` triple with its own object-id bookkeeping, distinct from every other cell record this writer already emits -- scoped as its own piece of work rather than folded into recovering the read side, the same split this table already draws for `Formula` records. A `ContentSheetCell.comment` is silently ignored on write. |
39
41
  | A page size no `iPaperSize` code names | Written as [MS-XLS] 2.4.257's own custom-paper value rather than as a named paper it is not — the dimensions themselves are unwritable, since `Setup` addresses paper only by code. See [Print settings](#print-settings). |
40
42
  | `Window1`/`Window2`, `CodePage`, `Index`/`DBCell`, the legacy interface records (`InterfaceHdr`, `WriteAccess`, …) | UI and interoperability bookkeeping [MS-XLS]'s own grammar names in the globals/worksheet substreams alongside the content-carrying records above, not data. `Index`/`DBCell` specifically is a pure cell-lookup performance optimisation (see [MS-XLS]'s own "Retrieval of Last-Calculated Cell Values Without Loading Cell Table") that this reader — and Excel's own reader — does not require to find a cell; real, well-established minimal BIFF8 writers (e.g. Python's `xlwt`) omit the same set and produce files Excel opens correctly. The calculation-state records (`CalcCount`, `CalcRefMode`, `CalcIter`, `CalcDelta`, `CalcSaveRecalc`) sat in this row until print settings needed them — see [Print settings](#print-settings) for why the writer emits them now. |
@@ -50,7 +52,8 @@ Each deliberate rather than overlooked:
50
52
  - **Cell decoration and alignment resolved for real; font still not.** `XF`'s trailing `CellXF` payload's fill pattern/colours and per-side border style/colour are read and resolved through the `Palette` record (or the default colour table when one is absent) — see [Cell decoration](#cell-decoration) for the full mapping, including every named pattern beyond solid, and how this was verified against real LibreOffice-produced BIFF8. The same payload's leading word is resolved too — see [Cell alignment](#cell-alignment) for the full `alc`/`alcV` mapping. `Font` records are not read at all: `ContentSheetCell` has no cell-level font field, and `ooxml.js`'s xlsx reader makes the identical scope choice.
51
53
  - **Print settings, resolved for real.** Every field of `ContentSheetPrintSettings` is read from the records that carry it, with Excel's own "Normal" preset standing in per field for whatever the file leaves unstated — see [Print settings](#print-settings) for the record map, the two of BIFF8's own conditional rules that decide how to read `Setup`, and the three things that genuinely do not come through.
52
54
  - **Cell comments, resolved for real (ExaDev/documents.js#949).** A legacy BIFF8 comment is split across three record kinds a single self-contained xlsx `<comment>` element never needs: a `Note` record ([MS-XLS] 2.4.179, wrapping a `NoteSh` structure) anchors the comment to a cell and names its author, but carries no text of its own; the text lives in a `Txo` record ([MS-XLS] 2.4.329), its characters carried across trailing `Continue` records; the two are joined through an `Obj` record ([MS-XLS] 2.4.181) whose `FtCmo` names an object id and type, the `Note`'s own `idObj` field naming that same id, and a `Txo` always immediately following the `Obj` record whose shape it belongs to (`src/workbook/comments.ts`). Read in one independent pass over the whole worksheet substream rather than assuming stream order between a `Note` and the `Obj`+`Txo` pair it names -- both are resolved regardless of which comes first. Legacy BIFF8 has no threading and no per-comment timestamp at all (unlike xlsx's own `[MS-XLSX]` threaded-comments extension), so `ContentSheetCellComment.replies` and `.createdAt` are never populated from an `.xls` source; rich per-character formatting within a comment (`TxORuns`) is skipped rather than modelled, the same scope limit this reader already applies to the shared string table's own rich runs, since `ContentSheetCellComment.text` is a plain string with nowhere to carry them.
53
- - **Not read at all:** charts, drawings and images, data validation, and conditional formatting. Defined names (`Lbl`) are read only for the two built-in ones a sheet's print range and repeated header bands live in ([Print settings](#print-settings)); a user-defined name has nowhere to land in `document-schema.js`'s spreadsheet model, so it is skipped.
55
+ - **Data validation, resolved for real (ExaDev/documents.js#1098).** `Dv` ([MS-XLS] 2.4.95) is a fixed, published binary structure -- a bit-packed flags `DWORD` (`valType`/`errStyle`/`fAllowBlank`/`fShowInputMsg`/`fShowErrorMsg`/`typOperator`), four `XLUnicodeString`s (prompt/error titles and messages), one or two `DVParsedFormula` structures, and a trailing `SqRefU` range list -- read directly against that spec (`src/workbook/data-validation.ts`), unlike `calcext:condition`'s own LibreOffice-source-transcribed mini-language odf.js's equivalent reader needed. A `DVParsedFormula`'s own `rgce` is the identical `Ptg` token grammar a cell's `Formula` record carries, so its formula text is recovered with the same `parseFormulaText` this reader already uses for ordinary cell formulas. `DVal` ([MS-XLS] 2.4.96), the record that precedes a sheet's own `Dv` collection, carries only input-window UI state (position, drop-down `Obj` reference) with no counterpart in `ContentSheetDataValidationSchema` and is not read for its own fields. BIFF8's `CF`/`CFEx`/`CondFmt` conditional-formatting records remain unread (ExaDev/documents.js#1100) -- a separate record family, its own cycle.
56
+ - **Not read at all:** charts, drawings and images, and conditional formatting (`CF`/`CFEx`/`CondFmt`, ExaDev/documents.js#1100). Defined names (`Lbl`) are read only for the two built-in ones a sheet's print range and repeated header bands live in ([Print settings](#print-settings)); a user-defined name has nowhere to land in `document-schema.js`'s spreadsheet model, so it is skipped.
54
57
  - **Encrypted workbooks** are refused rather than mis-read: a `FilePass` record means every record after it is ciphertext.
55
58
 
56
59
  This package is wired into `documents.js`'s conversion registry (`xlsToPdf`/`pdfToXls`, `convertDocument("xls", ...)`, and every same-variant spreadsheet bridge) — see that package's own README Fidelity table for exactly which pairs route and which don't. Remaining read+write scope gaps (formula writing and per-cell font) are tracked on [#815](https://github.com/ExaDev/documents.js/issues/815).
@@ -42,6 +42,10 @@ const RECORD_DEFCOLWIDTH = 85;
42
42
  const RECORD_DEFAULTROWHEIGHT = 549;
43
43
  /** Merged cell ranges ([MS-XLS] 2.4.168). */
44
44
  const RECORD_MERGECELLS = 229;
45
+ /** Marks the start of a collection of Dv records and carries only input-window UI state (position, drop-down Obj reference) this reader does not model ([MS-XLS] 2.4.96). Not read for its own fields -- the Dv records that follow it are found by type, not counted against DVal's own idvMac. */
46
+ const RECORD_DVAL = 434;
47
+ /** One data-validation rule: its type/operator/error-style/flags, prompt and error text, one or two formulas, and the cell ranges it applies to ([MS-XLS] 2.4.95). */
48
+ const RECORD_DV = 446;
45
49
  /** A cell comment's anchor -- row, column, and its own author, linking to the Obj record that names its text ([MS-XLS] 2.4.179). */
46
50
  const RECORD_NOTE = 28;
47
51
  /** A drawing object's common properties (id, type) and, for a comment, its FtNts sub-structure ([MS-XLS] 2.4.181). */
@@ -140,6 +144,8 @@ exports.RECORD_DATE1904 = RECORD_DATE1904;
140
144
  exports.RECORD_DEFAULTROWHEIGHT = RECORD_DEFAULTROWHEIGHT;
141
145
  exports.RECORD_DEFCOLWIDTH = RECORD_DEFCOLWIDTH;
142
146
  exports.RECORD_DIMENSIONS = RECORD_DIMENSIONS;
147
+ exports.RECORD_DV = RECORD_DV;
148
+ exports.RECORD_DVAL = RECORD_DVAL;
143
149
  exports.RECORD_EOF = RECORD_EOF;
144
150
  exports.RECORD_EXTERNSHEET = RECORD_EXTERNSHEET;
145
151
  exports.RECORD_FILEPASS = RECORD_FILEPASS;
@@ -41,6 +41,10 @@ declare const RECORD_DEFCOLWIDTH = 85;
41
41
  declare const RECORD_DEFAULTROWHEIGHT = 549;
42
42
  /** Merged cell ranges ([MS-XLS] 2.4.168). */
43
43
  declare const RECORD_MERGECELLS = 229;
44
+ /** Marks the start of a collection of Dv records and carries only input-window UI state (position, drop-down Obj reference) this reader does not model ([MS-XLS] 2.4.96). Not read for its own fields -- the Dv records that follow it are found by type, not counted against DVal's own idvMac. */
45
+ declare const RECORD_DVAL = 434;
46
+ /** One data-validation rule: its type/operator/error-style/flags, prompt and error text, one or two formulas, and the cell ranges it applies to ([MS-XLS] 2.4.95). */
47
+ declare const RECORD_DV = 446;
44
48
  /** A cell comment's anchor -- row, column, and its own author, linking to the Obj record that names its text ([MS-XLS] 2.4.179). */
45
49
  declare const RECORD_NOTE = 28;
46
50
  /** A drawing object's common properties (id, type) and, for a comment, its FtNts sub-structure ([MS-XLS] 2.4.181). */
@@ -116,4 +120,4 @@ declare const BIFF8_VERSION = 1536;
116
120
  /** [MS-XLS] 2.1.4: "The record size ... MUST be less than or equal to 8224." The ceiling a writer splits a record at, and the bound a reader can sanity-check a declared size against. */
117
121
  declare const MAX_RECORD_DATA_SIZE = 8224;
118
122
  //#endregion
119
- export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF };
123
+ export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_DV, RECORD_DVAL, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF };
@@ -41,6 +41,10 @@ declare const RECORD_DEFCOLWIDTH = 85;
41
41
  declare const RECORD_DEFAULTROWHEIGHT = 549;
42
42
  /** Merged cell ranges ([MS-XLS] 2.4.168). */
43
43
  declare const RECORD_MERGECELLS = 229;
44
+ /** Marks the start of a collection of Dv records and carries only input-window UI state (position, drop-down Obj reference) this reader does not model ([MS-XLS] 2.4.96). Not read for its own fields -- the Dv records that follow it are found by type, not counted against DVal's own idvMac. */
45
+ declare const RECORD_DVAL = 434;
46
+ /** One data-validation rule: its type/operator/error-style/flags, prompt and error text, one or two formulas, and the cell ranges it applies to ([MS-XLS] 2.4.95). */
47
+ declare const RECORD_DV = 446;
44
48
  /** A cell comment's anchor -- row, column, and its own author, linking to the Obj record that names its text ([MS-XLS] 2.4.179). */
45
49
  declare const RECORD_NOTE = 28;
46
50
  /** A drawing object's common properties (id, type) and, for a comment, its FtNts sub-structure ([MS-XLS] 2.4.181). */
@@ -116,4 +120,4 @@ declare const BIFF8_VERSION = 1536;
116
120
  /** [MS-XLS] 2.1.4: "The record size ... MUST be less than or equal to 8224." The ceiling a writer splits a record at, and the bound a reader can sanity-check a declared size against. */
117
121
  declare const MAX_RECORD_DATA_SIZE = 8224;
118
122
  //#endregion
119
- export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF };
123
+ export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_DV, RECORD_DVAL, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF };
@@ -41,6 +41,10 @@ const RECORD_DEFCOLWIDTH = 85;
41
41
  const RECORD_DEFAULTROWHEIGHT = 549;
42
42
  /** Merged cell ranges ([MS-XLS] 2.4.168). */
43
43
  const RECORD_MERGECELLS = 229;
44
+ /** Marks the start of a collection of Dv records and carries only input-window UI state (position, drop-down Obj reference) this reader does not model ([MS-XLS] 2.4.96). Not read for its own fields -- the Dv records that follow it are found by type, not counted against DVal's own idvMac. */
45
+ const RECORD_DVAL = 434;
46
+ /** One data-validation rule: its type/operator/error-style/flags, prompt and error text, one or two formulas, and the cell ranges it applies to ([MS-XLS] 2.4.95). */
47
+ const RECORD_DV = 446;
44
48
  /** A cell comment's anchor -- row, column, and its own author, linking to the Obj record that names its text ([MS-XLS] 2.4.179). */
45
49
  const RECORD_NOTE = 28;
46
50
  /** A drawing object's common properties (id, type) and, for a comment, its FtNts sub-structure ([MS-XLS] 2.4.181). */
@@ -116,4 +120,4 @@ const BIFF8_VERSION = 1536;
116
120
  /** [MS-XLS] 2.1.4: "The record size ... MUST be less than or equal to 8224." The ceiling a writer splits a record at, and the bound a reader can sanity-check a declared size against. */
117
121
  const MAX_RECORD_DATA_SIZE = 8224;
118
122
  //#endregion
119
- export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF };
123
+ export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_DV, RECORD_DVAL, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF };
package/dist/content.cjs CHANGED
@@ -114,6 +114,7 @@ function readSheet(entry, sheetIndex, substreams, globals) {
114
114
  rows: [],
115
115
  columns: [],
116
116
  merges: [],
117
+ dataValidations: [],
117
118
  print: {
118
119
  marginsPt: {},
119
120
  rowBreaks: [],
@@ -126,15 +127,34 @@ function readSheet(entry, sheetIndex, substreams, globals) {
126
127
  const comments = substream === void 0 ? /* @__PURE__ */ new Map() : require_workbook_comments.readSheetComments(substream.records);
127
128
  const cells = mapCells(raw, globals);
128
129
  applyCellComments(comments, cells);
130
+ const dataValidations = mapDataValidations(raw.dataValidations);
129
131
  return {
130
132
  name: entry.name,
131
133
  cells,
132
134
  columns: mapColumns(raw),
133
135
  rows: mapRows(raw),
134
136
  images: [],
135
- printSettings: mapPrintSettings(raw.print, globals.printNames.get(sheetIndex))
137
+ printSettings: mapPrintSettings(raw.print, globals.printNames.get(sheetIndex)),
138
+ ...dataValidations.length > 0 ? { dataValidations } : {}
136
139
  };
137
140
  }
141
+ function mapDataValidations(raw) {
142
+ return raw.map((validation) => ({
143
+ ranges: validation.ranges,
144
+ type: validation.type,
145
+ ...validation.operator === void 0 ? {} : { operator: validation.operator },
146
+ ...validation.formula1 === void 0 ? {} : { formula1: validation.formula1 },
147
+ ...validation.formula2 === void 0 ? {} : { formula2: validation.formula2 },
148
+ ...validation.allowBlank ? { allowBlank: true } : {},
149
+ ...validation.showInputMessage ? { showInputMessage: true } : {},
150
+ ...validation.promptTitle.length > 0 ? { promptTitle: validation.promptTitle } : {},
151
+ ...validation.prompt.length > 0 ? { prompt: validation.prompt } : {},
152
+ ...validation.showErrorMessage ? { showErrorMessage: true } : {},
153
+ ...validation.errorStyle === "stop" ? {} : { errorStyle: validation.errorStyle },
154
+ ...validation.errorTitle.length > 0 ? { errorTitle: validation.errorTitle } : {},
155
+ ...validation.error.length > 0 ? { error: validation.error } : {}
156
+ }));
157
+ }
138
158
  function mapRows(raw) {
139
159
  const rows = [];
140
160
  for (const row of raw.rows) {
package/dist/content.js CHANGED
@@ -113,6 +113,7 @@ function readSheet(entry, sheetIndex, substreams, globals) {
113
113
  rows: [],
114
114
  columns: [],
115
115
  merges: [],
116
+ dataValidations: [],
116
117
  print: {
117
118
  marginsPt: {},
118
119
  rowBreaks: [],
@@ -125,15 +126,34 @@ function readSheet(entry, sheetIndex, substreams, globals) {
125
126
  const comments = substream === void 0 ? /* @__PURE__ */ new Map() : readSheetComments(substream.records);
126
127
  const cells = mapCells(raw, globals);
127
128
  applyCellComments(comments, cells);
129
+ const dataValidations = mapDataValidations(raw.dataValidations);
128
130
  return {
129
131
  name: entry.name,
130
132
  cells,
131
133
  columns: mapColumns(raw),
132
134
  rows: mapRows(raw),
133
135
  images: [],
134
- printSettings: mapPrintSettings(raw.print, globals.printNames.get(sheetIndex))
136
+ printSettings: mapPrintSettings(raw.print, globals.printNames.get(sheetIndex)),
137
+ ...dataValidations.length > 0 ? { dataValidations } : {}
135
138
  };
136
139
  }
140
+ function mapDataValidations(raw) {
141
+ return raw.map((validation) => ({
142
+ ranges: validation.ranges,
143
+ type: validation.type,
144
+ ...validation.operator === void 0 ? {} : { operator: validation.operator },
145
+ ...validation.formula1 === void 0 ? {} : { formula1: validation.formula1 },
146
+ ...validation.formula2 === void 0 ? {} : { formula2: validation.formula2 },
147
+ ...validation.allowBlank ? { allowBlank: true } : {},
148
+ ...validation.showInputMessage ? { showInputMessage: true } : {},
149
+ ...validation.promptTitle.length > 0 ? { promptTitle: validation.promptTitle } : {},
150
+ ...validation.prompt.length > 0 ? { prompt: validation.prompt } : {},
151
+ ...validation.showErrorMessage ? { showErrorMessage: true } : {},
152
+ ...validation.errorStyle === "stop" ? {} : { errorStyle: validation.errorStyle },
153
+ ...validation.errorTitle.length > 0 ? { errorTitle: validation.errorTitle } : {},
154
+ ...validation.error.length > 0 ? { error: validation.error } : {}
155
+ }));
156
+ }
137
157
  function mapRows(raw) {
138
158
  const rows = [];
139
159
  for (const row of raw.rows) {
@@ -0,0 +1,22 @@
1
+ import { r as FormulaSheetContext } from "./ptg-CCBbJLZJ.cjs";
2
+ import { t as RecordGroup } from "./substreams-Cpy5Fi3d.cjs";
3
+ import { ContentSheetRange, SheetRuleOperator } from "document-schema.js";
4
+ //#region src/workbook/data-validation.d.ts
5
+ interface RawDataValidation {
6
+ readonly type: "whole" | "decimal" | "list" | "date" | "time" | "textLength" | "custom";
7
+ readonly operator: SheetRuleOperator | undefined;
8
+ readonly formula1: string | undefined;
9
+ readonly formula2: string | undefined;
10
+ readonly allowBlank: boolean;
11
+ readonly showInputMessage: boolean;
12
+ readonly showErrorMessage: boolean;
13
+ readonly errorStyle: "stop" | "warning" | "information";
14
+ readonly promptTitle: string;
15
+ readonly errorTitle: string;
16
+ readonly prompt: string;
17
+ readonly error: string;
18
+ readonly ranges: ContentSheetRange[];
19
+ }
20
+ declare function readDv(record: RecordGroup, formulaSheets: FormulaSheetContext): RawDataValidation | undefined;
21
+ //#endregion
22
+ export { readDv as n, RawDataValidation as t };
@@ -0,0 +1,22 @@
1
+ import { r as FormulaSheetContext } from "./ptg-CCBbJLZJ.js";
2
+ import { t as RecordGroup } from "./substreams-CmyZMtuM.js";
3
+ import { ContentSheetRange, SheetRuleOperator } from "document-schema.js";
4
+ //#region src/workbook/data-validation.d.ts
5
+ interface RawDataValidation {
6
+ readonly type: "whole" | "decimal" | "list" | "date" | "time" | "textLength" | "custom";
7
+ readonly operator: SheetRuleOperator | undefined;
8
+ readonly formula1: string | undefined;
9
+ readonly formula2: string | undefined;
10
+ readonly allowBlank: boolean;
11
+ readonly showInputMessage: boolean;
12
+ readonly showErrorMessage: boolean;
13
+ readonly errorStyle: "stop" | "warning" | "information";
14
+ readonly promptTitle: string;
15
+ readonly errorTitle: string;
16
+ readonly prompt: string;
17
+ readonly error: string;
18
+ readonly ranges: ContentSheetRange[];
19
+ }
20
+ declare function readDv(record: RecordGroup, formulaSheets: FormulaSheetContext): RawDataValidation | undefined;
21
+ //#endregion
22
+ export { readDv as n, RawDataValidation as t };
package/dist/index.cjs CHANGED
@@ -49,6 +49,8 @@ exports.RECORD_DATE1904 = require_biff_record_types.RECORD_DATE1904;
49
49
  exports.RECORD_DEFAULTROWHEIGHT = require_biff_record_types.RECORD_DEFAULTROWHEIGHT;
50
50
  exports.RECORD_DEFCOLWIDTH = require_biff_record_types.RECORD_DEFCOLWIDTH;
51
51
  exports.RECORD_DIMENSIONS = require_biff_record_types.RECORD_DIMENSIONS;
52
+ exports.RECORD_DV = require_biff_record_types.RECORD_DV;
53
+ exports.RECORD_DVAL = require_biff_record_types.RECORD_DVAL;
52
54
  exports.RECORD_EOF = require_biff_record_types.RECORD_EOF;
53
55
  exports.RECORD_EXTERNSHEET = require_biff_record_types.RECORD_EXTERNSHEET;
54
56
  exports.RECORD_FILEPASS = require_biff_record_types.RECORD_FILEPASS;
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ import { writeBofData } from "./biff/bof-writer.cjs";
2
2
  import { RecordBuilder } from "./biff/builder.cjs";
3
3
  import { t as BlockCursor } from "./cursor-VMtw9uVP.cjs";
4
4
  import { errorCodeOf, errorTextOf } from "./biff/errors.cjs";
5
- import { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF } from "./biff/record-types.cjs";
5
+ import { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_DV, RECORD_DVAL, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF } from "./biff/record-types.cjs";
6
6
  import { concatRecords, writeRecord } from "./biff/record-writer.cjs";
7
7
  import { n as BiffRecord, r as readRecords, t as BiffFormatError } from "./records-DVIqXFKk.cjs";
8
8
  import { decodeRkNumber } from "./biff/rk.cjs";
@@ -22,4 +22,4 @@ import { RawCell, RawCellValue, RawColumn, RawPrintSettings, RawRange, RawRow, R
22
22
  import { SheetWriteContext, buildWorksheetSubstream } from "./workbook/sheet-writer.cjs";
23
23
  import { writeXls, writeXlsContent } from "./write.cjs";
24
24
  export * from "excel-number-format";
25
- export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, BiffFormatError, BiffRecord, BiffWriteError, BlockCursor, CellFormat, CellXfPlanEntry, GENERAL_CELL_XF_INDEX, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF, RawCell, RawCellValue, RawColumn, RawPrintSettings, RawRange, RawRow, RawSheet, RecordBuilder, RecordGroup, SUMMARY_INFORMATION_STREAM, SheetEntry, SheetWriteContext, Substream, WorkbookGlobals, WorkbookGlobalsBuild, WorkbookGlobalsPlan, WorkbookStreams, XlsContentDocument, buildWorkbookGlobals, buildWorksheetSubstream, columnWidthToPoints, concatRecords, decodeRkNumber, errorCodeOf, errorTextOf, formatCodeOf, groupRecords, inchesToPoints, isXlsFile, isoDateTimeToSerial, isoDateToSerial, isoTimeToSerial, layoutMetadataToSummaryInformation, millimetresToPoints, pointsToColumnWidth, pointsToInches, pointsToTwips, readRecords, readRichExtendedString, readSheetRecords, readShortXLUnicodeString, readWorkbookGlobals, readWorkbookStreams, readXLUnicodeString, readXLUnicodeStringNoCch, readXls, readXlsContent, recordByteLength, serialToIsoDate, serialToIsoDateTime, serialToIsoTime, splitSubstreams, twipsToPoints, writeBofData, writeCellXfRecord, writeFontRecord, writeFormatRecord, writePaletteRecord, writeRecord, writeRichExtendedString, writeShortXLUnicodeString, writeStyleRecord, writeStyleXfRecord, writeXLUnicodeString, writeXls, writeXlsContent };
25
+ export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, BiffFormatError, BiffRecord, BiffWriteError, BlockCursor, CellFormat, CellXfPlanEntry, GENERAL_CELL_XF_INDEX, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_DV, RECORD_DVAL, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF, RawCell, RawCellValue, RawColumn, RawPrintSettings, RawRange, RawRow, RawSheet, RecordBuilder, RecordGroup, SUMMARY_INFORMATION_STREAM, SheetEntry, SheetWriteContext, Substream, WorkbookGlobals, WorkbookGlobalsBuild, WorkbookGlobalsPlan, WorkbookStreams, XlsContentDocument, buildWorkbookGlobals, buildWorksheetSubstream, columnWidthToPoints, concatRecords, decodeRkNumber, errorCodeOf, errorTextOf, formatCodeOf, groupRecords, inchesToPoints, isXlsFile, isoDateTimeToSerial, isoDateToSerial, isoTimeToSerial, layoutMetadataToSummaryInformation, millimetresToPoints, pointsToColumnWidth, pointsToInches, pointsToTwips, readRecords, readRichExtendedString, readSheetRecords, readShortXLUnicodeString, readWorkbookGlobals, readWorkbookStreams, readXLUnicodeString, readXLUnicodeStringNoCch, readXls, readXlsContent, recordByteLength, serialToIsoDate, serialToIsoDateTime, serialToIsoTime, splitSubstreams, twipsToPoints, writeBofData, writeCellXfRecord, writeFontRecord, writeFormatRecord, writePaletteRecord, writeRecord, writeRichExtendedString, writeShortXLUnicodeString, writeStyleRecord, writeStyleXfRecord, writeXLUnicodeString, writeXls, writeXlsContent };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { writeBofData } from "./biff/bof-writer.js";
2
2
  import { RecordBuilder } from "./biff/builder.js";
3
3
  import { t as BlockCursor } from "./cursor-VMtw9uVP.js";
4
4
  import { errorCodeOf, errorTextOf } from "./biff/errors.js";
5
- import { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF } from "./biff/record-types.js";
5
+ import { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_DV, RECORD_DVAL, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF } from "./biff/record-types.js";
6
6
  import { concatRecords, writeRecord } from "./biff/record-writer.js";
7
7
  import { n as BiffRecord, r as readRecords, t as BiffFormatError } from "./records-DVIqXFKk.js";
8
8
  import { decodeRkNumber } from "./biff/rk.js";
@@ -22,4 +22,4 @@ import { RawCell, RawCellValue, RawColumn, RawPrintSettings, RawRange, RawRow, R
22
22
  import { SheetWriteContext, buildWorksheetSubstream } from "./workbook/sheet-writer.js";
23
23
  import { writeXls, writeXlsContent } from "./write.js";
24
24
  export * from "excel-number-format";
25
- export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, BiffFormatError, BiffRecord, BiffWriteError, BlockCursor, CellFormat, CellXfPlanEntry, GENERAL_CELL_XF_INDEX, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF, RawCell, RawCellValue, RawColumn, RawPrintSettings, RawRange, RawRow, RawSheet, RecordBuilder, RecordGroup, SUMMARY_INFORMATION_STREAM, SheetEntry, SheetWriteContext, Substream, WorkbookGlobals, WorkbookGlobalsBuild, WorkbookGlobalsPlan, WorkbookStreams, XlsContentDocument, buildWorkbookGlobals, buildWorksheetSubstream, columnWidthToPoints, concatRecords, decodeRkNumber, errorCodeOf, errorTextOf, formatCodeOf, groupRecords, inchesToPoints, isXlsFile, isoDateTimeToSerial, isoDateToSerial, isoTimeToSerial, layoutMetadataToSummaryInformation, millimetresToPoints, pointsToColumnWidth, pointsToInches, pointsToTwips, readRecords, readRichExtendedString, readSheetRecords, readShortXLUnicodeString, readWorkbookGlobals, readWorkbookStreams, readXLUnicodeString, readXLUnicodeStringNoCch, readXls, readXlsContent, recordByteLength, serialToIsoDate, serialToIsoDateTime, serialToIsoTime, splitSubstreams, twipsToPoints, writeBofData, writeCellXfRecord, writeFontRecord, writeFormatRecord, writePaletteRecord, writeRecord, writeRichExtendedString, writeShortXLUnicodeString, writeStyleRecord, writeStyleXfRecord, writeXLUnicodeString, writeXls, writeXlsContent };
25
+ export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, BiffFormatError, BiffRecord, BiffWriteError, BlockCursor, CellFormat, CellXfPlanEntry, GENERAL_CELL_XF_INDEX, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_DV, RECORD_DVAL, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF, RawCell, RawCellValue, RawColumn, RawPrintSettings, RawRange, RawRow, RawSheet, RecordBuilder, RecordGroup, SUMMARY_INFORMATION_STREAM, SheetEntry, SheetWriteContext, Substream, WorkbookGlobals, WorkbookGlobalsBuild, WorkbookGlobalsPlan, WorkbookStreams, XlsContentDocument, buildWorkbookGlobals, buildWorksheetSubstream, columnWidthToPoints, concatRecords, decodeRkNumber, errorCodeOf, errorTextOf, formatCodeOf, groupRecords, inchesToPoints, isXlsFile, isoDateTimeToSerial, isoDateToSerial, isoTimeToSerial, layoutMetadataToSummaryInformation, millimetresToPoints, pointsToColumnWidth, pointsToInches, pointsToTwips, readRecords, readRichExtendedString, readSheetRecords, readShortXLUnicodeString, readWorkbookGlobals, readWorkbookStreams, readXLUnicodeString, readXLUnicodeStringNoCch, readXls, readXlsContent, recordByteLength, serialToIsoDate, serialToIsoDateTime, serialToIsoTime, splitSubstreams, twipsToPoints, writeBofData, writeCellXfRecord, writeFontRecord, writeFormatRecord, writePaletteRecord, writeRecord, writeRichExtendedString, writeShortXLUnicodeString, writeStyleRecord, writeStyleXfRecord, writeXLUnicodeString, writeXls, writeXlsContent };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF } from "./biff/record-types.js";
1
+ import { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_DV, RECORD_DVAL, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF } from "./biff/record-types.js";
2
2
  import { BiffFormatError, readRecords } from "./biff/records.js";
3
3
  import { SUMMARY_INFORMATION_STREAM, isXlsFile, readWorkbookStreams } from "./container.js";
4
4
  import { columnWidthToPoints, inchesToPoints, millimetresToPoints, pointsToColumnWidth, pointsToInches, pointsToTwips, twipsToPoints } from "./units.js";
@@ -22,4 +22,4 @@ import { GENERAL_CELL_XF_INDEX, buildWorkbookGlobals } from "./workbook/globals-
22
22
  import { buildWorksheetSubstream } from "./workbook/sheet-writer.js";
23
23
  import { writeXls, writeXlsContent } from "./write.js";
24
24
  export * from "excel-number-format";
25
- export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, BiffFormatError, BiffWriteError, BlockCursor, GENERAL_CELL_XF_INDEX, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF, RecordBuilder, SUMMARY_INFORMATION_STREAM, buildWorkbookGlobals, buildWorksheetSubstream, columnWidthToPoints, concatRecords, decodeRkNumber, errorCodeOf, errorTextOf, formatCodeOf, groupRecords, inchesToPoints, isXlsFile, isoDateTimeToSerial, isoDateToSerial, isoTimeToSerial, layoutMetadataToSummaryInformation, millimetresToPoints, pointsToColumnWidth, pointsToInches, pointsToTwips, readRecords, readRichExtendedString, readSheetRecords, readShortXLUnicodeString, readWorkbookGlobals, readWorkbookStreams, readXLUnicodeString, readXLUnicodeStringNoCch, readXls, readXlsContent, recordByteLength, serialToIsoDate, serialToIsoDateTime, serialToIsoTime, splitSubstreams, twipsToPoints, writeBofData, writeCellXfRecord, writeFontRecord, writeFormatRecord, writePaletteRecord, writeRecord, writeRichExtendedString, writeShortXLUnicodeString, writeStyleRecord, writeStyleXfRecord, writeXLUnicodeString, writeXls, writeXlsContent };
25
+ export { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_TYPE_WORKSHEET, BiffFormatError, BiffWriteError, BlockCursor, GENERAL_CELL_XF_INDEX, MAX_RECORD_DATA_SIZE, RECORD_ARRAY, RECORD_BLANK, RECORD_BOF, RECORD_BOOLERR, RECORD_BOTTOMMARGIN, RECORD_BOUNDSHEET8, RECORD_CALCCOUNT, RECORD_CALCDELTA, RECORD_CALCITER, RECORD_CALCREFMODE, RECORD_CALCSAVERECALC, RECORD_COLINFO, RECORD_CONTINUE, RECORD_DATE1904, RECORD_DEFAULTROWHEIGHT, RECORD_DEFCOLWIDTH, RECORD_DIMENSIONS, RECORD_DV, RECORD_DVAL, RECORD_EOF, RECORD_EXTERNSHEET, RECORD_FILEPASS, RECORD_FONT, RECORD_FORMAT, RECORD_FORMULA, RECORD_HORIZONTALPAGEBREAKS, RECORD_LABEL, RECORD_LABELSST, RECORD_LBL, RECORD_LEFTMARGIN, RECORD_MERGECELLS, RECORD_MULBLANK, RECORD_MULRK, RECORD_NOTE, RECORD_NUMBER, RECORD_OBJ, RECORD_PALETTE, RECORD_PRINTGRID, RECORD_PRINTROWCOL, RECORD_RIGHTMARGIN, RECORD_RK, RECORD_ROW, RECORD_SETUP, RECORD_SHRFMLA, RECORD_SST, RECORD_STRING, RECORD_STYLE, RECORD_SUPBOOK, RECORD_TABLE, RECORD_TOPMARGIN, RECORD_TXO, RECORD_VERTICALPAGEBREAKS, RECORD_WSBOOL, RECORD_XF, RecordBuilder, SUMMARY_INFORMATION_STREAM, buildWorkbookGlobals, buildWorksheetSubstream, columnWidthToPoints, concatRecords, decodeRkNumber, errorCodeOf, errorTextOf, formatCodeOf, groupRecords, inchesToPoints, isXlsFile, isoDateTimeToSerial, isoDateToSerial, isoTimeToSerial, layoutMetadataToSummaryInformation, millimetresToPoints, pointsToColumnWidth, pointsToInches, pointsToTwips, readRecords, readRichExtendedString, readSheetRecords, readShortXLUnicodeString, readWorkbookGlobals, readWorkbookStreams, readXLUnicodeString, readXLUnicodeStringNoCch, readXls, readXlsContent, recordByteLength, serialToIsoDate, serialToIsoDateTime, serialToIsoTime, splitSubstreams, twipsToPoints, writeBofData, writeCellXfRecord, writeFontRecord, writeFormatRecord, writePaletteRecord, writeRecord, writeRichExtendedString, writeShortXLUnicodeString, writeStyleRecord, writeStyleXfRecord, writeXLUnicodeString, writeXls, writeXlsContent };
@@ -0,0 +1,90 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_biff_records = require("../biff/records.cjs");
3
+ const require_biff_cursor = require("../biff/cursor.cjs");
4
+ const require_biff_strings = require("../biff/strings.cjs");
5
+ const require_biff_ptg = require("../biff/ptg.cjs");
6
+ //#region src/workbook/data-validation.ts
7
+ const VALUE_TYPE_BY_VAL_TYPE = /* @__PURE__ */ new Map([
8
+ [0, "custom"],
9
+ [1, "whole"],
10
+ [2, "decimal"],
11
+ [3, "list"],
12
+ [4, "date"],
13
+ [5, "time"],
14
+ [6, "textLength"],
15
+ [7, "custom"]
16
+ ]);
17
+ const OPERATOR_BY_TYP_OPERATOR = /* @__PURE__ */ new Map([
18
+ [0, "between"],
19
+ [1, "notBetween"],
20
+ [2, "equal"],
21
+ [3, "notEqual"],
22
+ [4, "greaterThan"],
23
+ [5, "lessThan"],
24
+ [6, "greaterThanOrEqual"],
25
+ [7, "lessThanOrEqual"]
26
+ ]);
27
+ const ERROR_STYLE_BY_ERR_STYLE = /* @__PURE__ */ new Map([
28
+ [0, "stop"],
29
+ [1, "warning"],
30
+ [2, "information"]
31
+ ]);
32
+ function readDvParsedFormula(cursor, formulaSheets) {
33
+ const cce = cursor.u16();
34
+ cursor.skip(2);
35
+ if (cce === 0) return;
36
+ return require_biff_ptg.parseFormulaText(cursor.take(cce), formulaSheets);
37
+ }
38
+ function readDv(record, formulaSheets) {
39
+ try {
40
+ const cursor = new require_biff_cursor.BlockCursor(record.blocks);
41
+ const flags = cursor.u32();
42
+ const valType = flags & 15;
43
+ const errStyleBits = flags >>> 4 & 7;
44
+ const fAllowBlank = (flags >>> 8 & 1) !== 0;
45
+ const fShowInputMsg = (flags >>> 18 & 1) !== 0;
46
+ const fShowErrorMsg = (flags >>> 19 & 1) !== 0;
47
+ const typOperator = flags >>> 20 & 15;
48
+ const promptTitle = require_biff_strings.readXLUnicodeString(cursor);
49
+ const errorTitle = require_biff_strings.readXLUnicodeString(cursor);
50
+ const prompt = require_biff_strings.readXLUnicodeString(cursor);
51
+ const error = require_biff_strings.readXLUnicodeString(cursor);
52
+ const formula1 = readDvParsedFormula(cursor, formulaSheets);
53
+ const formula2 = readDvParsedFormula(cursor, formulaSheets);
54
+ const rangeCount = cursor.u16();
55
+ const ranges = [];
56
+ for (let index = 0; index < rangeCount; index += 1) {
57
+ const startRow = cursor.u16();
58
+ const endRow = cursor.u16();
59
+ const startColumn = cursor.u16();
60
+ const endColumn = cursor.u16();
61
+ ranges.push({
62
+ startRow,
63
+ startColumn,
64
+ endRow,
65
+ endColumn
66
+ });
67
+ }
68
+ const type = VALUE_TYPE_BY_VAL_TYPE.get(valType) ?? "custom";
69
+ return {
70
+ type,
71
+ operator: type === "list" || type === "custom" ? void 0 : OPERATOR_BY_TYP_OPERATOR.get(typOperator),
72
+ formula1,
73
+ formula2,
74
+ allowBlank: fAllowBlank,
75
+ showInputMessage: fShowInputMsg,
76
+ showErrorMessage: fShowErrorMsg,
77
+ errorStyle: ERROR_STYLE_BY_ERR_STYLE.get(errStyleBits) ?? "stop",
78
+ promptTitle,
79
+ errorTitle,
80
+ prompt,
81
+ error,
82
+ ranges
83
+ };
84
+ } catch (err) {
85
+ if (!(err instanceof require_biff_records.BiffFormatError)) throw err;
86
+ return;
87
+ }
88
+ }
89
+ //#endregion
90
+ exports.readDv = readDv;
@@ -0,0 +1,2 @@
1
+ import { n as readDv, t as RawDataValidation } from "../data-validation-DZPzAW-8.cjs";
2
+ export { RawDataValidation, readDv };
@@ -0,0 +1,2 @@
1
+ import { n as readDv, t as RawDataValidation } from "../data-validation-DsVG0Mms.js";
2
+ export { RawDataValidation, readDv };
@@ -0,0 +1,89 @@
1
+ import { BiffFormatError } from "../biff/records.js";
2
+ import { BlockCursor } from "../biff/cursor.js";
3
+ import { readXLUnicodeString } from "../biff/strings.js";
4
+ import { parseFormulaText } from "../biff/ptg.js";
5
+ //#region src/workbook/data-validation.ts
6
+ const VALUE_TYPE_BY_VAL_TYPE = /* @__PURE__ */ new Map([
7
+ [0, "custom"],
8
+ [1, "whole"],
9
+ [2, "decimal"],
10
+ [3, "list"],
11
+ [4, "date"],
12
+ [5, "time"],
13
+ [6, "textLength"],
14
+ [7, "custom"]
15
+ ]);
16
+ const OPERATOR_BY_TYP_OPERATOR = /* @__PURE__ */ new Map([
17
+ [0, "between"],
18
+ [1, "notBetween"],
19
+ [2, "equal"],
20
+ [3, "notEqual"],
21
+ [4, "greaterThan"],
22
+ [5, "lessThan"],
23
+ [6, "greaterThanOrEqual"],
24
+ [7, "lessThanOrEqual"]
25
+ ]);
26
+ const ERROR_STYLE_BY_ERR_STYLE = /* @__PURE__ */ new Map([
27
+ [0, "stop"],
28
+ [1, "warning"],
29
+ [2, "information"]
30
+ ]);
31
+ function readDvParsedFormula(cursor, formulaSheets) {
32
+ const cce = cursor.u16();
33
+ cursor.skip(2);
34
+ if (cce === 0) return;
35
+ return parseFormulaText(cursor.take(cce), formulaSheets);
36
+ }
37
+ function readDv(record, formulaSheets) {
38
+ try {
39
+ const cursor = new BlockCursor(record.blocks);
40
+ const flags = cursor.u32();
41
+ const valType = flags & 15;
42
+ const errStyleBits = flags >>> 4 & 7;
43
+ const fAllowBlank = (flags >>> 8 & 1) !== 0;
44
+ const fShowInputMsg = (flags >>> 18 & 1) !== 0;
45
+ const fShowErrorMsg = (flags >>> 19 & 1) !== 0;
46
+ const typOperator = flags >>> 20 & 15;
47
+ const promptTitle = readXLUnicodeString(cursor);
48
+ const errorTitle = readXLUnicodeString(cursor);
49
+ const prompt = readXLUnicodeString(cursor);
50
+ const error = readXLUnicodeString(cursor);
51
+ const formula1 = readDvParsedFormula(cursor, formulaSheets);
52
+ const formula2 = readDvParsedFormula(cursor, formulaSheets);
53
+ const rangeCount = cursor.u16();
54
+ const ranges = [];
55
+ for (let index = 0; index < rangeCount; index += 1) {
56
+ const startRow = cursor.u16();
57
+ const endRow = cursor.u16();
58
+ const startColumn = cursor.u16();
59
+ const endColumn = cursor.u16();
60
+ ranges.push({
61
+ startRow,
62
+ startColumn,
63
+ endRow,
64
+ endColumn
65
+ });
66
+ }
67
+ const type = VALUE_TYPE_BY_VAL_TYPE.get(valType) ?? "custom";
68
+ return {
69
+ type,
70
+ operator: type === "list" || type === "custom" ? void 0 : OPERATOR_BY_TYP_OPERATOR.get(typOperator),
71
+ formula1,
72
+ formula2,
73
+ allowBlank: fAllowBlank,
74
+ showInputMessage: fShowInputMsg,
75
+ showErrorMessage: fShowErrorMsg,
76
+ errorStyle: ERROR_STYLE_BY_ERR_STYLE.get(errStyleBits) ?? "stop",
77
+ promptTitle,
78
+ errorTitle,
79
+ prompt,
80
+ error,
81
+ ranges
82
+ };
83
+ } catch (err) {
84
+ if (!(err instanceof BiffFormatError)) throw err;
85
+ return;
86
+ }
87
+ }
88
+ //#endregion
89
+ export { readDv };
@@ -9,6 +9,7 @@ const require_biff_strings = require("../biff/strings.cjs");
9
9
  const require_biff_errors = require("../biff/errors.cjs");
10
10
  const require_biff_ptg = require("../biff/ptg.cjs");
11
11
  const require_biff_rk = require("../biff/rk.cjs");
12
+ const require_workbook_data_validation = require("./data-validation.cjs");
12
13
  //#region src/workbook/sheet.ts
13
14
  /** Row record flag bits, in the 32-bit field following unused1 ([MS-XLS] 2.4.221). */
14
15
  const ROW_FLAG_HIDDEN = 32;
@@ -110,6 +111,7 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
110
111
  const rows = [];
111
112
  const columns = [];
112
113
  const merges = [];
114
+ const dataValidations = [];
113
115
  let usedRange;
114
116
  const marginsPt = {};
115
117
  const rowBreaks = [];
@@ -134,6 +136,11 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
134
136
  case 229:
135
137
  merges.push(...readMergeCells(record));
136
138
  break;
139
+ case 446: {
140
+ const validation = require_workbook_data_validation.readDv(record, formulaSheets);
141
+ if (validation !== void 0) dataValidations.push(validation);
142
+ break;
143
+ }
137
144
  case 513:
138
145
  cells.push(readBlank(record));
139
146
  break;
@@ -207,12 +214,14 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
207
214
  rows,
208
215
  columns,
209
216
  merges,
217
+ dataValidations,
210
218
  print
211
219
  } : {
212
220
  cells,
213
221
  rows,
214
222
  columns,
215
223
  merges,
224
+ dataValidations,
216
225
  usedRange,
217
226
  print
218
227
  };
@@ -1,6 +1,7 @@
1
1
  import { n as SetupFields } from "../print-setup-B_ihDvm5.cjs";
2
2
  import { r as FormulaSheetContext } from "../ptg-CCBbJLZJ.cjs";
3
3
  import { t as RecordGroup } from "../substreams-Cpy5Fi3d.cjs";
4
+ import { t as RawDataValidation } from "../data-validation-DZPzAW-8.cjs";
4
5
  //#region src/workbook/sheet.d.ts
5
6
  /** A cell's value as its own record carries it, before number-format classification decides whether a number is really a date, a percentage, or an amount of money. */
6
7
  type RawCellValue = {
@@ -81,6 +82,7 @@ interface RawSheet {
81
82
  readonly rows: readonly RawRow[];
82
83
  readonly columns: readonly RawColumn[];
83
84
  readonly merges: readonly RawRange[];
85
+ readonly dataValidations: readonly RawDataValidation[];
84
86
  /** The used range from the Dimensions record ([MS-XLS] 2.4.90), when the sheet declared one. */
85
87
  readonly usedRange?: RawRange;
86
88
  /** The sheet's own page setup, as far as its records state it. */
@@ -1,6 +1,7 @@
1
1
  import { n as SetupFields } from "../print-setup-B_ihDvm5.js";
2
2
  import { r as FormulaSheetContext } from "../ptg-CCBbJLZJ.js";
3
3
  import { t as RecordGroup } from "../substreams-CmyZMtuM.js";
4
+ import { t as RawDataValidation } from "../data-validation-DsVG0Mms.js";
4
5
  //#region src/workbook/sheet.d.ts
5
6
  /** A cell's value as its own record carries it, before number-format classification decides whether a number is really a date, a percentage, or an amount of money. */
6
7
  type RawCellValue = {
@@ -81,6 +82,7 @@ interface RawSheet {
81
82
  readonly rows: readonly RawRow[];
82
83
  readonly columns: readonly RawColumn[];
83
84
  readonly merges: readonly RawRange[];
85
+ readonly dataValidations: readonly RawDataValidation[];
84
86
  /** The used range from the Dimensions record ([MS-XLS] 2.4.90), when the sheet declared one. */
85
87
  readonly usedRange?: RawRange;
86
88
  /** The sheet's own page setup, as far as its records state it. */
@@ -8,6 +8,7 @@ import { readXLUnicodeString } from "../biff/strings.js";
8
8
  import { errorTextOf } from "../biff/errors.js";
9
9
  import { parseFormulaText, readPtgExpBase } from "../biff/ptg.js";
10
10
  import { decodeRkNumber } from "../biff/rk.js";
11
+ import { readDv } from "./data-validation.js";
11
12
  //#region src/workbook/sheet.ts
12
13
  /** Row record flag bits, in the 32-bit field following unused1 ([MS-XLS] 2.4.221). */
13
14
  const ROW_FLAG_HIDDEN = 32;
@@ -109,6 +110,7 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
109
110
  const rows = [];
110
111
  const columns = [];
111
112
  const merges = [];
113
+ const dataValidations = [];
112
114
  let usedRange;
113
115
  const marginsPt = {};
114
116
  const rowBreaks = [];
@@ -133,6 +135,11 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
133
135
  case 229:
134
136
  merges.push(...readMergeCells(record));
135
137
  break;
138
+ case 446: {
139
+ const validation = readDv(record, formulaSheets);
140
+ if (validation !== void 0) dataValidations.push(validation);
141
+ break;
142
+ }
136
143
  case 513:
137
144
  cells.push(readBlank(record));
138
145
  break;
@@ -206,12 +213,14 @@ function readSheetRecords(records, sharedStrings, formulaSheets = EMPTY_FORMULA_
206
213
  rows,
207
214
  columns,
208
215
  merges,
216
+ dataValidations,
209
217
  print
210
218
  } : {
211
219
  cells,
212
220
  rows,
213
221
  columns,
214
222
  merges,
223
+ dataValidations,
215
224
  usedRange,
216
225
  print
217
226
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xls-codec",
3
- "version": "4.2.3",
3
+ "version": "4.3.0",
4
4
  "description": "Hand-written reader for the legacy Excel Binary File Format (.xls, BIFF8) as specified by [MS-XLS], mapping a workbook's record stream onto the shared document-schema.js spreadsheet model - the .xls codec for the documents.js family.",
5
5
  "type": "module",
6
6
  "repository": {