xls-codec 3.0.0 → 4.0.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 (38) hide show
  1. package/README.md +4 -4
  2. package/dist/biff/ptg.cjs +160 -7
  3. package/dist/biff/ptg.d.cts +2 -2
  4. package/dist/biff/ptg.d.ts +2 -2
  5. package/dist/biff/ptg.js +161 -9
  6. package/dist/biff/strings.cjs +6 -0
  7. package/dist/biff/strings.d.cts +3 -1
  8. package/dist/biff/strings.d.ts +3 -1
  9. package/dist/biff/strings.js +6 -1
  10. package/dist/biff/substreams.cjs +5 -0
  11. package/dist/biff/substreams.d.cts +2 -2
  12. package/dist/biff/substreams.d.ts +2 -2
  13. package/dist/biff/substreams.js +5 -1
  14. package/dist/index.cjs +2 -0
  15. package/dist/index.d.cts +3 -3
  16. package/dist/index.d.ts +3 -3
  17. package/dist/index.js +3 -3
  18. package/dist/{print-names-DUlpVE00.d.ts → print-names-C-PQ2vAy.d.ts} +1 -1
  19. package/dist/{print-names-D-njuzVw.d.cts → print-names-DyYloloV.d.cts} +1 -1
  20. package/dist/ptg-CCBbJLZJ.d.cts +49 -0
  21. package/dist/ptg-CCBbJLZJ.d.ts +49 -0
  22. package/dist/{substreams-D7dQiJbp.d.ts → substreams-CmyZMtuM.d.ts} +3 -1
  23. package/dist/{substreams-Ddtvn_Vr.d.cts → substreams-Cpy5Fi3d.d.cts} +3 -1
  24. package/dist/workbook/globals-writer.d.cts +1 -1
  25. package/dist/workbook/globals-writer.d.ts +1 -1
  26. package/dist/workbook/globals.cjs +137 -14
  27. package/dist/workbook/globals.d.cts +6 -6
  28. package/dist/workbook/globals.d.ts +6 -6
  29. package/dist/workbook/globals.js +138 -15
  30. package/dist/workbook/print-names.d.cts +1 -1
  31. package/dist/workbook/print-names.d.ts +1 -1
  32. package/dist/workbook/sheet.cjs +109 -6
  33. package/dist/workbook/sheet.d.cts +3 -3
  34. package/dist/workbook/sheet.d.ts +3 -3
  35. package/dist/workbook/sheet.js +110 -7
  36. package/package.json +1 -1
  37. package/dist/ptg-B2K8t3js.d.cts +0 -21
  38. package/dist/ptg-B2K8t3js.d.ts +0 -21
@@ -1,6 +1,10 @@
1
1
  import "./record-types.js";
2
2
  import { BiffFormatError } from "./records.js";
3
3
  //#region src/biff/substreams.ts
4
+ /** The total byte length of a record's data across every block (the base record's and any Continues that followed it) -- what a reader needs whenever a trailing field's own length is implied by "whatever is left" rather than stated by a preceding count (a Mul record's entry count, an SST's own bounds check, a formula's RgbExtra trailer). */
5
+ function recordByteLength(record) {
6
+ return record.blocks.reduce((sum, block) => sum + block.length, 0);
7
+ }
4
8
  /** Joins each record to the Continue records following it, keeping the blocks separate. */
5
9
  function groupRecords(records) {
6
10
  const groups = [];
@@ -66,4 +70,4 @@ function readBofDocumentType(group) {
66
70
  return view.getUint16(2, true);
67
71
  }
68
72
  //#endregion
69
- export { groupRecords, splitSubstreams };
73
+ export { groupRecords, recordByteLength, splitSubstreams };
package/dist/index.cjs CHANGED
@@ -109,8 +109,10 @@ exports.readShortXLUnicodeString = require_biff_strings.readShortXLUnicodeString
109
109
  exports.readWorkbookGlobals = require_workbook_globals.readWorkbookGlobals;
110
110
  exports.readWorkbookStreams = require_container.readWorkbookStreams;
111
111
  exports.readXLUnicodeString = require_biff_strings.readXLUnicodeString;
112
+ exports.readXLUnicodeStringNoCch = require_biff_strings.readXLUnicodeStringNoCch;
112
113
  exports.readXls = require_content.readXls;
113
114
  exports.readXlsContent = require_content.readXlsContent;
115
+ exports.recordByteLength = require_biff_substreams.recordByteLength;
114
116
  exports.serialToIsoDate = require_serial.serialToIsoDate;
115
117
  exports.serialToIsoDateTime = require_serial.serialToIsoDateTime;
116
118
  exports.serialToIsoTime = require_serial.serialToIsoTime;
package/dist/index.d.cts CHANGED
@@ -7,8 +7,8 @@ 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";
9
9
  import { writeRichExtendedString, writeShortXLUnicodeString, writeXLUnicodeString } from "./biff/string-writer.cjs";
10
- import { readRichExtendedString, readShortXLUnicodeString, readXLUnicodeString } from "./biff/strings.cjs";
11
- import { i as splitSubstreams, n as Substream, r as groupRecords, t as RecordGroup } from "./substreams-Ddtvn_Vr.cjs";
10
+ import { readRichExtendedString, readShortXLUnicodeString, readXLUnicodeString, readXLUnicodeStringNoCch } from "./biff/strings.cjs";
11
+ import { a as splitSubstreams, i as recordByteLength, n as Substream, r as groupRecords, t as RecordGroup } from "./substreams-Cpy5Fi3d.cjs";
12
12
  import { BiffWriteError } from "./biff/write-errors.cjs";
13
13
  import { writeCellXfRecord, writeFontRecord, writeFormatRecord, writePaletteRecord, writeStyleRecord, writeStyleXfRecord } from "./biff/xf-writer.cjs";
14
14
  import { SUMMARY_INFORMATION_STREAM, WorkbookStreams, isXlsFile, readWorkbookStreams } from "./container.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_NUMBER, 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_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, readXls, readXlsContent, 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_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_NUMBER, 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_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
@@ -7,8 +7,8 @@ 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";
9
9
  import { writeRichExtendedString, writeShortXLUnicodeString, writeXLUnicodeString } from "./biff/string-writer.js";
10
- import { readRichExtendedString, readShortXLUnicodeString, readXLUnicodeString } from "./biff/strings.js";
11
- import { i as splitSubstreams, n as Substream, r as groupRecords, t as RecordGroup } from "./substreams-D7dQiJbp.js";
10
+ import { readRichExtendedString, readShortXLUnicodeString, readXLUnicodeString, readXLUnicodeStringNoCch } from "./biff/strings.js";
11
+ import { a as splitSubstreams, i as recordByteLength, n as Substream, r as groupRecords, t as RecordGroup } from "./substreams-CmyZMtuM.js";
12
12
  import { BiffWriteError } from "./biff/write-errors.js";
13
13
  import { writeCellXfRecord, writeFontRecord, writeFormatRecord, writePaletteRecord, writeStyleRecord, writeStyleXfRecord } from "./biff/xf-writer.js";
14
14
  import { SUMMARY_INFORMATION_STREAM, WorkbookStreams, isXlsFile, readWorkbookStreams } from "./container.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_NUMBER, 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_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, readXls, readXlsContent, 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_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_NUMBER, 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_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
@@ -2,11 +2,11 @@ import { BIFF8_VERSION, BOF_TYPE_CHART, BOF_TYPE_MACRO, BOF_TYPE_WORKBOOK, BOF_T
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";
5
- import { groupRecords, splitSubstreams } from "./biff/substreams.js";
5
+ import { groupRecords, recordByteLength, splitSubstreams } from "./biff/substreams.js";
6
6
  import { BiffWriteError } from "./biff/write-errors.js";
7
7
  import { isoDateTimeToSerial, isoDateToSerial, isoTimeToSerial, serialToIsoDate, serialToIsoDateTime, serialToIsoTime } from "./serial.js";
8
8
  import { BlockCursor } from "./biff/cursor.js";
9
- import { readRichExtendedString, readShortXLUnicodeString, readXLUnicodeString } from "./biff/strings.js";
9
+ import { readRichExtendedString, readShortXLUnicodeString, readXLUnicodeString, readXLUnicodeStringNoCch } from "./biff/strings.js";
10
10
  import { RecordBuilder } from "./biff/builder.js";
11
11
  import { concatRecords, writeRecord } from "./biff/record-writer.js";
12
12
  import { formatCodeOf, readWorkbookGlobals } from "./workbook/globals.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_NUMBER, 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_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, readXls, readXlsContent, 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_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_NUMBER, 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_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 };
@@ -1,4 +1,4 @@
1
- import { t as RecordGroup } from "./substreams-D7dQiJbp.js";
1
+ import { t as RecordGroup } from "./substreams-CmyZMtuM.js";
2
2
  import { ContentSheetPrintRange, ContentSheetRepeatRange } from "document-schema.js";
3
3
  //#region src/workbook/print-names.d.ts
4
4
  /** One sheet's print names, as the Lbl records of the globals substream carry them. Every field is absent when the workbook declares no such name for that sheet. */
@@ -1,4 +1,4 @@
1
- import { t as RecordGroup } from "./substreams-Ddtvn_Vr.cjs";
1
+ import { t as RecordGroup } from "./substreams-Cpy5Fi3d.cjs";
2
2
  import { ContentSheetPrintRange, ContentSheetRepeatRange } from "document-schema.js";
3
3
  //#region src/workbook/print-names.d.ts
4
4
  /** One sheet's print names, as the Lbl records of the globals substream carry them. Every field is absent when the workbook declares no such name for that sheet. */
@@ -0,0 +1,49 @@
1
+ //#region src/biff/ptg.d.ts
2
+ /** A 3D reference's sheet scope, resolved from its ixti through EXTERNSHEET and a self-referencing SupBook ([MS-XLS] 2.4.271, 2.4.106, 2.5.344): the first and last sheet of the reference, both direct BoundSheet8 indices into FormulaSheetContext.sheets. A single-sheet 3D reference has `firstSheetIndex === lastSheetIndex`. Defined here rather than alongside the globals reader that produces it, since resolving it into reference text is what this module exists to do. */
3
+ interface SheetRange {
4
+ readonly firstSheetIndex: number;
5
+ readonly lastSheetIndex: number;
6
+ }
7
+ /**
8
+ * A 3D reference's sheet-prefix label, already fully formatted by workbook/globals.ts, for an ixti this reader cannot resolve into a plain SheetRange -- a genuinely external workbook (label carries `[workbook]sheet` or `[workbook]first:last`) or a supporting link of a kind this reader never resolves a sheet name from at all (add-in, DDE/OLE, same-sheet, unused, an unresolved sheet index, or a workbook name this reader's own deliberately partial VirtualPath decoding could not isolate -- label then carries a bracketed `#REF!(reason)` diagnostic, or a `[EXTERNAL]` placeholder workbook name, in place of real recovered data). Kept as a single pre-formatted string rather than a further structured shape, since resolveSheetLabel below only ever needs the finished label text and every other consumer of a 3D reference's sheet name is upstream of this module (see WorkbookGlobals.sheetRanges, which this type's own sheetRanges field matches field-for-field).
9
+ *
10
+ * `diagnostic` says which of those two this is: false only when both the external workbook's own file name and its sheet name(s) were genuinely recovered from the file's own virtPath and rgst, in which case `label` is real data worth writing back out as a formula's sheet-scope text; true whenever `label` instead carries this reader's OWN placeholder text standing in for something it could not resolve. resolveSheetLabel treats a diagnostic label the same as any other construct this reader cannot resolve -- the containing formula is left absent rather than having synthetic, non-formula text spliced into what a spreadsheet application would otherwise treat as real, writable formula content (see documents.js's own write paths, which take ContentSheetCell.formula as literal, verbatim formula text with no further validation).
11
+ *
12
+ * No `kind` tag beyond this: SheetRange's two fields are both required and this type's own `label`/`diagnostic` fields are required too, so the two shapes are already mutually exclusive by construction and a plain `"label" in candidate` check discriminates them.
13
+ */
14
+ interface ExternalSheetLabel {
15
+ readonly label: string;
16
+ readonly diagnostic: boolean;
17
+ }
18
+ /** What a 3D reference's own ixti resolves against: the workbook's sheets in BoundSheet8 order (only the name is needed here), and each ixti's own resolved sheet scope (undefined where this reader has nothing at all to say about it -- see WorkbookGlobals.sheetRanges, which this type's own sheetRanges field matches field-for-field). */
19
+ interface FormulaSheetContext {
20
+ readonly sheets: readonly {
21
+ readonly name: string;
22
+ }[];
23
+ readonly sheetRanges: readonly (SheetRange | ExternalSheetLabel | undefined)[];
24
+ }
25
+ /** A cell position a relative Ptg token's offset is resolved against -- the referencing cell currently being expanded, never the shared formula's own base cell. Exported only because it appears in ParseFormulaOptions.relativeTo and readPtgExpBase's own return type, both public. */
26
+ interface FormulaOrigin {
27
+ readonly row: number;
28
+ readonly column: number;
29
+ }
30
+ /**
31
+ * Parses a Formula record's compiled expression into the text a spreadsheet application would show, or returns undefined for a token this reader does not resolve -- a defined name, a natural-language reference, or a data table (see the module comment for the full list). The caller leaves ContentSheetCell.formula absent in that case, exactly as for any other unsupported construct.
32
+ *
33
+ * `rgce` is the formula's own token bytes, already sliced to their declared length (CellParsedFormula.cce/SharedParsedFormula.cce/ArrayParsedFormula.cce) by the caller -- this function reads exactly that many bytes and nothing past them.
34
+ */
35
+ interface ParseFormulaOptions {
36
+ /** The cell this formula is being evaluated for -- present only when `rgce` is a ShrFmla's own SharedParsedFormula being expanded for one specific referencing cell (see workbook/sheet.ts's collectFormulaGroups), which is the only place PtgRefN/PtgAreaN are legal. Absent for every other caller, in which case meeting one of those tokens aborts the parse exactly as it always has. */
37
+ readonly relativeTo?: FormulaOrigin;
38
+ /** The RgbExtra trailer following `rgce` in the same CellParsedFormula/ArrayParsedFormula ([MS-XLS] 7dd67f0a/242bcf20) -- consulted only when `rgce` contains a PtgArray, one PtgExtraArray pulled off the front for each in the order both arrays share ([MS-XLS] 70f743b2: "The order of the structures MUST be the same as the order of the Ptgs"). Absent (or exhausted before a PtgArray needs it) aborts the parse rather than guessing at the array's values. */
39
+ readonly rgcb?: Uint8Array<ArrayBuffer>;
40
+ }
41
+ declare function parseFormulaText(rgce: Uint8Array<ArrayBuffer>, context: FormulaSheetContext, options?: ParseFormulaOptions): string | undefined;
42
+ /**
43
+ * If `rgce` is EXACTLY one PtgExp token -- which is the only shape a Formula record belonging to a shared or array formula group ever has, including the group's own base cell, which points at itself -- returns the (row, column) of the Formula record that carries the real expression (a ShrFmla or Array record immediately follows it). Returns undefined for every other rgce, so a caller can try this first and fall back to parseFormulaText for a formula that merely happens to open with byte 0x01 for some other reason (it cannot: no other single-byte-opcode Ptg in this reader's vocabulary is 0x01, but a malformed or foreign rgce is not assumed well-formed here either) or is simply longer than five bytes.
44
+ *
45
+ * Exported for workbook/sheet.ts's collectFormulaGroups, which joins the returned cell against whichever ShrFmla/Array record follows the Formula record found there.
46
+ */
47
+ declare function readPtgExpBase(rgce: Uint8Array<ArrayBuffer>): FormulaOrigin | undefined;
48
+ //#endregion
49
+ export { SheetRange as a, ParseFormulaOptions as i, FormulaOrigin as n, parseFormulaText as o, FormulaSheetContext as r, readPtgExpBase as s, ExternalSheetLabel as t };
@@ -0,0 +1,49 @@
1
+ //#region src/biff/ptg.d.ts
2
+ /** A 3D reference's sheet scope, resolved from its ixti through EXTERNSHEET and a self-referencing SupBook ([MS-XLS] 2.4.271, 2.4.106, 2.5.344): the first and last sheet of the reference, both direct BoundSheet8 indices into FormulaSheetContext.sheets. A single-sheet 3D reference has `firstSheetIndex === lastSheetIndex`. Defined here rather than alongside the globals reader that produces it, since resolving it into reference text is what this module exists to do. */
3
+ interface SheetRange {
4
+ readonly firstSheetIndex: number;
5
+ readonly lastSheetIndex: number;
6
+ }
7
+ /**
8
+ * A 3D reference's sheet-prefix label, already fully formatted by workbook/globals.ts, for an ixti this reader cannot resolve into a plain SheetRange -- a genuinely external workbook (label carries `[workbook]sheet` or `[workbook]first:last`) or a supporting link of a kind this reader never resolves a sheet name from at all (add-in, DDE/OLE, same-sheet, unused, an unresolved sheet index, or a workbook name this reader's own deliberately partial VirtualPath decoding could not isolate -- label then carries a bracketed `#REF!(reason)` diagnostic, or a `[EXTERNAL]` placeholder workbook name, in place of real recovered data). Kept as a single pre-formatted string rather than a further structured shape, since resolveSheetLabel below only ever needs the finished label text and every other consumer of a 3D reference's sheet name is upstream of this module (see WorkbookGlobals.sheetRanges, which this type's own sheetRanges field matches field-for-field).
9
+ *
10
+ * `diagnostic` says which of those two this is: false only when both the external workbook's own file name and its sheet name(s) were genuinely recovered from the file's own virtPath and rgst, in which case `label` is real data worth writing back out as a formula's sheet-scope text; true whenever `label` instead carries this reader's OWN placeholder text standing in for something it could not resolve. resolveSheetLabel treats a diagnostic label the same as any other construct this reader cannot resolve -- the containing formula is left absent rather than having synthetic, non-formula text spliced into what a spreadsheet application would otherwise treat as real, writable formula content (see documents.js's own write paths, which take ContentSheetCell.formula as literal, verbatim formula text with no further validation).
11
+ *
12
+ * No `kind` tag beyond this: SheetRange's two fields are both required and this type's own `label`/`diagnostic` fields are required too, so the two shapes are already mutually exclusive by construction and a plain `"label" in candidate` check discriminates them.
13
+ */
14
+ interface ExternalSheetLabel {
15
+ readonly label: string;
16
+ readonly diagnostic: boolean;
17
+ }
18
+ /** What a 3D reference's own ixti resolves against: the workbook's sheets in BoundSheet8 order (only the name is needed here), and each ixti's own resolved sheet scope (undefined where this reader has nothing at all to say about it -- see WorkbookGlobals.sheetRanges, which this type's own sheetRanges field matches field-for-field). */
19
+ interface FormulaSheetContext {
20
+ readonly sheets: readonly {
21
+ readonly name: string;
22
+ }[];
23
+ readonly sheetRanges: readonly (SheetRange | ExternalSheetLabel | undefined)[];
24
+ }
25
+ /** A cell position a relative Ptg token's offset is resolved against -- the referencing cell currently being expanded, never the shared formula's own base cell. Exported only because it appears in ParseFormulaOptions.relativeTo and readPtgExpBase's own return type, both public. */
26
+ interface FormulaOrigin {
27
+ readonly row: number;
28
+ readonly column: number;
29
+ }
30
+ /**
31
+ * Parses a Formula record's compiled expression into the text a spreadsheet application would show, or returns undefined for a token this reader does not resolve -- a defined name, a natural-language reference, or a data table (see the module comment for the full list). The caller leaves ContentSheetCell.formula absent in that case, exactly as for any other unsupported construct.
32
+ *
33
+ * `rgce` is the formula's own token bytes, already sliced to their declared length (CellParsedFormula.cce/SharedParsedFormula.cce/ArrayParsedFormula.cce) by the caller -- this function reads exactly that many bytes and nothing past them.
34
+ */
35
+ interface ParseFormulaOptions {
36
+ /** The cell this formula is being evaluated for -- present only when `rgce` is a ShrFmla's own SharedParsedFormula being expanded for one specific referencing cell (see workbook/sheet.ts's collectFormulaGroups), which is the only place PtgRefN/PtgAreaN are legal. Absent for every other caller, in which case meeting one of those tokens aborts the parse exactly as it always has. */
37
+ readonly relativeTo?: FormulaOrigin;
38
+ /** The RgbExtra trailer following `rgce` in the same CellParsedFormula/ArrayParsedFormula ([MS-XLS] 7dd67f0a/242bcf20) -- consulted only when `rgce` contains a PtgArray, one PtgExtraArray pulled off the front for each in the order both arrays share ([MS-XLS] 70f743b2: "The order of the structures MUST be the same as the order of the Ptgs"). Absent (or exhausted before a PtgArray needs it) aborts the parse rather than guessing at the array's values. */
39
+ readonly rgcb?: Uint8Array<ArrayBuffer>;
40
+ }
41
+ declare function parseFormulaText(rgce: Uint8Array<ArrayBuffer>, context: FormulaSheetContext, options?: ParseFormulaOptions): string | undefined;
42
+ /**
43
+ * If `rgce` is EXACTLY one PtgExp token -- which is the only shape a Formula record belonging to a shared or array formula group ever has, including the group's own base cell, which points at itself -- returns the (row, column) of the Formula record that carries the real expression (a ShrFmla or Array record immediately follows it). Returns undefined for every other rgce, so a caller can try this first and fall back to parseFormulaText for a formula that merely happens to open with byte 0x01 for some other reason (it cannot: no other single-byte-opcode Ptg in this reader's vocabulary is 0x01, but a malformed or foreign rgce is not assumed well-formed here either) or is simply longer than five bytes.
44
+ *
45
+ * Exported for workbook/sheet.ts's collectFormulaGroups, which joins the returned cell against whichever ShrFmla/Array record follows the Formula record found there.
46
+ */
47
+ declare function readPtgExpBase(rgce: Uint8Array<ArrayBuffer>): FormulaOrigin | undefined;
48
+ //#endregion
49
+ export { SheetRange as a, ParseFormulaOptions as i, FormulaOrigin as n, parseFormulaText as o, FormulaSheetContext as r, readPtgExpBase as s, ExternalSheetLabel as t };
@@ -6,6 +6,8 @@ interface RecordGroup {
6
6
  readonly blocks: readonly Uint8Array<ArrayBuffer>[];
7
7
  readonly offset: number;
8
8
  }
9
+ /** The total byte length of a record's data across every block (the base record's and any Continues that followed it) -- what a reader needs whenever a trailing field's own length is implied by "whatever is left" rather than stated by a preceding count (a Mul record's entry count, an SST's own bounds check, a formula's RgbExtra trailer). */
10
+ declare function recordByteLength(record: RecordGroup): number;
9
11
  /** One substream: the document type its BOF declared, the records between that BOF and its EOF, its ordinal position among the stream's substreams, and the stream offset of its own BOF -- which is what a BoundSheet8's lbPlyPos names. */
10
12
  interface Substream {
11
13
  readonly documentType: number;
@@ -18,4 +20,4 @@ declare function groupRecords(records: readonly BiffRecord[]): readonly RecordGr
18
20
  /** Splits a grouped record sequence into its substreams, verifying each BOF declares BIFF8. */
19
21
  declare function splitSubstreams(groups: readonly RecordGroup[]): readonly Substream[];
20
22
  //#endregion
21
- export { splitSubstreams as i, Substream as n, groupRecords as r, RecordGroup as t };
23
+ export { splitSubstreams as a, recordByteLength as i, Substream as n, groupRecords as r, RecordGroup as t };
@@ -6,6 +6,8 @@ interface RecordGroup {
6
6
  readonly blocks: readonly Uint8Array<ArrayBuffer>[];
7
7
  readonly offset: number;
8
8
  }
9
+ /** The total byte length of a record's data across every block (the base record's and any Continues that followed it) -- what a reader needs whenever a trailing field's own length is implied by "whatever is left" rather than stated by a preceding count (a Mul record's entry count, an SST's own bounds check, a formula's RgbExtra trailer). */
10
+ declare function recordByteLength(record: RecordGroup): number;
9
11
  /** One substream: the document type its BOF declared, the records between that BOF and its EOF, its ordinal position among the stream's substreams, and the stream offset of its own BOF -- which is what a BoundSheet8's lbPlyPos names. */
10
12
  interface Substream {
11
13
  readonly documentType: number;
@@ -18,4 +20,4 @@ declare function groupRecords(records: readonly BiffRecord[]): readonly RecordGr
18
20
  /** Splits a grouped record sequence into its substreams, verifying each BOF declares BIFF8. */
19
21
  declare function splitSubstreams(groups: readonly RecordGroup[]): readonly Substream[];
20
22
  //#endregion
21
- export { splitSubstreams as i, Substream as n, groupRecords as r, RecordGroup as t };
23
+ export { splitSubstreams as a, recordByteLength as i, Substream as n, groupRecords as r, RecordGroup as t };
@@ -1,5 +1,5 @@
1
1
  import { E as XfDecorationFields } from "../xf-colors-BB5MKq6R.cjs";
2
- import { t as PrintNamePlanEntry } from "../print-names-D-njuzVw.cjs";
2
+ import { t as PrintNamePlanEntry } from "../print-names-DyYloloV.cjs";
3
3
  import { Alignment, Color } from "document-schema.js";
4
4
  //#region src/workbook/globals-writer.d.ts
5
5
  /** [MS-XLS] 2.1.7.20.3's own XFS production requires at least sixteen XF records before any cell can reference one: BUILTIN_STYLES.length built-in cell styles, then at least one cell XF -- the "General, no declared format" one every workbook needs unconditionally, written immediately after them. Derived from BUILTIN_STYLES's own length rather than restated as a literal, so the two can never drift apart. */
@@ -1,5 +1,5 @@
1
1
  import { E as XfDecorationFields } from "../xf-colors--5oxSeI1.js";
2
- import { t as PrintNamePlanEntry } from "../print-names-DUlpVE00.js";
2
+ import { t as PrintNamePlanEntry } from "../print-names-C-PQ2vAy.js";
3
3
  import { Alignment, Color } from "document-schema.js";
4
4
  //#region src/workbook/globals-writer.d.ts
5
5
  /** [MS-XLS] 2.1.7.20.3's own XFS production requires at least sixteen XF records before any cell can reference one: BUILTIN_STYLES.length built-in cell styles, then at least one cell XF -- the "General, no declared format" one every workbook needs unconditionally, written immediately after them. Derived from BUILTIN_STYLES's own length rather than restated as a literal, so the two can never drift apart. */
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_biff_record_types = require("../biff/record-types.cjs");
3
3
  const require_biff_records = require("../biff/records.cjs");
4
+ const require_biff_substreams = require("../biff/substreams.cjs");
4
5
  const require_biff_xf_colors = require("../biff/xf-colors.cjs");
5
6
  const require_biff_cursor = require("../biff/cursor.cjs");
6
7
  const require_biff_strings = require("../biff/strings.cjs");
@@ -19,7 +20,7 @@ function readWorkbookGlobals(records) {
19
20
  const sheets = [];
20
21
  const cellFormats = [];
21
22
  const customFormats = /* @__PURE__ */ new Map();
22
- const supBookSelfReferencing = [];
23
+ const supBooks = [];
23
24
  let sharedStrings = [];
24
25
  let date1904 = false;
25
26
  let externSheet;
@@ -43,7 +44,7 @@ function readWorkbookGlobals(records) {
43
44
  date1904 = readDate1904(record);
44
45
  break;
45
46
  case 430:
46
- supBookSelfReferencing.push(isSelfReferencingSupBook(record));
47
+ supBooks.push(readSupBookSafely(record));
47
48
  break;
48
49
  case 23:
49
50
  externSheet = record;
@@ -52,7 +53,7 @@ function readWorkbookGlobals(records) {
52
53
  }
53
54
  const numberFormats = new Map(excel_number_format.BUILTIN_NUMBER_FORMATS);
54
55
  for (const [id, code] of customFormats) numberFormats.set(id, code);
55
- const sheetRanges = externSheet === void 0 ? [] : readSheetRanges(externSheet, supBookSelfReferencing);
56
+ const sheetRanges = externSheet === void 0 ? [] : readSheetRanges(externSheet, supBooks);
56
57
  return {
57
58
  sheets,
58
59
  sharedStrings,
@@ -64,16 +65,141 @@ function readWorkbookGlobals(records) {
64
65
  printNames: require_workbook_print_names.readPrintNames(records)
65
66
  };
66
67
  }
67
- /** [MS-XLS] 2.4.271's own cch table: a SupBook whose cch is exactly this value is a self-referencing supporting link -- this workbook itself -- rather than another workbook, a DDE/OLE data source, or an add-in. This is the only kind of supporting link a 3D reference resolves through here; every other kind genuinely needs bytes from outside this file. */
68
+ /** [MS-XLS] 2.4.271's own cch table: a SupBook whose cch is exactly this value is a self-referencing supporting link -- this workbook itself -- rather than another workbook, a DDE/OLE data source, or an add-in. */
68
69
  const SUPBOOK_SELF_REFERENCING_CCH = 1025;
69
- /** SupBook ([MS-XLS] 2.4.271): a two-byte ctab then a two-byte cch. Only cch is read here -- ctab is undefined for a self-referencing SupBook and unused for every other kind this reader does not resolve, and the virtPath/rgst payload that would follow for a non-self-referencing link is never reached. */
70
- function isSelfReferencingSupBook(record) {
70
+ /** The cch table's other named sentinel: an add-in-referencing supporting link, whose ExternName records name add-in functions this reader has no workbook or sheet to resolve a name from. */
71
+ const SUPBOOK_ADDIN_CCH = 14849;
72
+ /** The inclusive cch range meaning "virtPath is present, and its own grammar (rather than a further sentinel) says what kind of supporting link this is" ([MS-XLS] 2.4.271's own cch table). */
73
+ const SUPBOOK_VIRTPATH_MAX_CCH = 255;
74
+ /** virtPath's own single-character sentinels ([MS-XLS] 31ed3738's own virtPath value table): a lone NUL marks a same-sheet reference, a lone SPACE an unused supporting link. */
75
+ const SUPBOOK_SAME_SHEET_CHAR = "\0";
76
+ const SUPBOOK_UNUSED_CHAR = " ";
77
+ /**
78
+ * SupBook ([MS-XLS] 2.4.271): a two-byte ctab, a two-byte cch, then -- for every kind but self-referencing and add-in-referencing -- a virtPath (an XLUnicodeStringNoCch, cch characters long) and, for an external-workbook or unused link specifically, ctab sheet names (XLUnicodeString) in rgst.
79
+ */
80
+ function readSupBook(record) {
71
81
  const cursor = new require_biff_cursor.BlockCursor(record.blocks);
72
- cursor.skip(2);
73
- return cursor.u16() === SUPBOOK_SELF_REFERENCING_CCH;
82
+ const ctab = cursor.u16();
83
+ const cch = cursor.u16();
84
+ if (cch === SUPBOOK_SELF_REFERENCING_CCH) return { kind: "self" };
85
+ if (cch === SUPBOOK_ADDIN_CCH) return {
86
+ kind: "unresolvable",
87
+ diagnostic: "add-in function reference"
88
+ };
89
+ if (cch < 1 || cch > SUPBOOK_VIRTPATH_MAX_CCH) return {
90
+ kind: "unresolvable",
91
+ diagnostic: `supporting link of unrecognised type (cch=0x${cch.toString(16).padStart(4, "0")})`
92
+ };
93
+ const virtPath = require_biff_strings.readXLUnicodeStringNoCch(cursor, cch);
94
+ if (virtPath === SUPBOOK_SAME_SHEET_CHAR) return {
95
+ kind: "unresolvable",
96
+ diagnostic: "same-sheet reference"
97
+ };
98
+ if (virtPath === SUPBOOK_UNUSED_CHAR) return {
99
+ kind: "unresolvable",
100
+ diagnostic: "unused supporting link"
101
+ };
102
+ if (ctab === 0) return {
103
+ kind: "unresolvable",
104
+ diagnostic: "DDE or OLE data source reference"
105
+ };
106
+ const fileName = fileNameFromVirtPath(virtPath);
107
+ const sheetNames = [];
108
+ for (let index = 0; index < ctab; index += 1) sheetNames.push(require_biff_strings.readXLUnicodeString(cursor));
109
+ return {
110
+ kind: "external-workbook",
111
+ fileName,
112
+ sheetNames
113
+ };
114
+ }
115
+ /**
116
+ * readSupBook, degrading a malformed record (an rgst shorter than its own declared ctab, most concretely) to an unresolvable diagnostic rather than letting a BiffFormatError propagate out of this one SupBook and abort the whole globals read -- and with it, the whole workbook. This is entirely new territory added alongside external-3D-reference resolution: before it, this reader never walked a SupBook's own virtPath/rgst at all, so a malformed one had nothing here to trip over. The per-record boundary keeps the damage to the XTI entries that resolve through this one SupBook, which already carry their own `unresolvable` label path for every other kind this reader cannot fully resolve.
117
+ */
118
+ function readSupBookSafely(record) {
119
+ try {
120
+ return readSupBook(record);
121
+ } catch (error) {
122
+ if (!(error instanceof require_biff_records.BiffFormatError)) throw error;
123
+ return {
124
+ kind: "unresolvable",
125
+ diagnostic: "malformed supporting link"
126
+ };
127
+ }
128
+ }
129
+ /** [MS-XLS] 480c3d2a's own VirtualPath grammar directory separator (U+0003) -- never a printable character a real file or sheet name may contain, so splitting on it to find the trailing segment is unambiguous. */
130
+ const VIRTPATH_DIRECTORY_SEPARATOR = "";
131
+ /** [MS-XLS] 480c3d2a's own two-character virt-path markers this reader still resolves a trailing file name through: rel-volume, startup, alt-startup, and library -- each %x0001 followed by one of these bytes, then file-path itself. Distinct from simple-file-path, whose own leading %x0001 (when present at all) stands ALONE, with no second marker byte, directly followed by file-path -- so any OTHER second character belongs to that file-path, not to a marker this function should also consume. */
132
+ const VIRTPATH_REL_VOLUME_MARKER = 2;
133
+ const VIRTPATH_STARTUP_MARKER = 6;
134
+ const VIRTPATH_ALT_STARTUP_MARKER = 7;
135
+ const VIRTPATH_LIBRARY_MARKER = 8;
136
+ /**
137
+ * Isolates a plain trailing file name from a SupBook's own virtPath, when it uses one of the VirtualPath grammar's simpler forms: simple-file-path (no marker at all, or its own optional lone %x0001 with no second marker byte), or a genuine two-character marker saying the path is relative to the referencing workbook's own drive, the startup directory, the alternate startup directory, or the library directory (rel-volume/startup/alt-startup/library -- [MS-XLS] 480c3d2a's own virt-path alternatives). An absolute drive volume, a UNC share, or a transfer-protocol URL needs more of the grammar than a trailing path segment to reproduce faithfully, so those return undefined rather than a guess -- readSupBook's own caller then shows the sheet name(s) (still fully resolvable from rgst) against a placeholder workbook label instead of discarding them. file-path's own bracketed form (`"[" relative-path "]" sheet-name`, naming a sheet directly in the path rather than through SupBook's separate rgst array) is outside what this reader reconstructs too, and is declined the same way rather than folded into the file name and doubled up with the caller's own `[bookLabel]` bracketing.
138
+ */
139
+ function fileNameFromVirtPath(virtPath) {
140
+ let path = virtPath;
141
+ if (path.startsWith("")) switch (path.codePointAt(1)) {
142
+ case 1:
143
+ case 5: return;
144
+ case VIRTPATH_REL_VOLUME_MARKER:
145
+ case VIRTPATH_STARTUP_MARKER:
146
+ case VIRTPATH_ALT_STARTUP_MARKER:
147
+ case VIRTPATH_LIBRARY_MARKER:
148
+ path = path.slice(2);
149
+ break;
150
+ default: path = path.slice(1);
151
+ }
152
+ if (path.length === 0) return;
153
+ const last = path.split(VIRTPATH_DIRECTORY_SEPARATOR).at(-1);
154
+ if (last === void 0 || last.length === 0) return;
155
+ return last.includes("[") || last.includes("]") ? void 0 : last;
156
+ }
157
+ /** A bracketed diagnostic placeholder for a sheet label this reader could not fully resolve -- deliberately distinct from Excel's own bare `#REF!` error literal (which is valid, retypeable formula syntax on its own): this always carries a parenthesised reason, and resolveSheetLabel's own quoting (biff/ptg.ts) wraps the whole thing in single quotes regardless, since neither the reason text nor the surrounding punctuation matches a bare sheet-name pattern. */
158
+ function diagnosticLabel(reason) {
159
+ return `#REF!(${reason})`;
160
+ }
161
+ /**
162
+ * One XTI's own scope resolved against its SupBook -- a plain SheetRange when the SupBook is this same, self-referencing workbook and both sheet indices are real ([MS-XLS] 2.5.344's own `-1` "could not be found" and `-2` "workbook-level" sentinels aside), otherwise an ExternalSheetLabel carrying whatever this reader could recover (an external workbook's own file name and sheet name(s), when the SupBook resolves that far) or a diagnostic placeholder, for a supporting-link kind or a sheet index this reader does not resolve a name from at all.
163
+ *
164
+ * The SupBook's own kind is checked before the `-2` sentinel, not after: [MS-XLS] 2.5.344's itabFirst/itabLast table produces `-2` for a same-sheet, add-in, DDE, and OLE supporting link alike (none of them names a sheet at all), so treating every `-2` as a generic "workbook-level reference" before asking what kind of SupBook it belongs to would overwrite each of those already-specific `unresolvable` diagnostics with a less useful, wrong one. `-2` only means "workbook-level" for the two kinds that otherwise resolve a real sheet scope -- self and external-workbook -- so the sentinel is scoped to those.
165
+ */
166
+ function resolveXti(supBook, itabFirst, itabLast) {
167
+ if (supBook === void 0) return {
168
+ label: diagnosticLabel("supporting link index out of range"),
169
+ diagnostic: true
170
+ };
171
+ if (supBook.kind === "unresolvable") return {
172
+ label: diagnosticLabel(supBook.diagnostic),
173
+ diagnostic: true
174
+ };
175
+ if (itabFirst === -2 || itabLast === -2) return {
176
+ label: diagnosticLabel("workbook-level reference"),
177
+ diagnostic: true
178
+ };
179
+ if (supBook.kind === "self") return itabFirst >= 0 && itabLast >= 0 ? {
180
+ firstSheetIndex: itabFirst,
181
+ lastSheetIndex: itabLast
182
+ } : {
183
+ label: diagnosticLabel("sheet not found"),
184
+ diagnostic: true
185
+ };
186
+ const first = itabFirst >= 0 ? supBook.sheetNames[itabFirst] : void 0;
187
+ const last = itabLast >= 0 ? supBook.sheetNames[itabLast] : void 0;
188
+ if (first === void 0 || last === void 0) return {
189
+ label: `[${supBook.fileName ?? "EXTERNAL"}]${diagnosticLabel("sheet not found")}`,
190
+ diagnostic: true
191
+ };
192
+ if (supBook.fileName === void 0) return {
193
+ label: `[EXTERNAL]${first === last ? first : `${first}:${last}`}`,
194
+ diagnostic: true
195
+ };
196
+ return {
197
+ label: `[${supBook.fileName}]${first === last ? first : `${first}:${last}`}`,
198
+ diagnostic: false
199
+ };
74
200
  }
75
201
  /** ExternSheet ([MS-XLS] 2.4.106): a two-byte cXTI then that many XTI structures ([MS-XLS] 2.5.344) -- a two-byte iSupBook and two signed 16-bit sheet-scope bounds each. iSupBook indexes the SupBook collection positionally, in the order those records appeared. */
76
- function readSheetRanges(record, supBookSelfReferencing) {
202
+ function readSheetRanges(record, supBooks) {
77
203
  const cursor = new require_biff_cursor.BlockCursor(record.blocks);
78
204
  const count = cursor.u16();
79
205
  const ranges = [];
@@ -81,10 +207,7 @@ function readSheetRanges(record, supBookSelfReferencing) {
81
207
  const iSupBook = cursor.u16();
82
208
  const itabFirst = cursor.i16();
83
209
  const itabLast = cursor.i16();
84
- ranges.push((supBookSelfReferencing[iSupBook] ?? false) && itabFirst >= 0 && itabLast >= 0 ? {
85
- firstSheetIndex: itabFirst,
86
- lastSheetIndex: itabLast
87
- } : void 0);
210
+ ranges.push(resolveXti(supBooks[iSupBook], itabFirst, itabLast));
88
211
  }
89
212
  return ranges;
90
213
  }
@@ -107,7 +230,7 @@ function readSharedStrings(record) {
107
230
  cursor.i32();
108
231
  const uniqueCount = cursor.i32();
109
232
  if (uniqueCount < 0) throw new require_biff_records.BiffFormatError(`SST declares a negative unique-string count (${uniqueCount})`);
110
- const totalBytes = record.blocks.reduce((sum, block) => sum + block.length, 0);
233
+ const totalBytes = require_biff_substreams.recordByteLength(record);
111
234
  if (uniqueCount * MIN_SST_ENTRY_BYTES > totalBytes) throw new require_biff_records.BiffFormatError(`SST declares ${uniqueCount} unique strings, more than its ${totalBytes} bytes could carry`);
112
235
  const strings = [];
113
236
  for (let index = 0; index < uniqueCount; index += 1) strings.push(require_biff_strings.readRichExtendedString(cursor));
@@ -1,7 +1,7 @@
1
- import { n as SheetRange } from "../ptg-B2K8t3js.cjs";
2
- import { t as RecordGroup } from "../substreams-Ddtvn_Vr.cjs";
1
+ import { a as SheetRange, t as ExternalSheetLabel } from "../ptg-CCBbJLZJ.cjs";
2
+ import { t as RecordGroup } from "../substreams-Cpy5Fi3d.cjs";
3
3
  import { E as XfDecorationFields, w as XfAlignmentFields } from "../xf-colors-BB5MKq6R.cjs";
4
- import { n as SheetPrintNames } from "../print-names-D-njuzVw.cjs";
4
+ import { n as SheetPrintNames } from "../print-names-DyYloloV.cjs";
5
5
  import { Color } from "document-schema.js";
6
6
  //#region src/workbook/globals.d.ts
7
7
  /** One sheet, as its BoundSheet8 record describes it ([MS-XLS] 2.4.28). */
@@ -41,11 +41,11 @@ interface WorkbookGlobals {
41
41
  /** Whether serials count from the 1904 epoch rather than the 1900 one ([MS-XLS] 2.4.77). */
42
42
  readonly date1904: boolean;
43
43
  /**
44
- * A PtgRef3d/PtgArea3d's own ixti, resolved to the sheet range it names -- one entry per XTI in the EXTERNSHEET record's rgXTI array, in that array's own order (an ixti is an index into it).
44
+ * A PtgRef3d/PtgArea3d's own ixti, resolved to the sheet scope it names -- one entry per XTI in the EXTERNSHEET record's rgXTI array, in that array's own order (an ixti is an index into it).
45
45
  *
46
- * An entry is undefined when this reader does not resolve it: the XTI's own SupBook is not this same, self-referencing workbook (a genuine external-workbook, DDE, OLE, or add-in reference -- [MS-XLS] 2.4.271's own cch table, `0x0401` being the one this reader treats as resolvable), or its itabFirst/itabLast do not name a real sheet (`-1`, "sheet could not be found"). A formula whose 3D reference lands on an undefined entry is left with `formula` absent for that cell, exactly like the other unsupported-token cases -- this reader never resolves a genuinely external workbook's own sheet names, since that needs the external workbook's own bytes, not this one's.
46
+ * A plain SheetRange when the XTI's own SupBook is this same, self-referencing workbook and both itabFirst/itabLast name a real sheet. An ExternalSheetLabel -- a fully-formatted label text, diagnostic placeholder included -- for everything else this reader cannot turn into direct BoundSheet8 indices: a genuinely external workbook (resolved as far as its own virtPath and rgst allow, see readSupBook/fileNameFromVirtPath), a DDE/OLE/add-in/same-sheet/unused supporting link (no sheet name to resolve at all), or a sheet index [MS-XLS] 2.5.344 itself marks unresolvable (`-1`, "sheet could not be found") or workbook-level (`-2`). Only an ixti past the end of EXTERNSHEET's own array is genuinely undefined -- every other case now carries SOME label text, so a 3D reference into it no longer drops the whole formula the way an unresolvable one used to.
47
47
  */
48
- readonly sheetRanges: readonly (SheetRange | undefined)[];
48
+ readonly sheetRanges: readonly (SheetRange | ExternalSheetLabel | undefined)[];
49
49
  /**
50
50
  * The workbook's own custom colour table, from a Palette record ([MS-XLS] 2.4.188) -- 56 entries, index 0 being icv 8. Undefined when the file carries no Palette record at all, which is common: a real file relying purely on the fixed default 8-colour-plus-56-entry table (this package's own `resolveIcvColor` falls back to that same default table, matching [MS-XLS] "Icv"'s own documented fallback) never needs one.
51
51
  */
@@ -1,7 +1,7 @@
1
- import { n as SheetRange } from "../ptg-B2K8t3js.js";
2
- import { t as RecordGroup } from "../substreams-D7dQiJbp.js";
1
+ import { a as SheetRange, t as ExternalSheetLabel } from "../ptg-CCBbJLZJ.js";
2
+ import { t as RecordGroup } from "../substreams-CmyZMtuM.js";
3
3
  import { E as XfDecorationFields, w as XfAlignmentFields } from "../xf-colors--5oxSeI1.js";
4
- import { n as SheetPrintNames } from "../print-names-DUlpVE00.js";
4
+ import { n as SheetPrintNames } from "../print-names-C-PQ2vAy.js";
5
5
  import { Color } from "document-schema.js";
6
6
  //#region src/workbook/globals.d.ts
7
7
  /** One sheet, as its BoundSheet8 record describes it ([MS-XLS] 2.4.28). */
@@ -41,11 +41,11 @@ interface WorkbookGlobals {
41
41
  /** Whether serials count from the 1904 epoch rather than the 1900 one ([MS-XLS] 2.4.77). */
42
42
  readonly date1904: boolean;
43
43
  /**
44
- * A PtgRef3d/PtgArea3d's own ixti, resolved to the sheet range it names -- one entry per XTI in the EXTERNSHEET record's rgXTI array, in that array's own order (an ixti is an index into it).
44
+ * A PtgRef3d/PtgArea3d's own ixti, resolved to the sheet scope it names -- one entry per XTI in the EXTERNSHEET record's rgXTI array, in that array's own order (an ixti is an index into it).
45
45
  *
46
- * An entry is undefined when this reader does not resolve it: the XTI's own SupBook is not this same, self-referencing workbook (a genuine external-workbook, DDE, OLE, or add-in reference -- [MS-XLS] 2.4.271's own cch table, `0x0401` being the one this reader treats as resolvable), or its itabFirst/itabLast do not name a real sheet (`-1`, "sheet could not be found"). A formula whose 3D reference lands on an undefined entry is left with `formula` absent for that cell, exactly like the other unsupported-token cases -- this reader never resolves a genuinely external workbook's own sheet names, since that needs the external workbook's own bytes, not this one's.
46
+ * A plain SheetRange when the XTI's own SupBook is this same, self-referencing workbook and both itabFirst/itabLast name a real sheet. An ExternalSheetLabel -- a fully-formatted label text, diagnostic placeholder included -- for everything else this reader cannot turn into direct BoundSheet8 indices: a genuinely external workbook (resolved as far as its own virtPath and rgst allow, see readSupBook/fileNameFromVirtPath), a DDE/OLE/add-in/same-sheet/unused supporting link (no sheet name to resolve at all), or a sheet index [MS-XLS] 2.5.344 itself marks unresolvable (`-1`, "sheet could not be found") or workbook-level (`-2`). Only an ixti past the end of EXTERNSHEET's own array is genuinely undefined -- every other case now carries SOME label text, so a 3D reference into it no longer drops the whole formula the way an unresolvable one used to.
47
47
  */
48
- readonly sheetRanges: readonly (SheetRange | undefined)[];
48
+ readonly sheetRanges: readonly (SheetRange | ExternalSheetLabel | undefined)[];
49
49
  /**
50
50
  * The workbook's own custom colour table, from a Palette record ([MS-XLS] 2.4.188) -- 56 entries, index 0 being icv 8. Undefined when the file carries no Palette record at all, which is common: a real file relying purely on the fixed default 8-colour-plus-56-entry table (this package's own `resolveIcvColor` falls back to that same default table, matching [MS-XLS] "Icv"'s own documented fallback) never needs one.
51
51
  */