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.
- package/dist/automation/index.cjs +7237 -7188
- package/dist/automation/index.mjs +7237 -7188
- package/dist/teams/index.cjs +79 -3
- package/dist/teams/index.mjs +79 -3
- package/dist/xlsx/edit/sheets.d.ts.map +1 -1
- package/dist/xlsx/edit/sort.d.ts +1 -1
- package/dist/xlsx/edit/sort.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +271 -224
- package/dist/xlsx/index.mjs +271 -224
- package/dist/xlsx/load/index.cjs +63 -1
- package/dist/xlsx/load/index.mjs +63 -1
- package/dist/xlsx/ui/index.cjs +225 -223
- package/dist/xlsx/ui/index.mjs +225 -223
- package/dist/xlsx/write/chart-cache.d.ts +8 -0
- package/dist/xlsx/write/chart-cache.d.ts.map +1 -0
- package/dist/xlsx/write/sheet-parts.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/xlsx/load/index.mjs
CHANGED
|
@@ -4145,6 +4145,7 @@ function formatRange(range) {
|
|
|
4145
4145
|
const a2 = formatAddress(start);
|
|
4146
4146
|
return start.row === end.row && start.col === end.col ? a2 : `${a2}:${formatAddress(end)}`;
|
|
4147
4147
|
}
|
|
4148
|
+
var rangeSize = (range) => (range.end.row - range.start.row + 1) * (range.end.col - range.start.col + 1);
|
|
4148
4149
|
var cellKey = (row2, col) => row2 * (MAX_COL + 1) + col;
|
|
4149
4150
|
function quoteSheetName(name) {
|
|
4150
4151
|
return /^[A-Za-z_][A-Za-z0-9_.]*$/.test(name) && !parseAddress(name) ? name : `'${name.replace(/'/g, "''")}'`;
|
|
@@ -4152,6 +4153,7 @@ function quoteSheetName(name) {
|
|
|
4152
4153
|
|
|
4153
4154
|
// xlsx/cells.ts
|
|
4154
4155
|
var getCell = (sheet, row2, col) => sheet.rows.get(row2)?.get(col);
|
|
4156
|
+
var getValue = (sheet, row2, col) => getCell(sheet, row2, col)?.value ?? null;
|
|
4155
4157
|
function usedRange(sheet) {
|
|
4156
4158
|
let minRow = Infinity;
|
|
4157
4159
|
let maxRow = -1;
|
|
@@ -5626,6 +5628,7 @@ function createWorkbook(options = {}) {
|
|
|
5626
5628
|
warnings: []
|
|
5627
5629
|
};
|
|
5628
5630
|
}
|
|
5631
|
+
var sheetByName = (workbook, name) => workbook.sheets.find((sheet) => sheet.name.toLowerCase() === name.toLowerCase());
|
|
5629
5632
|
var xChildren = (parent, local) => children(parent, local, NS.x);
|
|
5630
5633
|
var xFirst = (parent, local) => first(parent, local, NS.x);
|
|
5631
5634
|
var att = (element2, name) => {
|
|
@@ -22225,6 +22228,62 @@ function sheetDataXml(ctx, sheet) {
|
|
|
22225
22228
|
return out ? `<sheetData>${out}</sheetData>` : "<sheetData/>";
|
|
22226
22229
|
}
|
|
22227
22230
|
|
|
22231
|
+
// xlsx/layout/sparkline-data.ts
|
|
22232
|
+
function resolveSparklineRange(workbook, sheet, formula) {
|
|
22233
|
+
const ref = formula.trim().replace(/^=/, "");
|
|
22234
|
+
const bang = ref.lastIndexOf("!");
|
|
22235
|
+
let target = sheet;
|
|
22236
|
+
if (bang >= 0) {
|
|
22237
|
+
const raw2 = ref.slice(0, bang);
|
|
22238
|
+
const name = /^'.*'$/.test(raw2) ? raw2.slice(1, -1).replace(/''/g, "'") : raw2;
|
|
22239
|
+
target = sheetByName(workbook, name);
|
|
22240
|
+
}
|
|
22241
|
+
const range = parseRange(ref.slice(bang + 1).replace(/\$/g, ""));
|
|
22242
|
+
return target && range ? { sheet: target, range: normalizeRange(range) } : void 0;
|
|
22243
|
+
}
|
|
22244
|
+
|
|
22245
|
+
// xlsx/write/chart-cache.ts
|
|
22246
|
+
var MAX_CHART_CACHE_CELLS = 1e4;
|
|
22247
|
+
function referenceValues(workbook, sheet, ref, maxCells = MAX_CHART_CACHE_CELLS) {
|
|
22248
|
+
if (!ref) return void 0;
|
|
22249
|
+
const target = resolveSparklineRange(workbook, sheet, ref);
|
|
22250
|
+
if (!target) return void 0;
|
|
22251
|
+
const { range } = target;
|
|
22252
|
+
const count2 = rangeSize(range);
|
|
22253
|
+
if (!Number.isSafeInteger(count2) || count2 < 1 || count2 > maxCells || range.end.row > MAX_ROW || range.end.col > MAX_COL)
|
|
22254
|
+
return void 0;
|
|
22255
|
+
const values2 = [];
|
|
22256
|
+
for (let row2 = range.start.row; row2 <= range.end.row; row2++)
|
|
22257
|
+
for (let col = range.start.col; col <= range.end.col; col++)
|
|
22258
|
+
values2.push(getValue(target.sheet, row2, col));
|
|
22259
|
+
return values2;
|
|
22260
|
+
}
|
|
22261
|
+
function categoryValue(value) {
|
|
22262
|
+
if (value === null) return "";
|
|
22263
|
+
if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
|
|
22264
|
+
if (typeof value === "object") return value.error;
|
|
22265
|
+
if (typeof value === "number" && !Number.isFinite(value)) return "";
|
|
22266
|
+
return value;
|
|
22267
|
+
}
|
|
22268
|
+
function chartWithCurrentCaches(workbook, sheet, chart) {
|
|
22269
|
+
return {
|
|
22270
|
+
...chart,
|
|
22271
|
+
series: chart.series.map((series) => {
|
|
22272
|
+
const values2 = referenceValues(workbook, sheet, series.valuesRef);
|
|
22273
|
+
const categories = referenceValues(workbook, sheet, series.categoriesRef);
|
|
22274
|
+
const name = referenceValues(workbook, sheet, series.nameRef, 1);
|
|
22275
|
+
return {
|
|
22276
|
+
...series,
|
|
22277
|
+
...name === void 0 ? {} : { name: String(categoryValue(name[0] ?? null)) },
|
|
22278
|
+
values: values2?.map(
|
|
22279
|
+
(value) => typeof value === "number" && Number.isFinite(value) ? value : null
|
|
22280
|
+
) ?? series.values,
|
|
22281
|
+
categories: categories?.map(categoryValue) ?? series.categories
|
|
22282
|
+
};
|
|
22283
|
+
})
|
|
22284
|
+
};
|
|
22285
|
+
}
|
|
22286
|
+
|
|
22228
22287
|
// xlsx/write/vml-ids.ts
|
|
22229
22288
|
var IDS_PER_BLOCK = 1024;
|
|
22230
22289
|
function vmlIdmapBlocks(xml) {
|
|
@@ -22693,7 +22752,10 @@ function writeSheetDrawing(ctx, sheet, partName, rels, sourceDrawing) {
|
|
|
22693
22752
|
}
|
|
22694
22753
|
}
|
|
22695
22754
|
const target = sourceDrawing && !writer.has(sourceDrawing) ? sourceDrawing : writer.uniqueName((n) => `xl/drawings/drawing${n}.xml`, ctx.reserved);
|
|
22696
|
-
|
|
22755
|
+
const drawings = sheet.drawings.map(
|
|
22756
|
+
(object) => object.kind === "chart" && (!object.partName || !source2?.has(object.partName)) ? chartWithCurrentCaches(ctx.workbook, sheet, object) : object
|
|
22757
|
+
);
|
|
22758
|
+
if (!writeDrawing(writer, target, drawings, sourceDrawing)) return "";
|
|
22697
22759
|
return `<drawing r:id="${rels.add(RELATIONSHIP_TYPES.drawing, relativeTarget(partName, target))}"/>`;
|
|
22698
22760
|
}
|
|
22699
22761
|
|
package/dist/xlsx/ui/index.cjs
CHANGED
|
@@ -14333,6 +14333,222 @@ function shiftFormulaInBand(formula, formulaSheet, sheet, shift2, band) {
|
|
|
14333
14333
|
return changed ? tokens.map((t) => t.text).join("") : formula;
|
|
14334
14334
|
}
|
|
14335
14335
|
|
|
14336
|
+
// xlsx/layout/sparkline-view.ts
|
|
14337
|
+
var DEFAULTS = {
|
|
14338
|
+
colorSeries: "#376092",
|
|
14339
|
+
colorNegative: "#D00000",
|
|
14340
|
+
colorAxis: "#000000",
|
|
14341
|
+
colorMarkers: "#D00000",
|
|
14342
|
+
colorFirst: "#D00000",
|
|
14343
|
+
colorLast: "#D00000",
|
|
14344
|
+
colorHigh: "#D00000",
|
|
14345
|
+
colorLow: "#D00000"
|
|
14346
|
+
};
|
|
14347
|
+
var COLUMN_GAP = 0.2;
|
|
14348
|
+
function extent(values2) {
|
|
14349
|
+
let min = Infinity;
|
|
14350
|
+
let max = -Infinity;
|
|
14351
|
+
for (const v of values2) {
|
|
14352
|
+
if (v === null) continue;
|
|
14353
|
+
if (v < min) min = v;
|
|
14354
|
+
if (v > max) max = v;
|
|
14355
|
+
}
|
|
14356
|
+
return min <= max ? { min, max } : void 0;
|
|
14357
|
+
}
|
|
14358
|
+
function sparklineValues(group, values2) {
|
|
14359
|
+
return group.displayEmptyCellsAs === "zero" ? values2.map((v) => v ?? 0) : [...values2];
|
|
14360
|
+
}
|
|
14361
|
+
function sparklineScale(group, all2, index2) {
|
|
14362
|
+
const own = extent(sparklineValues(group, all2[index2]?.values ?? []));
|
|
14363
|
+
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
14364
|
+
const shared = needsGroup ? extent(all2.flatMap((data) => sparklineValues(group, data.values))) : void 0;
|
|
14365
|
+
const end = (type, manual, key) => {
|
|
14366
|
+
if (type === "custom" && manual !== void 0) return manual;
|
|
14367
|
+
if (type === "group" && shared) return shared[key];
|
|
14368
|
+
return own?.[key];
|
|
14369
|
+
};
|
|
14370
|
+
const min = end(group.minAxisType, group.manualMin, "min");
|
|
14371
|
+
const max = end(group.maxAxisType, group.manualMax, "max");
|
|
14372
|
+
return min === void 0 || max === void 0 ? void 0 : { min, max };
|
|
14373
|
+
}
|
|
14374
|
+
function positions(group, data, n) {
|
|
14375
|
+
const dates = data.dates;
|
|
14376
|
+
if (group.dateAxis && dates && dates.length === n) {
|
|
14377
|
+
const span4 = extent(dates);
|
|
14378
|
+
if (span4) {
|
|
14379
|
+
const width = span4.max - span4.min;
|
|
14380
|
+
return dates.map((d) => d === null ? null : width ? (d - span4.min) / width : 0.5);
|
|
14381
|
+
}
|
|
14382
|
+
}
|
|
14383
|
+
return Array.from({ length: n }, (_, i2) => n === 1 ? 0.5 : i2 / (n - 1));
|
|
14384
|
+
}
|
|
14385
|
+
function pointFacts(values2) {
|
|
14386
|
+
const numbers3 = values2.filter((x) => x !== null);
|
|
14387
|
+
let last = values2.length - 1;
|
|
14388
|
+
while (last >= 0 && values2[last] === null) last--;
|
|
14389
|
+
return {
|
|
14390
|
+
high: Math.max(...numbers3),
|
|
14391
|
+
low: Math.min(...numbers3),
|
|
14392
|
+
first: values2.findIndex((x) => x !== null),
|
|
14393
|
+
last
|
|
14394
|
+
};
|
|
14395
|
+
}
|
|
14396
|
+
function pointColor(group, v, i2, facts, colors, markers) {
|
|
14397
|
+
let color = markers && group.markers ? colors.colorMarkers : void 0;
|
|
14398
|
+
if (group.negative && v < 0) color = colors.colorNegative;
|
|
14399
|
+
if (group.high && v === facts.high) color = colors.colorHigh;
|
|
14400
|
+
if (group.low && v === facts.low) color = colors.colorLow;
|
|
14401
|
+
if (group.first && i2 === facts.first) color = colors.colorFirst;
|
|
14402
|
+
if (group.last && i2 === facts.last) color = colors.colorLast;
|
|
14403
|
+
return color;
|
|
14404
|
+
}
|
|
14405
|
+
function resolveColors(group, theme2) {
|
|
14406
|
+
const out = { ...DEFAULTS };
|
|
14407
|
+
for (const key of Object.keys(DEFAULTS)) {
|
|
14408
|
+
const color = group[key];
|
|
14409
|
+
out[key] = resolveColor(color, theme2, DEFAULTS[key]) ?? DEFAULTS[key];
|
|
14410
|
+
}
|
|
14411
|
+
return out;
|
|
14412
|
+
}
|
|
14413
|
+
function sparklineView(group, data, scale2, theme2) {
|
|
14414
|
+
const colors = resolveColors(group, theme2);
|
|
14415
|
+
const view = {
|
|
14416
|
+
type: group.type,
|
|
14417
|
+
color: colors.colorSeries,
|
|
14418
|
+
lineWeightPt: group.lineWeight,
|
|
14419
|
+
lines: [],
|
|
14420
|
+
markers: [],
|
|
14421
|
+
columns: []
|
|
14422
|
+
};
|
|
14423
|
+
const values2 = sparklineValues(group, data.values);
|
|
14424
|
+
const n = values2.length;
|
|
14425
|
+
if (!n || !scale2) return view;
|
|
14426
|
+
const facts = pointFacts(values2);
|
|
14427
|
+
const xs = positions(group, data, n);
|
|
14428
|
+
const flip = (x) => group.rightToLeft ? 1 - x : x;
|
|
14429
|
+
const range2 = scale2.max - scale2.min;
|
|
14430
|
+
const yOf = (v) => range2 ? Math.max(0, Math.min(1, (scale2.max - v) / range2)) : 0.5;
|
|
14431
|
+
if (group.type === "line") {
|
|
14432
|
+
let segment = [];
|
|
14433
|
+
values2.forEach((v, i2) => {
|
|
14434
|
+
const x = xs[i2];
|
|
14435
|
+
if (v === null || x === null || x === void 0) {
|
|
14436
|
+
if (group.displayEmptyCellsAs === "gap" && segment.length) {
|
|
14437
|
+
view.lines.push(segment);
|
|
14438
|
+
segment = [];
|
|
14439
|
+
}
|
|
14440
|
+
return;
|
|
14441
|
+
}
|
|
14442
|
+
const point = { x: flip(x), y: yOf(v) };
|
|
14443
|
+
segment.push(point);
|
|
14444
|
+
const color = pointColor(group, v, i2, facts, colors, true);
|
|
14445
|
+
if (color) view.markers.push({ ...point, color });
|
|
14446
|
+
});
|
|
14447
|
+
if (segment.length) view.lines.push(segment);
|
|
14448
|
+
} else {
|
|
14449
|
+
const slot = 1 / n;
|
|
14450
|
+
const w = slot * (1 - COLUMN_GAP);
|
|
14451
|
+
const base = yOf(Math.max(scale2.min, Math.min(scale2.max, 0)));
|
|
14452
|
+
values2.forEach((v, i2) => {
|
|
14453
|
+
const position = xs[i2];
|
|
14454
|
+
if (v === null || position === null || position === void 0) return;
|
|
14455
|
+
if (v === 0) return;
|
|
14456
|
+
let top;
|
|
14457
|
+
let bottom;
|
|
14458
|
+
if (group.type === "stacked") [top, bottom] = v > 0 ? [0, 0.5] : [0.5, 1];
|
|
14459
|
+
else if (!range2) [top, bottom] = [0, 1];
|
|
14460
|
+
else [top, bottom] = [Math.min(base, yOf(v)), Math.max(base, yOf(v))];
|
|
14461
|
+
const centre = flip(slot / 2 + position * (1 - slot));
|
|
14462
|
+
const color = pointColor(group, v, i2, facts, colors, false) ?? view.color;
|
|
14463
|
+
view.columns.push({ x: centre - w / 2, y: top, w, h: bottom - top, color });
|
|
14464
|
+
});
|
|
14465
|
+
}
|
|
14466
|
+
if (group.type === "stacked") {
|
|
14467
|
+
if (group.displayXAxis) view.axis = { y: 0.5, color: colors.colorAxis };
|
|
14468
|
+
} else if (group.displayXAxis && range2 && scale2.min <= 0 && scale2.max >= 0)
|
|
14469
|
+
view.axis = { y: yOf(0), color: colors.colorAxis };
|
|
14470
|
+
return view;
|
|
14471
|
+
}
|
|
14472
|
+
|
|
14473
|
+
// xlsx/layout/sparkline-data.ts
|
|
14474
|
+
var MAX_POINTS = 1e4;
|
|
14475
|
+
var hostIndex = /* @__PURE__ */ new WeakMap();
|
|
14476
|
+
function hosts(sheet) {
|
|
14477
|
+
const groups = sheetSparklineGroups(sheet);
|
|
14478
|
+
let index2 = hostIndex.get(groups);
|
|
14479
|
+
if (!index2) {
|
|
14480
|
+
index2 = /* @__PURE__ */ new Map();
|
|
14481
|
+
for (const group of groups)
|
|
14482
|
+
group.sparklines.forEach((line2, i2) => {
|
|
14483
|
+
const key = cellKey(line2.host.start.row, line2.host.start.col);
|
|
14484
|
+
if (!index2.has(key)) index2.set(key, { group, index: i2 });
|
|
14485
|
+
});
|
|
14486
|
+
hostIndex.set(groups, index2);
|
|
14487
|
+
}
|
|
14488
|
+
return index2;
|
|
14489
|
+
}
|
|
14490
|
+
function hasSparklineAt(sheet, row2, col) {
|
|
14491
|
+
return hosts(sheet).has(cellKey(row2, col));
|
|
14492
|
+
}
|
|
14493
|
+
function resolveSparklineRange(workbook, sheet, formula) {
|
|
14494
|
+
const ref = formula.trim().replace(/^=/, "");
|
|
14495
|
+
const bang = ref.lastIndexOf("!");
|
|
14496
|
+
let target2 = sheet;
|
|
14497
|
+
if (bang >= 0) {
|
|
14498
|
+
const raw = ref.slice(0, bang);
|
|
14499
|
+
const name = /^'.*'$/.test(raw) ? raw.slice(1, -1).replace(/''/g, "'") : raw;
|
|
14500
|
+
target2 = sheetByName(workbook, name);
|
|
14501
|
+
}
|
|
14502
|
+
const range2 = parseRange(ref.slice(bang + 1).replace(/\$/g, ""));
|
|
14503
|
+
return target2 && range2 ? { sheet: target2, range: normalizeRange(range2) } : void 0;
|
|
14504
|
+
}
|
|
14505
|
+
var rowHidden = (sheet, row2) => sheet.rowInfo.get(row2)?.hidden === true;
|
|
14506
|
+
var colHidden = (sheet, col) => sheet.columns.some((c) => c.hidden === true && col >= c.min && col <= c.max);
|
|
14507
|
+
function readSparklineValues(sheet, range2, displayHidden) {
|
|
14508
|
+
let endRow = range2.end.row;
|
|
14509
|
+
if (endRow - range2.start.row >= MAX_POINTS) {
|
|
14510
|
+
let lastRow = range2.start.row;
|
|
14511
|
+
for (const row2 of sheet.rows.keys()) if (row2 > lastRow) lastRow = row2;
|
|
14512
|
+
endRow = Math.min(endRow, lastRow);
|
|
14513
|
+
}
|
|
14514
|
+
const out = [];
|
|
14515
|
+
for (let row2 = range2.start.row; row2 <= endRow && out.length < MAX_POINTS; row2++) {
|
|
14516
|
+
if (!displayHidden && rowHidden(sheet, row2)) continue;
|
|
14517
|
+
for (let col = range2.start.col; col <= range2.end.col && out.length < MAX_POINTS; col++) {
|
|
14518
|
+
if (!displayHidden && colHidden(sheet, col)) continue;
|
|
14519
|
+
const value2 = getCell(sheet, row2, col)?.value;
|
|
14520
|
+
out.push(typeof value2 === "number" && Number.isFinite(value2) ? value2 : null);
|
|
14521
|
+
}
|
|
14522
|
+
}
|
|
14523
|
+
return out;
|
|
14524
|
+
}
|
|
14525
|
+
function groupData(workbook, sheet, group) {
|
|
14526
|
+
const dateRange = group.dateAxis && group.dateFormula;
|
|
14527
|
+
const dates = dateRange ? resolveSparklineRange(workbook, sheet, dateRange) : void 0;
|
|
14528
|
+
const dateValues = dates ? readSparklineValues(dates.sheet, dates.range, group.displayHidden) : void 0;
|
|
14529
|
+
return group.sparklines.map((line2) => {
|
|
14530
|
+
const source = line2.formula ? resolveSparklineRange(workbook, sheet, line2.formula) : void 0;
|
|
14531
|
+
const values2 = source ? readSparklineValues(source.sheet, source.range, group.displayHidden) : [];
|
|
14532
|
+
return dateValues ? { values: values2, dates: dateValues } : { values: values2 };
|
|
14533
|
+
});
|
|
14534
|
+
}
|
|
14535
|
+
function sparklineViewAt(workbook, sheetIndex2, row2, col) {
|
|
14536
|
+
const sheet = workbook.sheets[sheetIndex2];
|
|
14537
|
+
if (!sheet) return void 0;
|
|
14538
|
+
const entry = hosts(sheet).get(cellKey(row2, col));
|
|
14539
|
+
if (!entry) return void 0;
|
|
14540
|
+
const { group, index: index2 } = entry;
|
|
14541
|
+
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
14542
|
+
const data = needsGroup ? groupData(workbook, sheet, group) : groupData(workbook, sheet, { ...group, sparklines: [group.sparklines[index2]] });
|
|
14543
|
+
const at = needsGroup ? index2 : 0;
|
|
14544
|
+
return sparklineView(
|
|
14545
|
+
group,
|
|
14546
|
+
data[at] ?? { values: [] },
|
|
14547
|
+
sparklineScale(group, data, at),
|
|
14548
|
+
workbook.theme
|
|
14549
|
+
);
|
|
14550
|
+
}
|
|
14551
|
+
|
|
14336
14552
|
// xlsx/edit/context.ts
|
|
14337
14553
|
function sheetAt(workbook, index2) {
|
|
14338
14554
|
const sheet = Number.isInteger(index2) ? workbook.sheets[index2] : void 0;
|
|
@@ -17049,6 +17265,7 @@ function sortRows2(sheet, range2, keys, hasHeader) {
|
|
|
17049
17265
|
const sortKeys2 = keys.length ? keys : [{ col: r.start.col }];
|
|
17050
17266
|
const rows2 = [];
|
|
17051
17267
|
for (let row2 = firstRow; row2 <= lastRow; row2++) {
|
|
17268
|
+
if (sheet.rowInfo.get(row2)?.hidden) continue;
|
|
17052
17269
|
const cells = /* @__PURE__ */ new Map();
|
|
17053
17270
|
for (const [col, cell] of sheet.rows.get(row2) ?? [])
|
|
17054
17271
|
if (col >= r.start.col && col <= r.end.col) cells.set(col, cell);
|
|
@@ -17066,9 +17283,9 @@ function sortRows2(sheet, range2, keys, hasHeader) {
|
|
|
17066
17283
|
return 0;
|
|
17067
17284
|
});
|
|
17068
17285
|
for (const { row: row2, cells } of rows2) for (const col of cells.keys()) deleteCell(sheet, row2, col);
|
|
17069
|
-
moveAnnotations(sheet, dataArea, new Map(sorted2.map((source, i2) => [source.row,
|
|
17286
|
+
moveAnnotations(sheet, dataArea, new Map(sorted2.map((source, i2) => [source.row, rows2[i2].row])));
|
|
17070
17287
|
sorted2.forEach((source, i2) => {
|
|
17071
|
-
const row2 =
|
|
17288
|
+
const row2 = rows2[i2].row;
|
|
17072
17289
|
const dRow = row2 - source.row;
|
|
17073
17290
|
for (const [col, cell] of source.cells) {
|
|
17074
17291
|
if (cell.formula !== void 0 && dRow) {
|
|
@@ -20574,222 +20791,6 @@ function bordersView(border, theme2) {
|
|
|
20574
20791
|
return out;
|
|
20575
20792
|
}
|
|
20576
20793
|
|
|
20577
|
-
// xlsx/layout/sparkline-view.ts
|
|
20578
|
-
var DEFAULTS = {
|
|
20579
|
-
colorSeries: "#376092",
|
|
20580
|
-
colorNegative: "#D00000",
|
|
20581
|
-
colorAxis: "#000000",
|
|
20582
|
-
colorMarkers: "#D00000",
|
|
20583
|
-
colorFirst: "#D00000",
|
|
20584
|
-
colorLast: "#D00000",
|
|
20585
|
-
colorHigh: "#D00000",
|
|
20586
|
-
colorLow: "#D00000"
|
|
20587
|
-
};
|
|
20588
|
-
var COLUMN_GAP = 0.2;
|
|
20589
|
-
function extent(values2) {
|
|
20590
|
-
let min = Infinity;
|
|
20591
|
-
let max = -Infinity;
|
|
20592
|
-
for (const v of values2) {
|
|
20593
|
-
if (v === null) continue;
|
|
20594
|
-
if (v < min) min = v;
|
|
20595
|
-
if (v > max) max = v;
|
|
20596
|
-
}
|
|
20597
|
-
return min <= max ? { min, max } : void 0;
|
|
20598
|
-
}
|
|
20599
|
-
function sparklineValues(group, values2) {
|
|
20600
|
-
return group.displayEmptyCellsAs === "zero" ? values2.map((v) => v ?? 0) : [...values2];
|
|
20601
|
-
}
|
|
20602
|
-
function sparklineScale(group, all2, index2) {
|
|
20603
|
-
const own = extent(sparklineValues(group, all2[index2]?.values ?? []));
|
|
20604
|
-
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
20605
|
-
const shared = needsGroup ? extent(all2.flatMap((data) => sparklineValues(group, data.values))) : void 0;
|
|
20606
|
-
const end = (type, manual, key) => {
|
|
20607
|
-
if (type === "custom" && manual !== void 0) return manual;
|
|
20608
|
-
if (type === "group" && shared) return shared[key];
|
|
20609
|
-
return own?.[key];
|
|
20610
|
-
};
|
|
20611
|
-
const min = end(group.minAxisType, group.manualMin, "min");
|
|
20612
|
-
const max = end(group.maxAxisType, group.manualMax, "max");
|
|
20613
|
-
return min === void 0 || max === void 0 ? void 0 : { min, max };
|
|
20614
|
-
}
|
|
20615
|
-
function positions(group, data, n) {
|
|
20616
|
-
const dates = data.dates;
|
|
20617
|
-
if (group.dateAxis && dates && dates.length === n) {
|
|
20618
|
-
const span4 = extent(dates);
|
|
20619
|
-
if (span4) {
|
|
20620
|
-
const width = span4.max - span4.min;
|
|
20621
|
-
return dates.map((d) => d === null ? null : width ? (d - span4.min) / width : 0.5);
|
|
20622
|
-
}
|
|
20623
|
-
}
|
|
20624
|
-
return Array.from({ length: n }, (_, i2) => n === 1 ? 0.5 : i2 / (n - 1));
|
|
20625
|
-
}
|
|
20626
|
-
function pointFacts(values2) {
|
|
20627
|
-
const numbers3 = values2.filter((x) => x !== null);
|
|
20628
|
-
let last = values2.length - 1;
|
|
20629
|
-
while (last >= 0 && values2[last] === null) last--;
|
|
20630
|
-
return {
|
|
20631
|
-
high: Math.max(...numbers3),
|
|
20632
|
-
low: Math.min(...numbers3),
|
|
20633
|
-
first: values2.findIndex((x) => x !== null),
|
|
20634
|
-
last
|
|
20635
|
-
};
|
|
20636
|
-
}
|
|
20637
|
-
function pointColor(group, v, i2, facts, colors, markers) {
|
|
20638
|
-
let color = markers && group.markers ? colors.colorMarkers : void 0;
|
|
20639
|
-
if (group.negative && v < 0) color = colors.colorNegative;
|
|
20640
|
-
if (group.high && v === facts.high) color = colors.colorHigh;
|
|
20641
|
-
if (group.low && v === facts.low) color = colors.colorLow;
|
|
20642
|
-
if (group.first && i2 === facts.first) color = colors.colorFirst;
|
|
20643
|
-
if (group.last && i2 === facts.last) color = colors.colorLast;
|
|
20644
|
-
return color;
|
|
20645
|
-
}
|
|
20646
|
-
function resolveColors(group, theme2) {
|
|
20647
|
-
const out = { ...DEFAULTS };
|
|
20648
|
-
for (const key of Object.keys(DEFAULTS)) {
|
|
20649
|
-
const color = group[key];
|
|
20650
|
-
out[key] = resolveColor(color, theme2, DEFAULTS[key]) ?? DEFAULTS[key];
|
|
20651
|
-
}
|
|
20652
|
-
return out;
|
|
20653
|
-
}
|
|
20654
|
-
function sparklineView(group, data, scale2, theme2) {
|
|
20655
|
-
const colors = resolveColors(group, theme2);
|
|
20656
|
-
const view = {
|
|
20657
|
-
type: group.type,
|
|
20658
|
-
color: colors.colorSeries,
|
|
20659
|
-
lineWeightPt: group.lineWeight,
|
|
20660
|
-
lines: [],
|
|
20661
|
-
markers: [],
|
|
20662
|
-
columns: []
|
|
20663
|
-
};
|
|
20664
|
-
const values2 = sparklineValues(group, data.values);
|
|
20665
|
-
const n = values2.length;
|
|
20666
|
-
if (!n || !scale2) return view;
|
|
20667
|
-
const facts = pointFacts(values2);
|
|
20668
|
-
const xs = positions(group, data, n);
|
|
20669
|
-
const flip = (x) => group.rightToLeft ? 1 - x : x;
|
|
20670
|
-
const range2 = scale2.max - scale2.min;
|
|
20671
|
-
const yOf = (v) => range2 ? Math.max(0, Math.min(1, (scale2.max - v) / range2)) : 0.5;
|
|
20672
|
-
if (group.type === "line") {
|
|
20673
|
-
let segment = [];
|
|
20674
|
-
values2.forEach((v, i2) => {
|
|
20675
|
-
const x = xs[i2];
|
|
20676
|
-
if (v === null || x === null || x === void 0) {
|
|
20677
|
-
if (group.displayEmptyCellsAs === "gap" && segment.length) {
|
|
20678
|
-
view.lines.push(segment);
|
|
20679
|
-
segment = [];
|
|
20680
|
-
}
|
|
20681
|
-
return;
|
|
20682
|
-
}
|
|
20683
|
-
const point = { x: flip(x), y: yOf(v) };
|
|
20684
|
-
segment.push(point);
|
|
20685
|
-
const color = pointColor(group, v, i2, facts, colors, true);
|
|
20686
|
-
if (color) view.markers.push({ ...point, color });
|
|
20687
|
-
});
|
|
20688
|
-
if (segment.length) view.lines.push(segment);
|
|
20689
|
-
} else {
|
|
20690
|
-
const slot = 1 / n;
|
|
20691
|
-
const w = slot * (1 - COLUMN_GAP);
|
|
20692
|
-
const base = yOf(Math.max(scale2.min, Math.min(scale2.max, 0)));
|
|
20693
|
-
values2.forEach((v, i2) => {
|
|
20694
|
-
const position = xs[i2];
|
|
20695
|
-
if (v === null || position === null || position === void 0) return;
|
|
20696
|
-
if (v === 0) return;
|
|
20697
|
-
let top;
|
|
20698
|
-
let bottom;
|
|
20699
|
-
if (group.type === "stacked") [top, bottom] = v > 0 ? [0, 0.5] : [0.5, 1];
|
|
20700
|
-
else if (!range2) [top, bottom] = [0, 1];
|
|
20701
|
-
else [top, bottom] = [Math.min(base, yOf(v)), Math.max(base, yOf(v))];
|
|
20702
|
-
const centre = flip(slot / 2 + position * (1 - slot));
|
|
20703
|
-
const color = pointColor(group, v, i2, facts, colors, false) ?? view.color;
|
|
20704
|
-
view.columns.push({ x: centre - w / 2, y: top, w, h: bottom - top, color });
|
|
20705
|
-
});
|
|
20706
|
-
}
|
|
20707
|
-
if (group.type === "stacked") {
|
|
20708
|
-
if (group.displayXAxis) view.axis = { y: 0.5, color: colors.colorAxis };
|
|
20709
|
-
} else if (group.displayXAxis && range2 && scale2.min <= 0 && scale2.max >= 0)
|
|
20710
|
-
view.axis = { y: yOf(0), color: colors.colorAxis };
|
|
20711
|
-
return view;
|
|
20712
|
-
}
|
|
20713
|
-
|
|
20714
|
-
// xlsx/layout/sparkline-data.ts
|
|
20715
|
-
var MAX_POINTS = 1e4;
|
|
20716
|
-
var hostIndex = /* @__PURE__ */ new WeakMap();
|
|
20717
|
-
function hosts(sheet) {
|
|
20718
|
-
const groups = sheetSparklineGroups(sheet);
|
|
20719
|
-
let index2 = hostIndex.get(groups);
|
|
20720
|
-
if (!index2) {
|
|
20721
|
-
index2 = /* @__PURE__ */ new Map();
|
|
20722
|
-
for (const group of groups)
|
|
20723
|
-
group.sparklines.forEach((line2, i2) => {
|
|
20724
|
-
const key = cellKey(line2.host.start.row, line2.host.start.col);
|
|
20725
|
-
if (!index2.has(key)) index2.set(key, { group, index: i2 });
|
|
20726
|
-
});
|
|
20727
|
-
hostIndex.set(groups, index2);
|
|
20728
|
-
}
|
|
20729
|
-
return index2;
|
|
20730
|
-
}
|
|
20731
|
-
function hasSparklineAt(sheet, row2, col) {
|
|
20732
|
-
return hosts(sheet).has(cellKey(row2, col));
|
|
20733
|
-
}
|
|
20734
|
-
function resolveSparklineRange(workbook, sheet, formula) {
|
|
20735
|
-
const ref = formula.trim().replace(/^=/, "");
|
|
20736
|
-
const bang = ref.lastIndexOf("!");
|
|
20737
|
-
let target2 = sheet;
|
|
20738
|
-
if (bang >= 0) {
|
|
20739
|
-
const raw = ref.slice(0, bang);
|
|
20740
|
-
const name = /^'.*'$/.test(raw) ? raw.slice(1, -1).replace(/''/g, "'") : raw;
|
|
20741
|
-
target2 = sheetByName(workbook, name);
|
|
20742
|
-
}
|
|
20743
|
-
const range2 = parseRange(ref.slice(bang + 1).replace(/\$/g, ""));
|
|
20744
|
-
return target2 && range2 ? { sheet: target2, range: normalizeRange(range2) } : void 0;
|
|
20745
|
-
}
|
|
20746
|
-
var rowHidden = (sheet, row2) => sheet.rowInfo.get(row2)?.hidden === true;
|
|
20747
|
-
var colHidden = (sheet, col) => sheet.columns.some((c) => c.hidden === true && col >= c.min && col <= c.max);
|
|
20748
|
-
function readSparklineValues(sheet, range2, displayHidden) {
|
|
20749
|
-
let endRow = range2.end.row;
|
|
20750
|
-
if (endRow - range2.start.row >= MAX_POINTS) {
|
|
20751
|
-
let lastRow = range2.start.row;
|
|
20752
|
-
for (const row2 of sheet.rows.keys()) if (row2 > lastRow) lastRow = row2;
|
|
20753
|
-
endRow = Math.min(endRow, lastRow);
|
|
20754
|
-
}
|
|
20755
|
-
const out = [];
|
|
20756
|
-
for (let row2 = range2.start.row; row2 <= endRow && out.length < MAX_POINTS; row2++) {
|
|
20757
|
-
if (!displayHidden && rowHidden(sheet, row2)) continue;
|
|
20758
|
-
for (let col = range2.start.col; col <= range2.end.col && out.length < MAX_POINTS; col++) {
|
|
20759
|
-
if (!displayHidden && colHidden(sheet, col)) continue;
|
|
20760
|
-
const value2 = getCell(sheet, row2, col)?.value;
|
|
20761
|
-
out.push(typeof value2 === "number" && Number.isFinite(value2) ? value2 : null);
|
|
20762
|
-
}
|
|
20763
|
-
}
|
|
20764
|
-
return out;
|
|
20765
|
-
}
|
|
20766
|
-
function groupData(workbook, sheet, group) {
|
|
20767
|
-
const dateRange = group.dateAxis && group.dateFormula;
|
|
20768
|
-
const dates = dateRange ? resolveSparklineRange(workbook, sheet, dateRange) : void 0;
|
|
20769
|
-
const dateValues = dates ? readSparklineValues(dates.sheet, dates.range, group.displayHidden) : void 0;
|
|
20770
|
-
return group.sparklines.map((line2) => {
|
|
20771
|
-
const source = line2.formula ? resolveSparklineRange(workbook, sheet, line2.formula) : void 0;
|
|
20772
|
-
const values2 = source ? readSparklineValues(source.sheet, source.range, group.displayHidden) : [];
|
|
20773
|
-
return dateValues ? { values: values2, dates: dateValues } : { values: values2 };
|
|
20774
|
-
});
|
|
20775
|
-
}
|
|
20776
|
-
function sparklineViewAt(workbook, sheetIndex2, row2, col) {
|
|
20777
|
-
const sheet = workbook.sheets[sheetIndex2];
|
|
20778
|
-
if (!sheet) return void 0;
|
|
20779
|
-
const entry = hosts(sheet).get(cellKey(row2, col));
|
|
20780
|
-
if (!entry) return void 0;
|
|
20781
|
-
const { group, index: index2 } = entry;
|
|
20782
|
-
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
20783
|
-
const data = needsGroup ? groupData(workbook, sheet, group) : groupData(workbook, sheet, { ...group, sparklines: [group.sparklines[index2]] });
|
|
20784
|
-
const at = needsGroup ? index2 : 0;
|
|
20785
|
-
return sparklineView(
|
|
20786
|
-
group,
|
|
20787
|
-
data[at] ?? { values: [] },
|
|
20788
|
-
sparklineScale(group, data, at),
|
|
20789
|
-
workbook.theme
|
|
20790
|
-
);
|
|
20791
|
-
}
|
|
20792
|
-
|
|
20793
20794
|
// xlsx/layout/units.ts
|
|
20794
20795
|
var DEFAULT_MAX_DIGIT_WIDTH = 7;
|
|
20795
20796
|
var DEFAULT_BASE_COL_WIDTH = 8;
|
|
@@ -21360,13 +21361,14 @@ function duplicateSheet(ctx, index2) {
|
|
|
21360
21361
|
delete next.partName;
|
|
21361
21362
|
return next;
|
|
21362
21363
|
});
|
|
21363
|
-
|
|
21364
|
-
|
|
21365
|
-
|
|
21366
|
-
|
|
21367
|
-
|
|
21364
|
+
const rewrite = (formula) => renames.reduce(
|
|
21365
|
+
(f6, [from, to]) => renameTableInFormula(f6, from, to),
|
|
21366
|
+
renameSheetInFormula(formula, sheet.name, copy2.name)
|
|
21367
|
+
);
|
|
21368
|
+
rewriteSheetFormulas(copy2, rewrite);
|
|
21368
21369
|
for (const drawing of copy2.drawings) if (drawing.kind === "chart") delete drawing.partName;
|
|
21369
21370
|
const copiedNames = namesForCopy(workbook, index2, sheet.name, copy2.name);
|
|
21371
|
+
for (const name of copiedNames) name.formula = rewrite(name.formula);
|
|
21370
21372
|
workbook.sheets.splice(at, 0, copy2);
|
|
21371
21373
|
remapSheets(workbook, (i2) => i2 >= at ? i2 + 1 : i2);
|
|
21372
21374
|
for (const n of copiedNames) workbook.definedNames.push({ ...n, localSheet: at });
|