ooxml-core 1.8.2 → 1.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14331,6 +14331,222 @@ function shiftFormulaInBand(formula, formulaSheet, sheet, shift2, band) {
14331
14331
  return changed ? tokens.map((t) => t.text).join("") : formula;
14332
14332
  }
14333
14333
 
14334
+ // xlsx/layout/sparkline-view.ts
14335
+ var DEFAULTS = {
14336
+ colorSeries: "#376092",
14337
+ colorNegative: "#D00000",
14338
+ colorAxis: "#000000",
14339
+ colorMarkers: "#D00000",
14340
+ colorFirst: "#D00000",
14341
+ colorLast: "#D00000",
14342
+ colorHigh: "#D00000",
14343
+ colorLow: "#D00000"
14344
+ };
14345
+ var COLUMN_GAP = 0.2;
14346
+ function extent(values2) {
14347
+ let min = Infinity;
14348
+ let max = -Infinity;
14349
+ for (const v of values2) {
14350
+ if (v === null) continue;
14351
+ if (v < min) min = v;
14352
+ if (v > max) max = v;
14353
+ }
14354
+ return min <= max ? { min, max } : void 0;
14355
+ }
14356
+ function sparklineValues(group, values2) {
14357
+ return group.displayEmptyCellsAs === "zero" ? values2.map((v) => v ?? 0) : [...values2];
14358
+ }
14359
+ function sparklineScale(group, all2, index2) {
14360
+ const own = extent(sparklineValues(group, all2[index2]?.values ?? []));
14361
+ const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
14362
+ const shared = needsGroup ? extent(all2.flatMap((data) => sparklineValues(group, data.values))) : void 0;
14363
+ const end = (type, manual, key) => {
14364
+ if (type === "custom" && manual !== void 0) return manual;
14365
+ if (type === "group" && shared) return shared[key];
14366
+ return own?.[key];
14367
+ };
14368
+ const min = end(group.minAxisType, group.manualMin, "min");
14369
+ const max = end(group.maxAxisType, group.manualMax, "max");
14370
+ return min === void 0 || max === void 0 ? void 0 : { min, max };
14371
+ }
14372
+ function positions(group, data, n) {
14373
+ const dates = data.dates;
14374
+ if (group.dateAxis && dates && dates.length === n) {
14375
+ const span4 = extent(dates);
14376
+ if (span4) {
14377
+ const width = span4.max - span4.min;
14378
+ return dates.map((d) => d === null ? null : width ? (d - span4.min) / width : 0.5);
14379
+ }
14380
+ }
14381
+ return Array.from({ length: n }, (_, i2) => n === 1 ? 0.5 : i2 / (n - 1));
14382
+ }
14383
+ function pointFacts(values2) {
14384
+ const numbers3 = values2.filter((x) => x !== null);
14385
+ let last = values2.length - 1;
14386
+ while (last >= 0 && values2[last] === null) last--;
14387
+ return {
14388
+ high: Math.max(...numbers3),
14389
+ low: Math.min(...numbers3),
14390
+ first: values2.findIndex((x) => x !== null),
14391
+ last
14392
+ };
14393
+ }
14394
+ function pointColor(group, v, i2, facts, colors, markers) {
14395
+ let color = markers && group.markers ? colors.colorMarkers : void 0;
14396
+ if (group.negative && v < 0) color = colors.colorNegative;
14397
+ if (group.high && v === facts.high) color = colors.colorHigh;
14398
+ if (group.low && v === facts.low) color = colors.colorLow;
14399
+ if (group.first && i2 === facts.first) color = colors.colorFirst;
14400
+ if (group.last && i2 === facts.last) color = colors.colorLast;
14401
+ return color;
14402
+ }
14403
+ function resolveColors(group, theme2) {
14404
+ const out = { ...DEFAULTS };
14405
+ for (const key of Object.keys(DEFAULTS)) {
14406
+ const color = group[key];
14407
+ out[key] = resolveColor(color, theme2, DEFAULTS[key]) ?? DEFAULTS[key];
14408
+ }
14409
+ return out;
14410
+ }
14411
+ function sparklineView(group, data, scale2, theme2) {
14412
+ const colors = resolveColors(group, theme2);
14413
+ const view = {
14414
+ type: group.type,
14415
+ color: colors.colorSeries,
14416
+ lineWeightPt: group.lineWeight,
14417
+ lines: [],
14418
+ markers: [],
14419
+ columns: []
14420
+ };
14421
+ const values2 = sparklineValues(group, data.values);
14422
+ const n = values2.length;
14423
+ if (!n || !scale2) return view;
14424
+ const facts = pointFacts(values2);
14425
+ const xs = positions(group, data, n);
14426
+ const flip = (x) => group.rightToLeft ? 1 - x : x;
14427
+ const range2 = scale2.max - scale2.min;
14428
+ const yOf = (v) => range2 ? Math.max(0, Math.min(1, (scale2.max - v) / range2)) : 0.5;
14429
+ if (group.type === "line") {
14430
+ let segment = [];
14431
+ values2.forEach((v, i2) => {
14432
+ const x = xs[i2];
14433
+ if (v === null || x === null || x === void 0) {
14434
+ if (group.displayEmptyCellsAs === "gap" && segment.length) {
14435
+ view.lines.push(segment);
14436
+ segment = [];
14437
+ }
14438
+ return;
14439
+ }
14440
+ const point = { x: flip(x), y: yOf(v) };
14441
+ segment.push(point);
14442
+ const color = pointColor(group, v, i2, facts, colors, true);
14443
+ if (color) view.markers.push({ ...point, color });
14444
+ });
14445
+ if (segment.length) view.lines.push(segment);
14446
+ } else {
14447
+ const slot = 1 / n;
14448
+ const w = slot * (1 - COLUMN_GAP);
14449
+ const base = yOf(Math.max(scale2.min, Math.min(scale2.max, 0)));
14450
+ values2.forEach((v, i2) => {
14451
+ const position = xs[i2];
14452
+ if (v === null || position === null || position === void 0) return;
14453
+ if (v === 0) return;
14454
+ let top;
14455
+ let bottom;
14456
+ if (group.type === "stacked") [top, bottom] = v > 0 ? [0, 0.5] : [0.5, 1];
14457
+ else if (!range2) [top, bottom] = [0, 1];
14458
+ else [top, bottom] = [Math.min(base, yOf(v)), Math.max(base, yOf(v))];
14459
+ const centre = flip(slot / 2 + position * (1 - slot));
14460
+ const color = pointColor(group, v, i2, facts, colors, false) ?? view.color;
14461
+ view.columns.push({ x: centre - w / 2, y: top, w, h: bottom - top, color });
14462
+ });
14463
+ }
14464
+ if (group.type === "stacked") {
14465
+ if (group.displayXAxis) view.axis = { y: 0.5, color: colors.colorAxis };
14466
+ } else if (group.displayXAxis && range2 && scale2.min <= 0 && scale2.max >= 0)
14467
+ view.axis = { y: yOf(0), color: colors.colorAxis };
14468
+ return view;
14469
+ }
14470
+
14471
+ // xlsx/layout/sparkline-data.ts
14472
+ var MAX_POINTS = 1e4;
14473
+ var hostIndex = /* @__PURE__ */ new WeakMap();
14474
+ function hosts(sheet) {
14475
+ const groups = sheetSparklineGroups(sheet);
14476
+ let index2 = hostIndex.get(groups);
14477
+ if (!index2) {
14478
+ index2 = /* @__PURE__ */ new Map();
14479
+ for (const group of groups)
14480
+ group.sparklines.forEach((line2, i2) => {
14481
+ const key = cellKey(line2.host.start.row, line2.host.start.col);
14482
+ if (!index2.has(key)) index2.set(key, { group, index: i2 });
14483
+ });
14484
+ hostIndex.set(groups, index2);
14485
+ }
14486
+ return index2;
14487
+ }
14488
+ function hasSparklineAt(sheet, row2, col) {
14489
+ return hosts(sheet).has(cellKey(row2, col));
14490
+ }
14491
+ function resolveSparklineRange(workbook, sheet, formula) {
14492
+ const ref = formula.trim().replace(/^=/, "");
14493
+ const bang = ref.lastIndexOf("!");
14494
+ let target2 = sheet;
14495
+ if (bang >= 0) {
14496
+ const raw = ref.slice(0, bang);
14497
+ const name = /^'.*'$/.test(raw) ? raw.slice(1, -1).replace(/''/g, "'") : raw;
14498
+ target2 = sheetByName(workbook, name);
14499
+ }
14500
+ const range2 = parseRange(ref.slice(bang + 1).replace(/\$/g, ""));
14501
+ return target2 && range2 ? { sheet: target2, range: normalizeRange(range2) } : void 0;
14502
+ }
14503
+ var rowHidden = (sheet, row2) => sheet.rowInfo.get(row2)?.hidden === true;
14504
+ var colHidden = (sheet, col) => sheet.columns.some((c) => c.hidden === true && col >= c.min && col <= c.max);
14505
+ function readSparklineValues(sheet, range2, displayHidden) {
14506
+ let endRow = range2.end.row;
14507
+ if (endRow - range2.start.row >= MAX_POINTS) {
14508
+ let lastRow = range2.start.row;
14509
+ for (const row2 of sheet.rows.keys()) if (row2 > lastRow) lastRow = row2;
14510
+ endRow = Math.min(endRow, lastRow);
14511
+ }
14512
+ const out = [];
14513
+ for (let row2 = range2.start.row; row2 <= endRow && out.length < MAX_POINTS; row2++) {
14514
+ if (!displayHidden && rowHidden(sheet, row2)) continue;
14515
+ for (let col = range2.start.col; col <= range2.end.col && out.length < MAX_POINTS; col++) {
14516
+ if (!displayHidden && colHidden(sheet, col)) continue;
14517
+ const value2 = getCell(sheet, row2, col)?.value;
14518
+ out.push(typeof value2 === "number" && Number.isFinite(value2) ? value2 : null);
14519
+ }
14520
+ }
14521
+ return out;
14522
+ }
14523
+ function groupData(workbook, sheet, group) {
14524
+ const dateRange = group.dateAxis && group.dateFormula;
14525
+ const dates = dateRange ? resolveSparklineRange(workbook, sheet, dateRange) : void 0;
14526
+ const dateValues = dates ? readSparklineValues(dates.sheet, dates.range, group.displayHidden) : void 0;
14527
+ return group.sparklines.map((line2) => {
14528
+ const source = line2.formula ? resolveSparklineRange(workbook, sheet, line2.formula) : void 0;
14529
+ const values2 = source ? readSparklineValues(source.sheet, source.range, group.displayHidden) : [];
14530
+ return dateValues ? { values: values2, dates: dateValues } : { values: values2 };
14531
+ });
14532
+ }
14533
+ function sparklineViewAt(workbook, sheetIndex2, row2, col) {
14534
+ const sheet = workbook.sheets[sheetIndex2];
14535
+ if (!sheet) return void 0;
14536
+ const entry = hosts(sheet).get(cellKey(row2, col));
14537
+ if (!entry) return void 0;
14538
+ const { group, index: index2 } = entry;
14539
+ const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
14540
+ const data = needsGroup ? groupData(workbook, sheet, group) : groupData(workbook, sheet, { ...group, sparklines: [group.sparklines[index2]] });
14541
+ const at = needsGroup ? index2 : 0;
14542
+ return sparklineView(
14543
+ group,
14544
+ data[at] ?? { values: [] },
14545
+ sparklineScale(group, data, at),
14546
+ workbook.theme
14547
+ );
14548
+ }
14549
+
14334
14550
  // xlsx/edit/context.ts
14335
14551
  function sheetAt(workbook, index2) {
14336
14552
  const sheet = Number.isInteger(index2) ? workbook.sheets[index2] : void 0;
@@ -17047,6 +17263,7 @@ function sortRows2(sheet, range2, keys, hasHeader) {
17047
17263
  const sortKeys2 = keys.length ? keys : [{ col: r.start.col }];
17048
17264
  const rows2 = [];
17049
17265
  for (let row2 = firstRow; row2 <= lastRow; row2++) {
17266
+ if (sheet.rowInfo.get(row2)?.hidden) continue;
17050
17267
  const cells = /* @__PURE__ */ new Map();
17051
17268
  for (const [col, cell] of sheet.rows.get(row2) ?? [])
17052
17269
  if (col >= r.start.col && col <= r.end.col) cells.set(col, cell);
@@ -17064,9 +17281,9 @@ function sortRows2(sheet, range2, keys, hasHeader) {
17064
17281
  return 0;
17065
17282
  });
17066
17283
  for (const { row: row2, cells } of rows2) for (const col of cells.keys()) deleteCell(sheet, row2, col);
17067
- moveAnnotations(sheet, dataArea, new Map(sorted2.map((source, i2) => [source.row, firstRow + i2])));
17284
+ moveAnnotations(sheet, dataArea, new Map(sorted2.map((source, i2) => [source.row, rows2[i2].row])));
17068
17285
  sorted2.forEach((source, i2) => {
17069
- const row2 = firstRow + i2;
17286
+ const row2 = rows2[i2].row;
17070
17287
  const dRow = row2 - source.row;
17071
17288
  for (const [col, cell] of source.cells) {
17072
17289
  if (cell.formula !== void 0 && dRow) {
@@ -20572,222 +20789,6 @@ function bordersView(border, theme2) {
20572
20789
  return out;
20573
20790
  }
20574
20791
 
20575
- // xlsx/layout/sparkline-view.ts
20576
- var DEFAULTS = {
20577
- colorSeries: "#376092",
20578
- colorNegative: "#D00000",
20579
- colorAxis: "#000000",
20580
- colorMarkers: "#D00000",
20581
- colorFirst: "#D00000",
20582
- colorLast: "#D00000",
20583
- colorHigh: "#D00000",
20584
- colorLow: "#D00000"
20585
- };
20586
- var COLUMN_GAP = 0.2;
20587
- function extent(values2) {
20588
- let min = Infinity;
20589
- let max = -Infinity;
20590
- for (const v of values2) {
20591
- if (v === null) continue;
20592
- if (v < min) min = v;
20593
- if (v > max) max = v;
20594
- }
20595
- return min <= max ? { min, max } : void 0;
20596
- }
20597
- function sparklineValues(group, values2) {
20598
- return group.displayEmptyCellsAs === "zero" ? values2.map((v) => v ?? 0) : [...values2];
20599
- }
20600
- function sparklineScale(group, all2, index2) {
20601
- const own = extent(sparklineValues(group, all2[index2]?.values ?? []));
20602
- const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
20603
- const shared = needsGroup ? extent(all2.flatMap((data) => sparklineValues(group, data.values))) : void 0;
20604
- const end = (type, manual, key) => {
20605
- if (type === "custom" && manual !== void 0) return manual;
20606
- if (type === "group" && shared) return shared[key];
20607
- return own?.[key];
20608
- };
20609
- const min = end(group.minAxisType, group.manualMin, "min");
20610
- const max = end(group.maxAxisType, group.manualMax, "max");
20611
- return min === void 0 || max === void 0 ? void 0 : { min, max };
20612
- }
20613
- function positions(group, data, n) {
20614
- const dates = data.dates;
20615
- if (group.dateAxis && dates && dates.length === n) {
20616
- const span4 = extent(dates);
20617
- if (span4) {
20618
- const width = span4.max - span4.min;
20619
- return dates.map((d) => d === null ? null : width ? (d - span4.min) / width : 0.5);
20620
- }
20621
- }
20622
- return Array.from({ length: n }, (_, i2) => n === 1 ? 0.5 : i2 / (n - 1));
20623
- }
20624
- function pointFacts(values2) {
20625
- const numbers3 = values2.filter((x) => x !== null);
20626
- let last = values2.length - 1;
20627
- while (last >= 0 && values2[last] === null) last--;
20628
- return {
20629
- high: Math.max(...numbers3),
20630
- low: Math.min(...numbers3),
20631
- first: values2.findIndex((x) => x !== null),
20632
- last
20633
- };
20634
- }
20635
- function pointColor(group, v, i2, facts, colors, markers) {
20636
- let color = markers && group.markers ? colors.colorMarkers : void 0;
20637
- if (group.negative && v < 0) color = colors.colorNegative;
20638
- if (group.high && v === facts.high) color = colors.colorHigh;
20639
- if (group.low && v === facts.low) color = colors.colorLow;
20640
- if (group.first && i2 === facts.first) color = colors.colorFirst;
20641
- if (group.last && i2 === facts.last) color = colors.colorLast;
20642
- return color;
20643
- }
20644
- function resolveColors(group, theme2) {
20645
- const out = { ...DEFAULTS };
20646
- for (const key of Object.keys(DEFAULTS)) {
20647
- const color = group[key];
20648
- out[key] = resolveColor(color, theme2, DEFAULTS[key]) ?? DEFAULTS[key];
20649
- }
20650
- return out;
20651
- }
20652
- function sparklineView(group, data, scale2, theme2) {
20653
- const colors = resolveColors(group, theme2);
20654
- const view = {
20655
- type: group.type,
20656
- color: colors.colorSeries,
20657
- lineWeightPt: group.lineWeight,
20658
- lines: [],
20659
- markers: [],
20660
- columns: []
20661
- };
20662
- const values2 = sparklineValues(group, data.values);
20663
- const n = values2.length;
20664
- if (!n || !scale2) return view;
20665
- const facts = pointFacts(values2);
20666
- const xs = positions(group, data, n);
20667
- const flip = (x) => group.rightToLeft ? 1 - x : x;
20668
- const range2 = scale2.max - scale2.min;
20669
- const yOf = (v) => range2 ? Math.max(0, Math.min(1, (scale2.max - v) / range2)) : 0.5;
20670
- if (group.type === "line") {
20671
- let segment = [];
20672
- values2.forEach((v, i2) => {
20673
- const x = xs[i2];
20674
- if (v === null || x === null || x === void 0) {
20675
- if (group.displayEmptyCellsAs === "gap" && segment.length) {
20676
- view.lines.push(segment);
20677
- segment = [];
20678
- }
20679
- return;
20680
- }
20681
- const point = { x: flip(x), y: yOf(v) };
20682
- segment.push(point);
20683
- const color = pointColor(group, v, i2, facts, colors, true);
20684
- if (color) view.markers.push({ ...point, color });
20685
- });
20686
- if (segment.length) view.lines.push(segment);
20687
- } else {
20688
- const slot = 1 / n;
20689
- const w = slot * (1 - COLUMN_GAP);
20690
- const base = yOf(Math.max(scale2.min, Math.min(scale2.max, 0)));
20691
- values2.forEach((v, i2) => {
20692
- const position = xs[i2];
20693
- if (v === null || position === null || position === void 0) return;
20694
- if (v === 0) return;
20695
- let top;
20696
- let bottom;
20697
- if (group.type === "stacked") [top, bottom] = v > 0 ? [0, 0.5] : [0.5, 1];
20698
- else if (!range2) [top, bottom] = [0, 1];
20699
- else [top, bottom] = [Math.min(base, yOf(v)), Math.max(base, yOf(v))];
20700
- const centre = flip(slot / 2 + position * (1 - slot));
20701
- const color = pointColor(group, v, i2, facts, colors, false) ?? view.color;
20702
- view.columns.push({ x: centre - w / 2, y: top, w, h: bottom - top, color });
20703
- });
20704
- }
20705
- if (group.type === "stacked") {
20706
- if (group.displayXAxis) view.axis = { y: 0.5, color: colors.colorAxis };
20707
- } else if (group.displayXAxis && range2 && scale2.min <= 0 && scale2.max >= 0)
20708
- view.axis = { y: yOf(0), color: colors.colorAxis };
20709
- return view;
20710
- }
20711
-
20712
- // xlsx/layout/sparkline-data.ts
20713
- var MAX_POINTS = 1e4;
20714
- var hostIndex = /* @__PURE__ */ new WeakMap();
20715
- function hosts(sheet) {
20716
- const groups = sheetSparklineGroups(sheet);
20717
- let index2 = hostIndex.get(groups);
20718
- if (!index2) {
20719
- index2 = /* @__PURE__ */ new Map();
20720
- for (const group of groups)
20721
- group.sparklines.forEach((line2, i2) => {
20722
- const key = cellKey(line2.host.start.row, line2.host.start.col);
20723
- if (!index2.has(key)) index2.set(key, { group, index: i2 });
20724
- });
20725
- hostIndex.set(groups, index2);
20726
- }
20727
- return index2;
20728
- }
20729
- function hasSparklineAt(sheet, row2, col) {
20730
- return hosts(sheet).has(cellKey(row2, col));
20731
- }
20732
- function resolveSparklineRange(workbook, sheet, formula) {
20733
- const ref = formula.trim().replace(/^=/, "");
20734
- const bang = ref.lastIndexOf("!");
20735
- let target2 = sheet;
20736
- if (bang >= 0) {
20737
- const raw = ref.slice(0, bang);
20738
- const name = /^'.*'$/.test(raw) ? raw.slice(1, -1).replace(/''/g, "'") : raw;
20739
- target2 = sheetByName(workbook, name);
20740
- }
20741
- const range2 = parseRange(ref.slice(bang + 1).replace(/\$/g, ""));
20742
- return target2 && range2 ? { sheet: target2, range: normalizeRange(range2) } : void 0;
20743
- }
20744
- var rowHidden = (sheet, row2) => sheet.rowInfo.get(row2)?.hidden === true;
20745
- var colHidden = (sheet, col) => sheet.columns.some((c) => c.hidden === true && col >= c.min && col <= c.max);
20746
- function readSparklineValues(sheet, range2, displayHidden) {
20747
- let endRow = range2.end.row;
20748
- if (endRow - range2.start.row >= MAX_POINTS) {
20749
- let lastRow = range2.start.row;
20750
- for (const row2 of sheet.rows.keys()) if (row2 > lastRow) lastRow = row2;
20751
- endRow = Math.min(endRow, lastRow);
20752
- }
20753
- const out = [];
20754
- for (let row2 = range2.start.row; row2 <= endRow && out.length < MAX_POINTS; row2++) {
20755
- if (!displayHidden && rowHidden(sheet, row2)) continue;
20756
- for (let col = range2.start.col; col <= range2.end.col && out.length < MAX_POINTS; col++) {
20757
- if (!displayHidden && colHidden(sheet, col)) continue;
20758
- const value2 = getCell(sheet, row2, col)?.value;
20759
- out.push(typeof value2 === "number" && Number.isFinite(value2) ? value2 : null);
20760
- }
20761
- }
20762
- return out;
20763
- }
20764
- function groupData(workbook, sheet, group) {
20765
- const dateRange = group.dateAxis && group.dateFormula;
20766
- const dates = dateRange ? resolveSparklineRange(workbook, sheet, dateRange) : void 0;
20767
- const dateValues = dates ? readSparklineValues(dates.sheet, dates.range, group.displayHidden) : void 0;
20768
- return group.sparklines.map((line2) => {
20769
- const source = line2.formula ? resolveSparklineRange(workbook, sheet, line2.formula) : void 0;
20770
- const values2 = source ? readSparklineValues(source.sheet, source.range, group.displayHidden) : [];
20771
- return dateValues ? { values: values2, dates: dateValues } : { values: values2 };
20772
- });
20773
- }
20774
- function sparklineViewAt(workbook, sheetIndex2, row2, col) {
20775
- const sheet = workbook.sheets[sheetIndex2];
20776
- if (!sheet) return void 0;
20777
- const entry = hosts(sheet).get(cellKey(row2, col));
20778
- if (!entry) return void 0;
20779
- const { group, index: index2 } = entry;
20780
- const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
20781
- const data = needsGroup ? groupData(workbook, sheet, group) : groupData(workbook, sheet, { ...group, sparklines: [group.sparklines[index2]] });
20782
- const at = needsGroup ? index2 : 0;
20783
- return sparklineView(
20784
- group,
20785
- data[at] ?? { values: [] },
20786
- sparklineScale(group, data, at),
20787
- workbook.theme
20788
- );
20789
- }
20790
-
20791
20792
  // xlsx/layout/units.ts
20792
20793
  var DEFAULT_MAX_DIGIT_WIDTH = 7;
20793
20794
  var DEFAULT_BASE_COL_WIDTH = 8;
@@ -21358,13 +21359,14 @@ function duplicateSheet(ctx, index2) {
21358
21359
  delete next.partName;
21359
21360
  return next;
21360
21361
  });
21361
- if (renames.length)
21362
- rewriteSheetFormulas(
21363
- copy2,
21364
- (formula) => renames.reduce((f6, [from, to]) => renameTableInFormula(f6, from, to), formula)
21365
- );
21362
+ const rewrite = (formula) => renames.reduce(
21363
+ (f6, [from, to]) => renameTableInFormula(f6, from, to),
21364
+ renameSheetInFormula(formula, sheet.name, copy2.name)
21365
+ );
21366
+ rewriteSheetFormulas(copy2, rewrite);
21366
21367
  for (const drawing of copy2.drawings) if (drawing.kind === "chart") delete drawing.partName;
21367
21368
  const copiedNames = namesForCopy(workbook, index2, sheet.name, copy2.name);
21369
+ for (const name of copiedNames) name.formula = rewrite(name.formula);
21368
21370
  workbook.sheets.splice(at, 0, copy2);
21369
21371
  remapSheets(workbook, (i2) => i2 >= at ? i2 + 1 : i2);
21370
21372
  for (const n of copiedNames) workbook.definedNames.push({ ...n, localSheet: at });
@@ -0,0 +1,8 @@
1
+ import type { ChartObject, Workbook, Worksheet } from '../model.js';
2
+ /**
3
+ * A serialization-only chart with bounded local-range caches. Oversized or unresolvable
4
+ * references keep their imported caches; series names refresh only from single-cell ranges.
5
+ * Charts carried from the source package never use this helper.
6
+ */
7
+ export declare function chartWithCurrentCaches(workbook: Workbook, sheet: Worksheet, chart: ChartObject): ChartObject;
8
+ //# sourceMappingURL=chart-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-cache.d.ts","sourceRoot":"","sources":["../../../xlsx/write/chart-cache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAa,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAyC5E;;;;GAIG;AACH,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,WAAW,GAChB,WAAW,CAkBb"}
@@ -1 +1 @@
1
- {"version":3,"file":"sheet-parts.d.ts","sourceRoot":"","sources":["../../../xlsx/write/sheet-parts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAQpD,OAAO,EA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AC9B,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5B,uFAAuF;IACvF,aAAa,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;CACxB;AAED,wBAAgB,YAAY,CAC3B,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,GACd;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAQvC;AAED,wBAAgB,aAAa,CAC5B,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,eAAe,GACnB,MAAM,CAkER;AASD,wBAAgB,WAAW,CAC1B,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,eAAe,EACrB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,MAAM,CA+CR;AAED,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,eAAe,EACrB,aAAa,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,CA2BR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml-core",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "description": "Shared OOXML logic for the Word, PowerPoint and Excel viewers: everything except the UI",
5
5
  "keywords": [
6
6
  "charts",