@evotecit/officeimo 0.1.19 → 0.1.43

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 (102) hide show
  1. package/README.md +44 -10
  2. package/bundles/officeimo-canopyx-adapter.js +147 -65
  3. package/bundles/officeimo-canopyx-adapter.min.js +1 -1
  4. package/bundles/officeimo-canopyx-adapter.min.mjs +1 -1
  5. package/bundles/officeimo-canopyx-adapter.mjs +134 -53
  6. package/bundles/officeimo-canopyx.js +554 -234
  7. package/bundles/officeimo-canopyx.min.js +1 -1
  8. package/bundles/officeimo-canopyx.min.mjs +1 -1
  9. package/bundles/officeimo-canopyx.mjs +477 -158
  10. package/bundles/officeimo-chartforgex-adapter.js +1924 -0
  11. package/bundles/officeimo-chartforgex-adapter.min.js +2 -0
  12. package/bundles/officeimo-chartforgex-adapter.min.mjs +2 -0
  13. package/bundles/officeimo-chartforgex-adapter.mjs +1910 -0
  14. package/bundles/officeimo-chartforgex.js +13594 -0
  15. package/bundles/officeimo-chartforgex.min.js +2 -0
  16. package/bundles/officeimo-chartforgex.min.mjs +2 -0
  17. package/bundles/officeimo-chartforgex.mjs +13487 -0
  18. package/bundles/officeimo-csv.js +12 -7
  19. package/bundles/officeimo-csv.min.js +1 -1
  20. package/bundles/officeimo-csv.min.mjs +1 -1
  21. package/bundles/officeimo-csv.mjs +8 -3
  22. package/bundles/officeimo-datatables-adapter.js +11 -11
  23. package/bundles/officeimo-datatables-adapter.min.js +1 -1
  24. package/bundles/officeimo-datatables-adapter.min.mjs +1 -1
  25. package/bundles/officeimo-datatables-adapter.mjs +7 -7
  26. package/bundles/officeimo-datatables.js +418 -180
  27. package/bundles/officeimo-datatables.min.js +1 -1
  28. package/bundles/officeimo-datatables.min.mjs +1 -1
  29. package/bundles/officeimo-datatables.mjs +350 -112
  30. package/bundles/officeimo-execution.js +14 -9
  31. package/bundles/officeimo-execution.min.js +1 -1
  32. package/bundles/officeimo-execution.min.mjs +1 -1
  33. package/bundles/officeimo-execution.mjs +8 -3
  34. package/bundles/officeimo-pdf.js +286 -120
  35. package/bundles/officeimo-pdf.min.js +1 -1
  36. package/bundles/officeimo-pdf.min.mjs +1 -1
  37. package/bundles/officeimo-pdf.mjs +244 -78
  38. package/bundles/officeimo-xlsx.js +136 -59
  39. package/bundles/officeimo-xlsx.min.js +1 -1
  40. package/bundles/officeimo-xlsx.min.mjs +1 -1
  41. package/bundles/officeimo-xlsx.mjs +114 -37
  42. package/bundles/officeimo.js +416 -178
  43. package/bundles/officeimo.min.js +1 -1
  44. package/bundles/officeimo.min.mjs +1 -1
  45. package/bundles/officeimo.mjs +351 -113
  46. package/dist/core/progress.js +7 -2
  47. package/dist/index.d.ts +1 -1
  48. package/dist/integrations/canopyx/index.js +13 -4
  49. package/dist/integrations/canopyx/pdf-number.js +9 -6
  50. package/dist/integrations/canopyx/rule-predicates.d.ts +1 -1
  51. package/dist/integrations/canopyx/rule-predicates.js +2 -1
  52. package/dist/integrations/canopyx/rules.d.ts +1 -1
  53. package/dist/integrations/canopyx/rules.js +11 -13
  54. package/dist/integrations/canopyx/source.js +57 -7
  55. package/dist/integrations/canopyx/tones.d.ts +10 -0
  56. package/dist/integrations/canopyx/tones.js +12 -0
  57. package/dist/integrations/canopyx/types.d.ts +8 -1
  58. package/dist/integrations/chartforgex/capture.d.ts +31 -0
  59. package/dist/integrations/chartforgex/capture.js +103 -0
  60. package/dist/integrations/chartforgex/index.d.ts +13 -0
  61. package/dist/integrations/chartforgex/index.js +88 -0
  62. package/dist/integrations/chartforgex/svg-drawing.d.ts +5 -0
  63. package/dist/integrations/chartforgex/svg-drawing.js +775 -0
  64. package/dist/integrations/chartforgex/svg-geometry.d.ts +23 -0
  65. package/dist/integrations/chartforgex/svg-geometry.js +304 -0
  66. package/dist/integrations/chartforgex/svg-image.d.ts +9 -0
  67. package/dist/integrations/chartforgex/svg-image.js +46 -0
  68. package/dist/integrations/chartforgex/svg-markup.d.ts +10 -0
  69. package/dist/integrations/chartforgex/svg-markup.js +124 -0
  70. package/dist/integrations/chartforgex/svg-paint.d.ts +16 -0
  71. package/dist/integrations/chartforgex/svg-paint.js +146 -0
  72. package/dist/integrations/chartforgex/types.d.ts +77 -0
  73. package/dist/integrations/chartforgex/types.js +1 -0
  74. package/dist/integrations/chartforgex/winansi.d.ts +4 -0
  75. package/dist/integrations/chartforgex/winansi.js +48 -0
  76. package/dist/integrations/chartforgex/workbook.d.ts +12 -0
  77. package/dist/integrations/chartforgex/workbook.js +137 -0
  78. package/dist/pdf/document-drawings.d.ts +1 -1
  79. package/dist/pdf/document-drawings.js +91 -17
  80. package/dist/pdf/document-images.d.ts +7 -1
  81. package/dist/pdf/document-images.js +59 -24
  82. package/dist/pdf/document-types.d.ts +3 -1
  83. package/dist/pdf/document.d.ts +2 -2
  84. package/dist/pdf/document.js +3 -1
  85. package/dist/pdf/drawing-types.d.ts +37 -10
  86. package/dist/pdf/font-resources.d.ts +1 -1
  87. package/dist/pdf/font-resources.js +6 -3
  88. package/dist/pdf/index.d.ts +1 -1
  89. package/dist/pdf/pages.js +15 -0
  90. package/dist/pdf/png.d.ts +11 -2
  91. package/dist/pdf/png.js +50 -23
  92. package/dist/pdf/session.js +3 -2
  93. package/dist/pdf/settings.d.ts +2 -2
  94. package/dist/pdf/settings.js +7 -3
  95. package/dist/xlsx/options.js +2 -2
  96. package/dist/xlsx/portable.js +1 -1
  97. package/dist/xlsx/styles.js +28 -18
  98. package/dist/xlsx/types.d.ts +13 -1
  99. package/dist/xlsx/workbook.js +9 -1
  100. package/dist/xlsx/worksheet.d.ts +13 -1
  101. package/dist/xlsx/worksheet.js +65 -11
  102. package/package.json +9 -2
@@ -197,19 +197,24 @@ _modules.set("d5c945064d81fdd257960f48c421125e106e5f270427d170bb05587dd96a44ea",
197
197
  return _exports;
198
198
  })();
199
199
 
200
- const _m4 = _modules.get("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f") ?? (() => {
200
+ const _m4 = _modules.get("4eea31c4336d3c43bc743739843a3ef31803d8f0ed553f5645ee9de2554eb244") ?? (() => {
201
201
  /** @internal Notify synchronously; observe an accidental promise before rejecting its unsupported use. */
202
202
  function notifyProgress(callback, progress) {
203
+ notifySynchronously("onProgress", callback, progress);
204
+ }
205
+ /** @internal Run a host notification that must finish before the export continues. A returned promise is observed,
206
+ * so its rejection is never unhandled, and the export fails instead of reporting success before the callback ends. */
207
+ function notifySynchronously(name, callback, value) {
203
208
  if (!callback)
204
209
  return;
205
- const result = callback(progress);
210
+ const result = callback(value);
206
211
  if (result && typeof result.then === "function") {
207
212
  void Promise.resolve(result).catch(() => { });
208
- throw new TypeError("onProgress must be synchronous.");
213
+ throw new TypeError(name + " must be synchronous.");
209
214
  }
210
215
  }
211
- const _exports = Object.freeze({ notifyProgress: notifyProgress });
212
- _modules.set("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f", _exports);
216
+ const _exports = Object.freeze({ notifyProgress: notifyProgress, notifySynchronously: notifySynchronously });
217
+ _modules.set("4eea31c4336d3c43bc743739843a3ef31803d8f0ed553f5645ee9de2554eb244", _exports);
213
218
  return _exports;
214
219
  })();
215
220
 
@@ -1386,7 +1391,7 @@ _modules.set("6ae88f25e1c09d00fbb828917498569f883fae88ec25d37caebaf8a2b802b148",
1386
1391
  return _exports;
1387
1392
  })();
1388
1393
 
1389
- const _m16 = _modules.get("077c3c668f1457253dba044e6f6be7f7afd28a8976ed20c764bd5d5dc7c41889") ?? (() => {
1394
+ const _m16 = _modules.get("8d96d0024443ac9aeaea70e9324b53aacef098c2385d4e6a89a76d184e28556a") ?? (() => {
1390
1395
  const { escapeOoxmlAttribute, cleanXml, xmlDeclaration } = _m11;
1391
1396
 
1392
1397
  const { OfficeIMOError } = _m3;
@@ -1398,6 +1403,24 @@ const { DifferentialStyles } = _m18;
1398
1403
 
1399
1404
 
1400
1405
  const spreadsheetNamespace = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
1406
+ const borderStyles = ["thin", "medium", "dashed", "dotted", "thick", "double", "hair", "dashDot", "dashDotDot", "slantDashDot", "mediumDashed", "mediumDashDot", "mediumDashDotDot"];
1407
+ /** @internal Validate and normalize border edges without registering a workbook style. */
1408
+ function normalizeBorder(border) {
1409
+ if (!border || typeof border !== "object")
1410
+ throw new TypeError("A border must be an object of edges.");
1411
+ const result = {};
1412
+ for (const side of ["left", "right", "top", "bottom"]) {
1413
+ const edge = border[side];
1414
+ if (edge) {
1415
+ // Read each property once, so the validated edge is the one that is stored.
1416
+ const { style, color } = edge;
1417
+ if (!borderStyles.includes(style))
1418
+ throw new TypeError("Invalid border style.");
1419
+ result[side] = { style, ...(color ? { color: colorArgb(color) } : {}) };
1420
+ }
1421
+ }
1422
+ return result;
1423
+ }
1401
1424
  const NumberFormats = { General: "General", Integer: "0", Decimal: "0.00", Percent: "0.00%", Date: "yyyy-mm-dd", DateTime: "yyyy-mm-dd hh:mm:ss" };
1402
1425
  function index(value, count, kind) {
1403
1426
  if (!Number.isInteger(value) || value < 0 || value >= count)
@@ -1470,32 +1493,24 @@ class StyleRegistry {
1470
1493
  /** @internal */
1471
1494
  addDifferentials(styles) { this.checkDifferentials(styles); return this.differential.add(styles); }
1472
1495
  addFont(font) {
1473
- if (font.name !== undefined && typeof font.name !== "string")
1496
+ const { name: requested, size: requestedSize, bold, italic, underline, strike, color } = font;
1497
+ if (requested !== undefined && typeof requested !== "string")
1474
1498
  throw new TypeError("Font name must be a string.");
1475
- const name = cleanXml(font.name ?? "Calibri", this.policy), size = font.size ?? 11;
1499
+ const name = cleanXml(requested ?? "Calibri", this.policy), size = requestedSize ?? 11;
1476
1500
  if (typeof name !== "string" || !name || name.length > 31)
1477
1501
  throw new TypeError("Font name must contain 1 through 31 characters.");
1478
1502
  if (!Number.isFinite(size) || size <= 0 || size > 409)
1479
1503
  throw new RangeError("Font size must be positive and at most 409.");
1480
- return deduplicate(this.fonts, this.fontIndexes, { name, size, bold: !!font.bold, italic: !!font.italic, underline: !!font.underline, strike: !!font.strike, color: font.color ? colorArgb(font.color) : "" }, this.maximum);
1504
+ return deduplicate(this.fonts, this.fontIndexes, { name, size, bold: !!bold, italic: !!italic, underline: !!underline, strike: !!strike, color: color ? colorArgb(color) : "" }, this.maximum);
1481
1505
  }
1482
1506
  addFill(fill) {
1483
- const pattern = fill.pattern ?? (fill.color ? "solid" : "none");
1484
- if (!["none", "gray125", "solid"].includes(pattern) || (pattern === "solid" && !fill.color) || (pattern !== "solid" && fill.color))
1507
+ const { color } = fill, pattern = fill.pattern ?? (color ? "solid" : "none");
1508
+ if (!["none", "gray125", "solid"].includes(pattern) || (pattern === "solid" && !color) || (pattern !== "solid" && color))
1485
1509
  throw new TypeError("A solid fill requires a color; none and gray125 have no color.");
1486
- return deduplicate(this.fills, this.fillIndexes, { pattern, color: fill.color ? colorArgb(fill.color) : "" }, this.maximum + 1);
1510
+ return deduplicate(this.fills, this.fillIndexes, { pattern, color: color ? colorArgb(color) : "" }, this.maximum + 1);
1487
1511
  }
1488
1512
  addBorder(border) {
1489
- const result = {};
1490
- for (const side of ["left", "right", "top", "bottom"]) {
1491
- const edge = border[side];
1492
- if (edge) {
1493
- if (!["thin", "medium", "dashed", "dotted", "thick", "double", "hair", "dashDot", "dashDotDot", "slantDashDot", "mediumDashed", "mediumDashDot", "mediumDashDotDot"].includes(edge.style))
1494
- throw new TypeError("Invalid border style.");
1495
- result[side] = { style: edge.style, ...(edge.color ? { color: colorArgb(edge.color) } : {}) };
1496
- }
1497
- }
1498
- return deduplicate(this.borders, this.borderIndexes, result, this.maximum);
1513
+ return deduplicate(this.borders, this.borderIndexes, normalizeBorder(border), this.maximum);
1499
1514
  }
1500
1515
  addNumberFormat(format) {
1501
1516
  if (typeof format !== "string" || !format || format.length > 255)
@@ -1561,7 +1576,7 @@ class StyleRegistry {
1561
1576
  return this.compose(base, { numberFormat: this.styles[this.validateStyle(dateStyle)].numberFormat });
1562
1577
  }
1563
1578
  /** @internal Column shorthand and header style composition. */
1564
- forColumn(column, header = false, fill, date = false) {
1579
+ forColumn(column, header = false, fill, date = false, border) {
1565
1580
  const base = !header && column.style !== undefined ? this.styles[this.validateStyle(column.style)] : undefined;
1566
1581
  const format = column.format !== undefined ? column.format || NumberFormats.General : base?.numberFormat || (column.type === "date" || date ? NumberFormats.DateTime : NumberFormats.General);
1567
1582
  return this.add({
@@ -1570,7 +1585,7 @@ class StyleRegistry {
1570
1585
  wrapText: column.wrapText ?? base?.wrapText ?? false,
1571
1586
  ...(column.alignment ? { alignment: column.alignment } : base?.alignment ? { alignment: base.alignment } : {}),
1572
1587
  ...(base?.verticalAlignment ? { verticalAlignment: base.verticalAlignment } : {}),
1573
- ...(header ? { font: { bold: true } } : {}), ...(fill ? { fill: { color: fill } } : {})
1588
+ ...(header ? { font: { bold: true } } : {}), ...(fill ? { fill: { color: fill } } : {}), ...(border ? { border } : {})
1574
1589
  });
1575
1590
  }
1576
1591
  toXml() {
@@ -1595,8 +1610,8 @@ class StyleRegistry {
1595
1610
  }).join("") + '</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>' + this.differential.toXml() + '</styleSheet>';
1596
1611
  }
1597
1612
  }
1598
- const _exports = Object.freeze({ colorArgb: _m17.colorArgb, spreadsheetNamespace: spreadsheetNamespace, NumberFormats: NumberFormats, validateStylePatch: validateStylePatch, copyStylePatch: copyStylePatch, StyleRegistry: StyleRegistry });
1599
- _modules.set("077c3c668f1457253dba044e6f6be7f7afd28a8976ed20c764bd5d5dc7c41889", _exports);
1613
+ const _exports = Object.freeze({ colorArgb: _m17.colorArgb, spreadsheetNamespace: spreadsheetNamespace, normalizeBorder: normalizeBorder, NumberFormats: NumberFormats, validateStylePatch: validateStylePatch, copyStylePatch: copyStylePatch, StyleRegistry: StyleRegistry });
1614
+ _modules.set("8d96d0024443ac9aeaea70e9324b53aacef098c2385d4e6a89a76d184e28556a", _exports);
1600
1615
  return _exports;
1601
1616
  })();
1602
1617
 
@@ -3060,14 +3075,14 @@ _modules.set("13fa96d976e4dec7343dd3a392829567f1fcb574324a98f5a5d3a61c9a0dc27d",
3060
3075
  return _exports;
3061
3076
  })();
3062
3077
 
3063
- const _m27 = _modules.get("a61e744201bb537b635b367b1764bd85892101d55e00b8c78faec8be89577376") ?? (() => {
3078
+ const _m27 = _modules.get("d5957683aa1945575924c89c63b427878e6e6e47ef5c229dc524b1879d146499") ?? (() => {
3064
3079
  const { checkAbort, consumeRows, inputRows, pause, taskYieldDue } = _m2;
3065
3080
 
3066
3081
  const { ChunkedTextSink, BlobByteSink } = _m5;
3067
3082
 
3068
3083
  const { OfficeIMOError } = _m3;
3069
3084
 
3070
- const { notifyProgress } = _m4;
3085
+ const { notifyProgress, notifySynchronously } = _m4;
3071
3086
 
3072
3087
  const { copyColumns, createRowProjector } = _m24;
3073
3088
 
@@ -3139,8 +3154,14 @@ class Worksheet {
3139
3154
  pendingCharacters = 0;
3140
3155
  reservedLayout = false;
3141
3156
  internalLinks = [];
3157
+ // Evicted entries become holes and are compacted in one pass when the links are read, keeping eviction O(1).
3142
3158
  links = [];
3159
+ evictedLinks = 0;
3143
3160
  linkedCells = new Set();
3161
+ /** Indexes in `links` of data-cell links that `hyperlinkOverflow: "drop"` may give up, in row order. */
3162
+ droppable = [];
3163
+ droppableLinks = new WeakSet();
3164
+ droppedLinks = 0;
3144
3165
  pictures = [];
3145
3166
  nativeCharts = [];
3146
3167
  conditional;
@@ -3171,8 +3192,9 @@ class Worksheet {
3171
3192
  book.checkLinks(this.links.length);
3172
3193
  this.declared = this.columns.map((column, i) => ({ column, letter: columnName(i + 1),
3173
3194
  style: book.styles.forColumn(column), dateStyle: book.styles.forColumn(column, false, undefined, true),
3174
- headerStyle: this.headerRows ? options.headerStyle ?? book.styles.forColumn({ header: column.header, ...(column.wrapText === undefined ? {} : { wrapText: column.wrapText }),
3175
- ...(column.alignment === undefined ? {} : { alignment: column.alignment }) }, options.boldHeader !== false, options.headerFill) : 0
3195
+ headerStyle: this.headerRows ? options.headerStyle ?? book.styles.forColumn({ header: column.header,
3196
+ ...((options.headerWrap ?? column.wrapText) === undefined ? {} : { wrapText: options.headerWrap ?? column.wrapText }),
3197
+ ...(column.alignment === undefined ? {} : { alignment: column.alignment }) }, options.boldHeader !== false, options.headerFill, false, options.headerBorder) : 0
3176
3198
  }));
3177
3199
  // Register conditional styles only after worksheet construction can no longer reject its options.
3178
3200
  this.conditional = new ConditionalFormats(conditional, book.styles);
@@ -3224,6 +3246,8 @@ class Worksheet {
3224
3246
  throw new TypeError("A frozen header or autofilter requires a header row.");
3225
3247
  if (options.headerFill !== undefined)
3226
3248
  colorArgb(options.headerFill);
3249
+ if (options.headerWrap !== undefined && typeof options.headerWrap !== "boolean")
3250
+ throw new TypeError("headerWrap must be boolean.");
3227
3251
  if (options.headerStyle !== undefined)
3228
3252
  book.styles.validateStyle(options.headerStyle);
3229
3253
  if (options.alternatingRowStyle !== undefined)
@@ -3349,7 +3373,8 @@ class Worksheet {
3349
3373
  const cell = col.letter + row;
3350
3374
  if (link || this.linkedCells.has(cell))
3351
3375
  throw new TypeError("A text-preservation cell cannot also have an external hyperlink.");
3352
- checkHyperlinkCount(this.links.length + this.internalLinks.length + 1);
3376
+ this.makeLinkRoom();
3377
+ checkHyperlinkCount(this.linkCount + 1);
3353
3378
  this.book.checkLinks(1);
3354
3379
  // Replace a generated cell's original reservation with its preview and overflow records.
3355
3380
  if (reservedCharacters !== undefined) {
@@ -3363,7 +3388,7 @@ class Worksheet {
3363
3388
  value = preserved.preview;
3364
3389
  }
3365
3390
  if (link)
3366
- this.appendHyperlink({ cell: col.letter + row, ...link });
3391
+ this.appendHyperlink({ cell: col.letter + row, ...link }, !header && !footer && !title && this.book.settings.hyperlinkOverflow === "drop");
3367
3392
  if (type === "date")
3368
3393
  value = excelDate(value, this.book.settings.dateMode);
3369
3394
  if (!header && !footer && visible && (!formula || !isSubtotalFormula(formula)))
@@ -3672,20 +3697,61 @@ class Worksheet {
3672
3697
  throw this.error;
3673
3698
  this.appendHyperlink(link);
3674
3699
  }
3675
- appendHyperlink(link) {
3700
+ appendHyperlink(link, droppable = false) {
3701
+ // Validate before any overflow decision, so a dropped link can never hide an unsafe target.
3676
3702
  const copied = copyHyperlink(link, this.book.settings.invalidCharacterPolicy);
3677
3703
  const position = cellPosition(copied.cell);
3678
3704
  if (this.layout.regions.covered(position.column, position.row))
3679
3705
  throw new TypeError("Hyperlinks cannot address a covered merged cell.");
3680
3706
  if (this.linkedCells.has(copied.cell))
3681
3707
  throw new TypeError("Duplicate hyperlink cell: " + copied.cell);
3682
- checkHyperlinkCount(this.links.length + this.internalLinks.length + 1);
3708
+ if (droppable && this.linkCount >= maximumHyperlinks) {
3709
+ this.droppedLinks++;
3710
+ return;
3711
+ }
3712
+ if (!droppable)
3713
+ this.makeLinkRoom();
3714
+ checkHyperlinkCount(this.linkCount + 1);
3683
3715
  this.book.retainLink();
3716
+ if (droppable) {
3717
+ this.droppable.push(this.links.length);
3718
+ this.droppableLinks.add(copied);
3719
+ }
3684
3720
  this.links.push(copied);
3685
3721
  this.linkedCells.add(copied.cell);
3686
3722
  }
3723
+ /** Links the worksheet holds now, not counting evicted holes. */
3724
+ get linkCount() { return this.links.length - this.evictedLinks + this.internalLinks.length; }
3725
+ /** A full worksheet gives up its latest data-cell link for a link that cannot be dropped. Hyperlinks are serialized after
3726
+ * the rows, so the cell keeps its written value. The entry becomes a hole, so other indexes stay valid until compaction. */
3727
+ makeLinkRoom() {
3728
+ if (this.linkCount < maximumHyperlinks || !this.droppable.length)
3729
+ return;
3730
+ const index = this.droppable.pop(), removed = this.links[index];
3731
+ this.links[index] = undefined;
3732
+ this.evictedLinks++;
3733
+ this.linkedCells.delete(removed.cell);
3734
+ this.book.releaseLink();
3735
+ this.droppedLinks++;
3736
+ }
3737
+ /** One ordered pass removes evicted holes and rebuilds the droppable indexes. */
3738
+ compactLinks() {
3739
+ if (this.evictedLinks) {
3740
+ const kept = [], droppable = [];
3741
+ for (const link of this.links)
3742
+ if (link) {
3743
+ if (this.droppableLinks.has(link))
3744
+ droppable.push(kept.length);
3745
+ kept.push(link);
3746
+ }
3747
+ this.links = kept;
3748
+ this.droppable = droppable;
3749
+ this.evictedLinks = 0;
3750
+ }
3751
+ return this.links;
3752
+ }
3687
3753
  /** @internal */
3688
- get hyperlinks() { return this.links; }
3754
+ get hyperlinks() { return this.compactLinks(); }
3689
3755
  /** @internal */
3690
3756
  get images() { return this.pictures; }
3691
3757
  /** @internal An empty export has no data table; it still emits the declared headers. */
@@ -3736,7 +3802,7 @@ class Worksheet {
3736
3802
  for (const binding of this.chartSources)
3737
3803
  binding.finish();
3738
3804
  this.chartSources.length = 0;
3739
- for (const link of this.links) {
3805
+ for (const link of this.compactLinks()) {
3740
3806
  const position = cellPosition(link.cell);
3741
3807
  if (position.column > this.columns.length || position.row > this.totalRows)
3742
3808
  throw new RangeError("Hyperlinks must address cells within the exported rows and columns.");
@@ -3766,8 +3832,11 @@ class Worksheet {
3766
3832
  await this.buffer.write(xml);
3767
3833
  for (const xml of dataValidationsXml(this.validations, this.headerRows, this.count, detailRanges))
3768
3834
  await this.buffer.write(xml);
3769
- if (this.links.length || this.internalLinks.length)
3770
- await this.buffer.write(hyperlinksXml(this.links, this.book.settings.invalidCharacterPolicy, this.internalLinks));
3835
+ if (this.droppedLinks)
3836
+ notifySynchronously("onHyperlinkOverflow", this.book.settings.onHyperlinkOverflow, Object.freeze({ sheetName: this.name, dropped: this.droppedLinks }));
3837
+ const links = this.compactLinks();
3838
+ if (links.length || this.internalLinks.length)
3839
+ await this.buffer.write(hyperlinksXml(links, this.book.settings.invalidCharacterPolicy, this.internalLinks));
3771
3840
  await this.buffer.write(printXml(this.options.print, this.book.settings.invalidCharacterPolicy));
3772
3841
  if (this.pictures.length || this.nativeCharts.length)
3773
3842
  await this.buffer.write('<drawing r:id="drawing"/>');
@@ -3792,11 +3861,11 @@ class Worksheet {
3792
3861
  async discard(error) { this.failed = true; this.error = error; this.pending = []; this.pendingCharacters = 0; this.prepared = undefined; this.buffer = undefined; this.nativeCharts.length = 0; this.chartSources.length = 0; this.output.discard(); await this.entry?.discard(error); }
3793
3862
  }
3794
3863
  const _exports = Object.freeze({ Worksheet: Worksheet });
3795
- _modules.set("a61e744201bb537b635b367b1764bd85892101d55e00b8c78faec8be89577376", _exports);
3864
+ _modules.set("d5957683aa1945575924c89c63b427878e6e6e47ef5c229dc524b1879d146499", _exports);
3796
3865
  return _exports;
3797
3866
  })();
3798
3867
 
3799
- const _m38 = _modules.get("1b4698baf9a9c9b3505988abac9f83967c32cf37483d70a949ae89c4485532a4") ?? (() => {
3868
+ const _m38 = _modules.get("c84eae41cd3066f5463d88a1f467117b37dd9e9c9ccd8c0f8a106aa41631fea0") ?? (() => {
3800
3869
  const { escapeOoxmlAttribute, escapeXml, xmlDeclaration } = _m11;
3801
3870
 
3802
3871
  const { cellText, columnName } = _m19;
@@ -3839,7 +3908,7 @@ function tableXml(table, rowCount, policy, headerRow = 1, footer) {
3839
3908
  '" showColumnStripes="' + (options.bandedColumns ? 1 : 0) + '"/></table>';
3840
3909
  }
3841
3910
  const _exports = Object.freeze({ defineTable: defineTable, tableXml: tableXml });
3842
- _modules.set("1b4698baf9a9c9b3505988abac9f83967c32cf37483d70a949ae89c4485532a4", _exports);
3911
+ _modules.set("c84eae41cd3066f5463d88a1f467117b37dd9e9c9ccd8c0f8a106aa41631fea0", _exports);
3843
3912
  return _exports;
3844
3913
  })();
3845
3914
 
@@ -3911,13 +3980,13 @@ _modules.set("0c395783b9d7cc62dd39a21adeb698ad4a61e2c89f7b1fc8712e2eb2ccfe9d92",
3911
3980
  return _exports;
3912
3981
  })();
3913
3982
 
3914
- const _m40 = _modules.get("477ff98f49343b8ec4213008254b57a60dd42d07cb9843b3791d5e5f8e295865") ?? (() => {
3983
+ const _m40 = _modules.get("fd70ccda89f27c6b874c8840ac944b3ec723dbdef3dfe7600f7bdb81f4660c96") ?? (() => {
3915
3984
  const { captureFields } = _m7;
3916
3985
 
3917
3986
  /** @internal The workbook owner captures these settings before validation or adapter merging. */
3918
- const workbookOptionFields = ["signal", "onProgress", "limits", "sink", "dateMode", "compression", "invalidCharacterPolicy", "appProperties", "cellValueWriters", "oversizedText", "creator", "title", "subject", "description", "created", "modified"];
3987
+ const workbookOptionFields = ["signal", "onProgress", "limits", "sink", "dateMode", "compression", "invalidCharacterPolicy", "appProperties", "cellValueWriters", "oversizedText", "hyperlinkOverflow", "onHyperlinkOverflow", "creator", "title", "subject", "description", "created", "modified"];
3919
3988
  /** @internal Worksheet settings also used by the portable sheet owner. */
3920
- const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "outlineSummaryBelow", "outlineSummaryRight", "columnOutlines", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
3989
+ const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerBorder", "headerWrap", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "outlineSummaryBelow", "outlineSummaryRight", "columnOutlines", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
3921
3990
  /** @internal Includes inherited format-specific ceilings before a wrapper combines stream settings. */
3922
3991
  const workbookLimitFields = ["maxRows", "maxCells", "maxTextCharacters", "maxOutputBytes", "maxStyles", "maxSheets", "maxOverflowCharacters", "maxHyperlinks", "maxImageBytes", "maxBufferedCells", "maxBufferedCharacters", "maxMergedRanges", "maxConditionalFormats", "maxDifferentialStyles", "maxCharts", "maxChartPoints", "maxChartTextCharacters", "maxFormulaCharacters", "maxDataValidations", "maxValidationTextCharacters"];
3923
3992
  /** @internal Capture the workbook's known ceilings without dropping supported prototype fields. */
@@ -3930,7 +3999,7 @@ function captureWorkbookOptions(options) {
3930
3999
  return { ...captured, ...(captured.limits === undefined ? {} : { limits: captureWorkbookLimits(captured.limits) }) };
3931
4000
  }
3932
4001
  const _exports = Object.freeze({ workbookOptionFields: workbookOptionFields, sheetOptionFields: sheetOptionFields, workbookLimitFields: workbookLimitFields, captureWorkbookLimits: captureWorkbookLimits, captureWorkbookOptions: captureWorkbookOptions });
3933
- _modules.set("477ff98f49343b8ec4213008254b57a60dd42d07cb9843b3791d5e5f8e295865", _exports);
4002
+ _modules.set("fd70ccda89f27c6b874c8840ac944b3ec723dbdef3dfe7600f7bdb81f4660c96", _exports);
3934
4003
  return _exports;
3935
4004
  })();
3936
4005
 
@@ -4237,7 +4306,7 @@ _modules.set("24f1417c3c320a8a41137c28f70b72091256c63010be0c88b684dce85f54950c",
4237
4306
  return _exports;
4238
4307
  })();
4239
4308
 
4240
- const _m1 = _modules.get("e89ecd2f5e1738c6e88f72ac2bcac70dfaa81b4aa86edf333e9b395cf2212e2a") ?? (() => {
4309
+ const _m1 = _modules.get("a34a46ed9564c388d5f3ca087c70819f8aa897e469ca50f8547233c264a8e8af") ?? (() => {
4241
4310
  const { beginTask, checkAbort, pause, taskYieldDue } = _m2;
4242
4311
 
4243
4312
  const { OfficeIMOError } = _m3;
@@ -4252,7 +4321,7 @@ const { OpcPackage, officeRelationshipsNamespace, relationshipTypes, corePropert
4252
4321
 
4253
4322
  const { escapeOoxmlAttribute, cleanXml, xmlDeclaration } = _m11;
4254
4323
 
4255
- const { StyleRegistry, spreadsheetNamespace } = _m16;
4324
+ const { StyleRegistry, spreadsheetNamespace, normalizeBorder } = _m16;
4256
4325
 
4257
4326
  const { sheetName, assertXlsxValue, copyValue } = _m19;
4258
4327
 
@@ -4293,6 +4362,8 @@ function captureSheet(options, policy) {
4293
4362
  return { ...captured, columns,
4294
4363
  ...(captured.columnOutlines === undefined ? {} : { columnOutlines: captureColumnOutlines(captured.columnOutlines, columns.length) }),
4295
4364
  ...(captured.headerRows === undefined ? {} : { headerRows: captureTableSpans(captured.headerRows, columns.length) }),
4365
+ // Preflight and every header style read this one snapshot of the edges.
4366
+ ...(captured.headerBorder === undefined ? {} : { headerBorder: normalizeBorder(captured.headerBorder) }),
4296
4367
  ...(footer ? { footer: { ...footer,
4297
4368
  ...(footer.rows === undefined ? {} : { rows: captureTableSpans(footer.rows, columns.length) }),
4298
4369
  ...(footer.values === undefined ? {} : { values: footer.values.map(copyValue) }) } } : {}),
@@ -4368,6 +4439,10 @@ class Workbook {
4368
4439
  throw new RangeError("compression must be auto or store.");
4369
4440
  if (options.oversizedText !== undefined && !["reject", "preserve"].includes(options.oversizedText))
4370
4441
  throw new RangeError("oversizedText must be reject or preserve.");
4442
+ if (options.hyperlinkOverflow !== undefined && !["reject", "drop"].includes(options.hyperlinkOverflow))
4443
+ throw new RangeError("hyperlinkOverflow must be reject or drop.");
4444
+ if (options.onHyperlinkOverflow !== undefined && typeof options.onHyperlinkOverflow !== "function")
4445
+ throw new TypeError("onHyperlinkOverflow must be a function.");
4371
4446
  cleanXml("", policy);
4372
4447
  corePropertiesXml(options, policy);
4373
4448
  this.budget = new ExportBudget(options.limits);
@@ -4445,6 +4520,8 @@ class Workbook {
4445
4520
  }
4446
4521
  /** @internal Reserve a preflighted worksheet batch or one row hyperlink. */
4447
4522
  retainLink(count = 1) { this.checkLinks(count); this.links += count; }
4523
+ /** @internal A worksheet dropped a data-cell link it had retained. */
4524
+ releaseLink() { this.links--; }
4448
4525
  /** @internal */
4449
4526
  checkImage(bytes) {
4450
4527
  if (this.settings.limits?.maxImageBytes !== undefined && this.imageBytes + bytes > this.settings.limits.maxImageBytes)
@@ -4718,11 +4795,11 @@ class Workbook {
4718
4795
  }
4719
4796
  }
4720
4797
  const _exports = Object.freeze({ Workbook: Workbook });
4721
- _modules.set("e89ecd2f5e1738c6e88f72ac2bcac70dfaa81b4aa86edf333e9b395cf2212e2a", _exports);
4798
+ _modules.set("a34a46ed9564c388d5f3ca087c70819f8aa897e469ca50f8547233c264a8e8af", _exports);
4722
4799
  return _exports;
4723
4800
  })();
4724
4801
 
4725
- const _m44 = _modules.get("a10003e971cd5ec2cee127bc9b029a0aa06fe3d50112838929d7a04a55e177c0") ?? (() => {
4802
+ const _m44 = _modules.get("d6884428c3e4d15a691ecf2523372a03b32de22a890edfbfc9961f2dc92711c2") ?? (() => {
4726
4803
  const { ExportCell, assertScalar } = _m20;
4727
4804
 
4728
4805
  const { captureWorkbookOptions, sheetOptionFields } = _m40;
@@ -4744,7 +4821,7 @@ function value(result) {
4744
4821
  function portableSheet(options = {}) {
4745
4822
  options = captureFields(options, sheetOptionFields);
4746
4823
  if (options.headerStyle !== undefined)
4747
- throw new TypeError("Workbook-local header styles require the advanced Workbook API; use boldHeader and headerFill.");
4824
+ throw new TypeError("Workbook-local header styles require the advanced Workbook API; use boldHeader, headerFill, headerBorder and headerWrap.");
4748
4825
  style(options.alternatingRowStyle);
4749
4826
  style(options.title?.style);
4750
4827
  style(options.footer?.style);
@@ -4771,11 +4848,11 @@ function portableWorkbook(options = {}) {
4771
4848
  return { ...options, cellValueWriters: wrapped };
4772
4849
  }
4773
4850
  const _exports = Object.freeze({ portableSheet: portableSheet, portableWorkbook: portableWorkbook });
4774
- _modules.set("a10003e971cd5ec2cee127bc9b029a0aa06fe3d50112838929d7a04a55e177c0", _exports);
4851
+ _modules.set("d6884428c3e4d15a691ecf2523372a03b32de22a890edfbfc9961f2dc92711c2", _exports);
4775
4852
  return _exports;
4776
4853
  })();
4777
4854
 
4778
- const _m43 = _modules.get("5bfd5c9c5e179305b9bebd6cb0d6a0d75e974b223e119e0fd4fbb773325f1e63") ?? (() => {
4855
+ const _m43 = _modules.get("b9b1793c41e466048fe823422088a6fcc1fd8393c67293df3f0cd83a5d5ec7e1") ?? (() => {
4779
4856
  const { withDestination } = _m5;
4780
4857
 
4781
4858
  const { copyColumns } = _m24;
@@ -4830,7 +4907,7 @@ async function writeXlsxTo(rows, destination, configuration) {
4830
4907
  });
4831
4908
  }
4832
4909
  const _exports = Object.freeze({ writeXlsx: writeXlsx, writeXlsxTo: writeXlsxTo });
4833
- _modules.set("5bfd5c9c5e179305b9bebd6cb0d6a0d75e974b223e119e0fd4fbb773325f1e63", _exports);
4910
+ _modules.set("b9b1793c41e466048fe823422088a6fcc1fd8393c67293df3f0cd83a5d5ec7e1", _exports);
4834
4911
  return _exports;
4835
4912
  })();
4836
4913
 
@@ -5100,7 +5177,7 @@ _modules.set("046b305cdccf817d847addb75a778131622de23f2840830bbe1c0c26053a68c0",
5100
5177
  return _exports;
5101
5178
  })();
5102
5179
 
5103
- const _m47 = _modules.get("dd34d5fd89869a0f953f3f2b3fd27ac83be29e68f76c9087fae3d33095aeda7c") ?? (() => {
5180
+ const _m47 = _modules.get("ba0e1f29c8de5d46b966b7b097260529e42b80f662e92a7f9e8add22df747a50") ?? (() => {
5104
5181
  const { assertGroupedReportSource } = _m46;
5105
5182
 
5106
5183
  const { captureFields } = _m7;
@@ -5189,11 +5266,11 @@ function prepareGroupedSheet(report, configuration, maxConditionalFormats = 1000
5189
5266
  ...(options.grandTotalStyle ? { grandTotalStyle: copyStylePatch(options.grandTotalStyle) } : {}) };
5190
5267
  }
5191
5268
  const _exports = Object.freeze({ groupedOptionFields: groupedOptionFields, prepareGroupedSheet: prepareGroupedSheet });
5192
- _modules.set("dd34d5fd89869a0f953f3f2b3fd27ac83be29e68f76c9087fae3d33095aeda7c", _exports);
5269
+ _modules.set("ba0e1f29c8de5d46b966b7b097260529e42b80f662e92a7f9e8add22df747a50", _exports);
5193
5270
  return _exports;
5194
5271
  })();
5195
5272
 
5196
- const _m45 = _modules.get("2ba62cdf88d559804bb84b20e9816b2de0f232401b7431ac414699a607d554a4") ?? (() => {
5273
+ const _m45 = _modules.get("d7cfa6a7b1be9758925a4ccb860a80a33eb0de2c88c80cc55e438213595f2b71") ?? (() => {
5197
5274
  const { groupedReportOperation } = _m46;
5198
5275
 
5199
5276
  const { checkAbort, withAbort } = _m2;
@@ -5366,7 +5443,7 @@ async function writeGroupedXlsxTo(report, destination, options) {
5366
5443
  return withDestination(destination, async (sink) => (await write(report, prepared, sink)).result);
5367
5444
  }
5368
5445
  const _exports = Object.freeze({ addGroupedXlsx: addGroupedXlsx, writeGroupedXlsx: writeGroupedXlsx, writeGroupedXlsxTo: writeGroupedXlsxTo });
5369
- _modules.set("2ba62cdf88d559804bb84b20e9816b2de0f232401b7431ac414699a607d554a4", _exports);
5446
+ _modules.set("d7cfa6a7b1be9758925a4ccb860a80a33eb0de2c88c80cc55e438213595f2b71", _exports);
5370
5447
  return _exports;
5371
5448
  })();
5372
5449
 
@@ -5419,10 +5496,10 @@ _modules.set("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00",
5419
5496
  return _exports;
5420
5497
  })();
5421
5498
 
5422
- const _m0 = _modules.get("d6587a933b36ccfdba9a2a252389924ac8461f672b3a500082cceb5e53c8b0b6") ?? (() => {
5499
+ const _m0 = _modules.get("edf1bf5cb6d749de0e6823397df6610a6c1cc88768898c1b4d7083ee96ef6759") ?? (() => {
5423
5500
 
5424
5501
  const _exports = Object.freeze({ Workbook: _m1.Workbook, writeXlsx: _m43.writeXlsx, writeXlsxTo: _m43.writeXlsxTo, writeGroupedXlsx: _m45.writeGroupedXlsx, writeGroupedXlsxTo: _m45.writeGroupedXlsxTo, addGroupedXlsx: _m45.addGroupedXlsx, createGroupedReport: _m46.createGroupedReport, Worksheet: _m27.Worksheet, Cell: _m19.Cell, FormulaCell: _m22.FormulaCell, StyleRegistry: _m16.StyleRegistry, NumberFormats: _m16.NumberFormats, saveBlob: _m48.saveBlob, ExportCell: _m20.ExportCell });
5425
- _modules.set("d6587a933b36ccfdba9a2a252389924ac8461f672b3a500082cceb5e53c8b0b6", _exports);
5502
+ _modules.set("edf1bf5cb6d749de0e6823397df6610a6c1cc88768898c1b4d7083ee96ef6759", _exports);
5426
5503
  return _exports;
5427
5504
  })();
5428
5505
  Object.assign(officeimo, _m0, { core: _m48, zip: _m13, xml: _m11, opc: _m8, xlsx: _m0 });