ooxml-core 1.8.3 → 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 +7240 -7192
- package/dist/automation/index.mjs +7240 -7192
- 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/index.cjs +268 -222
- package/dist/xlsx/index.mjs +268 -222
- package/dist/xlsx/load/index.cjs +63 -1
- package/dist/xlsx/load/index.mjs +63 -1
- package/dist/xlsx/ui/index.cjs +222 -221
- package/dist/xlsx/ui/index.mjs +222 -221
- 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/index.cjs
CHANGED
|
@@ -23738,6 +23738,264 @@ function sheetDataXml(ctx, sheet) {
|
|
|
23738
23738
|
return out ? `<sheetData>${out}</sheetData>` : "<sheetData/>";
|
|
23739
23739
|
}
|
|
23740
23740
|
|
|
23741
|
+
// xlsx/layout/sparkline-view.ts
|
|
23742
|
+
var DEFAULTS = {
|
|
23743
|
+
colorSeries: "#376092",
|
|
23744
|
+
colorNegative: "#D00000",
|
|
23745
|
+
colorAxis: "#000000",
|
|
23746
|
+
colorMarkers: "#D00000",
|
|
23747
|
+
colorFirst: "#D00000",
|
|
23748
|
+
colorLast: "#D00000",
|
|
23749
|
+
colorHigh: "#D00000",
|
|
23750
|
+
colorLow: "#D00000"
|
|
23751
|
+
};
|
|
23752
|
+
var COLUMN_GAP = 0.2;
|
|
23753
|
+
function extent(values2) {
|
|
23754
|
+
let min = Infinity;
|
|
23755
|
+
let max = -Infinity;
|
|
23756
|
+
for (const v of values2) {
|
|
23757
|
+
if (v === null) continue;
|
|
23758
|
+
if (v < min) min = v;
|
|
23759
|
+
if (v > max) max = v;
|
|
23760
|
+
}
|
|
23761
|
+
return min <= max ? { min, max } : void 0;
|
|
23762
|
+
}
|
|
23763
|
+
function sparklineValues(group, values2) {
|
|
23764
|
+
return group.displayEmptyCellsAs === "zero" ? values2.map((v) => v ?? 0) : [...values2];
|
|
23765
|
+
}
|
|
23766
|
+
function sparklineScale(group, all2, index2) {
|
|
23767
|
+
const own = extent(sparklineValues(group, all2[index2]?.values ?? []));
|
|
23768
|
+
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
23769
|
+
const shared = needsGroup ? extent(all2.flatMap((data) => sparklineValues(group, data.values))) : void 0;
|
|
23770
|
+
const end = (type, manual, key) => {
|
|
23771
|
+
if (type === "custom" && manual !== void 0) return manual;
|
|
23772
|
+
if (type === "group" && shared) return shared[key];
|
|
23773
|
+
return own?.[key];
|
|
23774
|
+
};
|
|
23775
|
+
const min = end(group.minAxisType, group.manualMin, "min");
|
|
23776
|
+
const max = end(group.maxAxisType, group.manualMax, "max");
|
|
23777
|
+
return min === void 0 || max === void 0 ? void 0 : { min, max };
|
|
23778
|
+
}
|
|
23779
|
+
function positions(group, data, n2) {
|
|
23780
|
+
const dates = data.dates;
|
|
23781
|
+
if (group.dateAxis && dates && dates.length === n2) {
|
|
23782
|
+
const span3 = extent(dates);
|
|
23783
|
+
if (span3) {
|
|
23784
|
+
const width = span3.max - span3.min;
|
|
23785
|
+
return dates.map((d) => d === null ? null : width ? (d - span3.min) / width : 0.5);
|
|
23786
|
+
}
|
|
23787
|
+
}
|
|
23788
|
+
return Array.from({ length: n2 }, (_, i2) => n2 === 1 ? 0.5 : i2 / (n2 - 1));
|
|
23789
|
+
}
|
|
23790
|
+
function pointFacts(values2) {
|
|
23791
|
+
const numbers3 = values2.filter((x) => x !== null);
|
|
23792
|
+
let last = values2.length - 1;
|
|
23793
|
+
while (last >= 0 && values2[last] === null) last--;
|
|
23794
|
+
return {
|
|
23795
|
+
high: Math.max(...numbers3),
|
|
23796
|
+
low: Math.min(...numbers3),
|
|
23797
|
+
first: values2.findIndex((x) => x !== null),
|
|
23798
|
+
last
|
|
23799
|
+
};
|
|
23800
|
+
}
|
|
23801
|
+
function pointColor(group, v, i2, facts, colors, markers) {
|
|
23802
|
+
let color = markers && group.markers ? colors.colorMarkers : void 0;
|
|
23803
|
+
if (group.negative && v < 0) color = colors.colorNegative;
|
|
23804
|
+
if (group.high && v === facts.high) color = colors.colorHigh;
|
|
23805
|
+
if (group.low && v === facts.low) color = colors.colorLow;
|
|
23806
|
+
if (group.first && i2 === facts.first) color = colors.colorFirst;
|
|
23807
|
+
if (group.last && i2 === facts.last) color = colors.colorLast;
|
|
23808
|
+
return color;
|
|
23809
|
+
}
|
|
23810
|
+
function resolveColors(group, theme2) {
|
|
23811
|
+
const out = { ...DEFAULTS };
|
|
23812
|
+
for (const key of Object.keys(DEFAULTS)) {
|
|
23813
|
+
const color = group[key];
|
|
23814
|
+
out[key] = resolveColor(color, theme2, DEFAULTS[key]) ?? DEFAULTS[key];
|
|
23815
|
+
}
|
|
23816
|
+
return out;
|
|
23817
|
+
}
|
|
23818
|
+
function sparklineView(group, data, scale2, theme2) {
|
|
23819
|
+
const colors = resolveColors(group, theme2);
|
|
23820
|
+
const view = {
|
|
23821
|
+
type: group.type,
|
|
23822
|
+
color: colors.colorSeries,
|
|
23823
|
+
lineWeightPt: group.lineWeight,
|
|
23824
|
+
lines: [],
|
|
23825
|
+
markers: [],
|
|
23826
|
+
columns: []
|
|
23827
|
+
};
|
|
23828
|
+
const values2 = sparklineValues(group, data.values);
|
|
23829
|
+
const n2 = values2.length;
|
|
23830
|
+
if (!n2 || !scale2) return view;
|
|
23831
|
+
const facts = pointFacts(values2);
|
|
23832
|
+
const xs = positions(group, data, n2);
|
|
23833
|
+
const flip = (x) => group.rightToLeft ? 1 - x : x;
|
|
23834
|
+
const range = scale2.max - scale2.min;
|
|
23835
|
+
const yOf = (v) => range ? Math.max(0, Math.min(1, (scale2.max - v) / range)) : 0.5;
|
|
23836
|
+
if (group.type === "line") {
|
|
23837
|
+
let segment = [];
|
|
23838
|
+
values2.forEach((v, i2) => {
|
|
23839
|
+
const x = xs[i2];
|
|
23840
|
+
if (v === null || x === null || x === void 0) {
|
|
23841
|
+
if (group.displayEmptyCellsAs === "gap" && segment.length) {
|
|
23842
|
+
view.lines.push(segment);
|
|
23843
|
+
segment = [];
|
|
23844
|
+
}
|
|
23845
|
+
return;
|
|
23846
|
+
}
|
|
23847
|
+
const point = { x: flip(x), y: yOf(v) };
|
|
23848
|
+
segment.push(point);
|
|
23849
|
+
const color = pointColor(group, v, i2, facts, colors, true);
|
|
23850
|
+
if (color) view.markers.push({ ...point, color });
|
|
23851
|
+
});
|
|
23852
|
+
if (segment.length) view.lines.push(segment);
|
|
23853
|
+
} else {
|
|
23854
|
+
const slot2 = 1 / n2;
|
|
23855
|
+
const w = slot2 * (1 - COLUMN_GAP);
|
|
23856
|
+
const base = yOf(Math.max(scale2.min, Math.min(scale2.max, 0)));
|
|
23857
|
+
values2.forEach((v, i2) => {
|
|
23858
|
+
const position = xs[i2];
|
|
23859
|
+
if (v === null || position === null || position === void 0) return;
|
|
23860
|
+
if (v === 0) return;
|
|
23861
|
+
let top;
|
|
23862
|
+
let bottom;
|
|
23863
|
+
if (group.type === "stacked") [top, bottom] = v > 0 ? [0, 0.5] : [0.5, 1];
|
|
23864
|
+
else if (!range) [top, bottom] = [0, 1];
|
|
23865
|
+
else [top, bottom] = [Math.min(base, yOf(v)), Math.max(base, yOf(v))];
|
|
23866
|
+
const centre = flip(slot2 / 2 + position * (1 - slot2));
|
|
23867
|
+
const color = pointColor(group, v, i2, facts, colors, false) ?? view.color;
|
|
23868
|
+
view.columns.push({ x: centre - w / 2, y: top, w, h: bottom - top, color });
|
|
23869
|
+
});
|
|
23870
|
+
}
|
|
23871
|
+
if (group.type === "stacked") {
|
|
23872
|
+
if (group.displayXAxis) view.axis = { y: 0.5, color: colors.colorAxis };
|
|
23873
|
+
} else if (group.displayXAxis && range && scale2.min <= 0 && scale2.max >= 0)
|
|
23874
|
+
view.axis = { y: yOf(0), color: colors.colorAxis };
|
|
23875
|
+
return view;
|
|
23876
|
+
}
|
|
23877
|
+
|
|
23878
|
+
// xlsx/layout/sparkline-data.ts
|
|
23879
|
+
var MAX_POINTS = 1e4;
|
|
23880
|
+
var hostIndex = /* @__PURE__ */ new WeakMap();
|
|
23881
|
+
function hosts(sheet) {
|
|
23882
|
+
const groups = sheetSparklineGroups(sheet);
|
|
23883
|
+
let index2 = hostIndex.get(groups);
|
|
23884
|
+
if (!index2) {
|
|
23885
|
+
index2 = /* @__PURE__ */ new Map();
|
|
23886
|
+
for (const group of groups)
|
|
23887
|
+
group.sparklines.forEach((line3, i2) => {
|
|
23888
|
+
const key = cellKey(line3.host.start.row, line3.host.start.col);
|
|
23889
|
+
if (!index2.has(key)) index2.set(key, { group, index: i2 });
|
|
23890
|
+
});
|
|
23891
|
+
hostIndex.set(groups, index2);
|
|
23892
|
+
}
|
|
23893
|
+
return index2;
|
|
23894
|
+
}
|
|
23895
|
+
function hasSparklineAt(sheet, row2, col) {
|
|
23896
|
+
return hosts(sheet).has(cellKey(row2, col));
|
|
23897
|
+
}
|
|
23898
|
+
function resolveSparklineRange(workbook, sheet, formula) {
|
|
23899
|
+
const ref = formula.trim().replace(/^=/, "");
|
|
23900
|
+
const bang = ref.lastIndexOf("!");
|
|
23901
|
+
let target = sheet;
|
|
23902
|
+
if (bang >= 0) {
|
|
23903
|
+
const raw2 = ref.slice(0, bang);
|
|
23904
|
+
const name = /^'.*'$/.test(raw2) ? raw2.slice(1, -1).replace(/''/g, "'") : raw2;
|
|
23905
|
+
target = sheetByName(workbook, name);
|
|
23906
|
+
}
|
|
23907
|
+
const range = parseRange(ref.slice(bang + 1).replace(/\$/g, ""));
|
|
23908
|
+
return target && range ? { sheet: target, range: normalizeRange(range) } : void 0;
|
|
23909
|
+
}
|
|
23910
|
+
var rowHidden = (sheet, row2) => sheet.rowInfo.get(row2)?.hidden === true;
|
|
23911
|
+
var colHidden = (sheet, col) => sheet.columns.some((c2) => c2.hidden === true && col >= c2.min && col <= c2.max);
|
|
23912
|
+
function readSparklineValues(sheet, range, displayHidden) {
|
|
23913
|
+
let endRow = range.end.row;
|
|
23914
|
+
if (endRow - range.start.row >= MAX_POINTS) {
|
|
23915
|
+
let lastRow = range.start.row;
|
|
23916
|
+
for (const row2 of sheet.rows.keys()) if (row2 > lastRow) lastRow = row2;
|
|
23917
|
+
endRow = Math.min(endRow, lastRow);
|
|
23918
|
+
}
|
|
23919
|
+
const out = [];
|
|
23920
|
+
for (let row2 = range.start.row; row2 <= endRow && out.length < MAX_POINTS; row2++) {
|
|
23921
|
+
if (!displayHidden && rowHidden(sheet, row2)) continue;
|
|
23922
|
+
for (let col = range.start.col; col <= range.end.col && out.length < MAX_POINTS; col++) {
|
|
23923
|
+
if (!displayHidden && colHidden(sheet, col)) continue;
|
|
23924
|
+
const value = getCell(sheet, row2, col)?.value;
|
|
23925
|
+
out.push(typeof value === "number" && Number.isFinite(value) ? value : null);
|
|
23926
|
+
}
|
|
23927
|
+
}
|
|
23928
|
+
return out;
|
|
23929
|
+
}
|
|
23930
|
+
function groupData(workbook, sheet, group) {
|
|
23931
|
+
const dateRange = group.dateAxis && group.dateFormula;
|
|
23932
|
+
const dates = dateRange ? resolveSparklineRange(workbook, sheet, dateRange) : void 0;
|
|
23933
|
+
const dateValues = dates ? readSparklineValues(dates.sheet, dates.range, group.displayHidden) : void 0;
|
|
23934
|
+
return group.sparklines.map((line3) => {
|
|
23935
|
+
const source2 = line3.formula ? resolveSparklineRange(workbook, sheet, line3.formula) : void 0;
|
|
23936
|
+
const values2 = source2 ? readSparklineValues(source2.sheet, source2.range, group.displayHidden) : [];
|
|
23937
|
+
return dateValues ? { values: values2, dates: dateValues } : { values: values2 };
|
|
23938
|
+
});
|
|
23939
|
+
}
|
|
23940
|
+
function sparklineViewAt(workbook, sheetIndex2, row2, col) {
|
|
23941
|
+
const sheet = workbook.sheets[sheetIndex2];
|
|
23942
|
+
if (!sheet) return void 0;
|
|
23943
|
+
const entry3 = hosts(sheet).get(cellKey(row2, col));
|
|
23944
|
+
if (!entry3) return void 0;
|
|
23945
|
+
const { group, index: index2 } = entry3;
|
|
23946
|
+
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
23947
|
+
const data = needsGroup ? groupData(workbook, sheet, group) : groupData(workbook, sheet, { ...group, sparklines: [group.sparklines[index2]] });
|
|
23948
|
+
const at = needsGroup ? index2 : 0;
|
|
23949
|
+
return sparklineView(
|
|
23950
|
+
group,
|
|
23951
|
+
data[at] ?? { values: [] },
|
|
23952
|
+
sparklineScale(group, data, at),
|
|
23953
|
+
workbook.theme
|
|
23954
|
+
);
|
|
23955
|
+
}
|
|
23956
|
+
|
|
23957
|
+
// xlsx/write/chart-cache.ts
|
|
23958
|
+
var MAX_CHART_CACHE_CELLS = 1e4;
|
|
23959
|
+
function referenceValues(workbook, sheet, ref, maxCells = MAX_CHART_CACHE_CELLS) {
|
|
23960
|
+
if (!ref) return void 0;
|
|
23961
|
+
const target = resolveSparklineRange(workbook, sheet, ref);
|
|
23962
|
+
if (!target) return void 0;
|
|
23963
|
+
const { range } = target;
|
|
23964
|
+
const count2 = rangeSize(range);
|
|
23965
|
+
if (!Number.isSafeInteger(count2) || count2 < 1 || count2 > maxCells || range.end.row > MAX_ROW || range.end.col > MAX_COL)
|
|
23966
|
+
return void 0;
|
|
23967
|
+
const values2 = [];
|
|
23968
|
+
for (let row2 = range.start.row; row2 <= range.end.row; row2++)
|
|
23969
|
+
for (let col = range.start.col; col <= range.end.col; col++)
|
|
23970
|
+
values2.push(getValue(target.sheet, row2, col));
|
|
23971
|
+
return values2;
|
|
23972
|
+
}
|
|
23973
|
+
function categoryValue(value) {
|
|
23974
|
+
if (value === null) return "";
|
|
23975
|
+
if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
|
|
23976
|
+
if (typeof value === "object") return value.error;
|
|
23977
|
+
if (typeof value === "number" && !Number.isFinite(value)) return "";
|
|
23978
|
+
return value;
|
|
23979
|
+
}
|
|
23980
|
+
function chartWithCurrentCaches(workbook, sheet, chart) {
|
|
23981
|
+
return {
|
|
23982
|
+
...chart,
|
|
23983
|
+
series: chart.series.map((series) => {
|
|
23984
|
+
const values2 = referenceValues(workbook, sheet, series.valuesRef);
|
|
23985
|
+
const categories = referenceValues(workbook, sheet, series.categoriesRef);
|
|
23986
|
+
const name = referenceValues(workbook, sheet, series.nameRef, 1);
|
|
23987
|
+
return {
|
|
23988
|
+
...series,
|
|
23989
|
+
...name === void 0 ? {} : { name: String(categoryValue(name[0] ?? null)) },
|
|
23990
|
+
values: values2?.map(
|
|
23991
|
+
(value) => typeof value === "number" && Number.isFinite(value) ? value : null
|
|
23992
|
+
) ?? series.values,
|
|
23993
|
+
categories: categories?.map(categoryValue) ?? series.categories
|
|
23994
|
+
};
|
|
23995
|
+
})
|
|
23996
|
+
};
|
|
23997
|
+
}
|
|
23998
|
+
|
|
23741
23999
|
// xlsx/write/vml-ids.ts
|
|
23742
24000
|
var IDS_PER_BLOCK = 1024;
|
|
23743
24001
|
function vmlIdmapBlocks(xml) {
|
|
@@ -24206,7 +24464,10 @@ function writeSheetDrawing(ctx, sheet, partName, rels, sourceDrawing) {
|
|
|
24206
24464
|
}
|
|
24207
24465
|
}
|
|
24208
24466
|
const target = sourceDrawing && !writer.has(sourceDrawing) ? sourceDrawing : writer.uniqueName((n2) => `xl/drawings/drawing${n2}.xml`, ctx.reserved);
|
|
24209
|
-
|
|
24467
|
+
const drawings = sheet.drawings.map(
|
|
24468
|
+
(object) => object.kind === "chart" && (!object.partName || !source2?.has(object.partName)) ? chartWithCurrentCaches(ctx.workbook, sheet, object) : object
|
|
24469
|
+
);
|
|
24470
|
+
if (!writeDrawing(writer, target, drawings, sourceDrawing)) return "";
|
|
24210
24471
|
return `<drawing r:id="${rels.add(RELATIONSHIP_TYPES.drawing, relativeTarget(partName, target))}"/>`;
|
|
24211
24472
|
}
|
|
24212
24473
|
|
|
@@ -31175,222 +31436,6 @@ function bordersView(border, theme2) {
|
|
|
31175
31436
|
return out;
|
|
31176
31437
|
}
|
|
31177
31438
|
|
|
31178
|
-
// xlsx/layout/sparkline-view.ts
|
|
31179
|
-
var DEFAULTS = {
|
|
31180
|
-
colorSeries: "#376092",
|
|
31181
|
-
colorNegative: "#D00000",
|
|
31182
|
-
colorAxis: "#000000",
|
|
31183
|
-
colorMarkers: "#D00000",
|
|
31184
|
-
colorFirst: "#D00000",
|
|
31185
|
-
colorLast: "#D00000",
|
|
31186
|
-
colorHigh: "#D00000",
|
|
31187
|
-
colorLow: "#D00000"
|
|
31188
|
-
};
|
|
31189
|
-
var COLUMN_GAP = 0.2;
|
|
31190
|
-
function extent(values2) {
|
|
31191
|
-
let min = Infinity;
|
|
31192
|
-
let max = -Infinity;
|
|
31193
|
-
for (const v of values2) {
|
|
31194
|
-
if (v === null) continue;
|
|
31195
|
-
if (v < min) min = v;
|
|
31196
|
-
if (v > max) max = v;
|
|
31197
|
-
}
|
|
31198
|
-
return min <= max ? { min, max } : void 0;
|
|
31199
|
-
}
|
|
31200
|
-
function sparklineValues(group, values2) {
|
|
31201
|
-
return group.displayEmptyCellsAs === "zero" ? values2.map((v) => v ?? 0) : [...values2];
|
|
31202
|
-
}
|
|
31203
|
-
function sparklineScale(group, all2, index2) {
|
|
31204
|
-
const own = extent(sparklineValues(group, all2[index2]?.values ?? []));
|
|
31205
|
-
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
31206
|
-
const shared = needsGroup ? extent(all2.flatMap((data) => sparklineValues(group, data.values))) : void 0;
|
|
31207
|
-
const end = (type, manual, key) => {
|
|
31208
|
-
if (type === "custom" && manual !== void 0) return manual;
|
|
31209
|
-
if (type === "group" && shared) return shared[key];
|
|
31210
|
-
return own?.[key];
|
|
31211
|
-
};
|
|
31212
|
-
const min = end(group.minAxisType, group.manualMin, "min");
|
|
31213
|
-
const max = end(group.maxAxisType, group.manualMax, "max");
|
|
31214
|
-
return min === void 0 || max === void 0 ? void 0 : { min, max };
|
|
31215
|
-
}
|
|
31216
|
-
function positions(group, data, n2) {
|
|
31217
|
-
const dates = data.dates;
|
|
31218
|
-
if (group.dateAxis && dates && dates.length === n2) {
|
|
31219
|
-
const span3 = extent(dates);
|
|
31220
|
-
if (span3) {
|
|
31221
|
-
const width = span3.max - span3.min;
|
|
31222
|
-
return dates.map((d) => d === null ? null : width ? (d - span3.min) / width : 0.5);
|
|
31223
|
-
}
|
|
31224
|
-
}
|
|
31225
|
-
return Array.from({ length: n2 }, (_, i2) => n2 === 1 ? 0.5 : i2 / (n2 - 1));
|
|
31226
|
-
}
|
|
31227
|
-
function pointFacts(values2) {
|
|
31228
|
-
const numbers3 = values2.filter((x) => x !== null);
|
|
31229
|
-
let last = values2.length - 1;
|
|
31230
|
-
while (last >= 0 && values2[last] === null) last--;
|
|
31231
|
-
return {
|
|
31232
|
-
high: Math.max(...numbers3),
|
|
31233
|
-
low: Math.min(...numbers3),
|
|
31234
|
-
first: values2.findIndex((x) => x !== null),
|
|
31235
|
-
last
|
|
31236
|
-
};
|
|
31237
|
-
}
|
|
31238
|
-
function pointColor(group, v, i2, facts, colors, markers) {
|
|
31239
|
-
let color = markers && group.markers ? colors.colorMarkers : void 0;
|
|
31240
|
-
if (group.negative && v < 0) color = colors.colorNegative;
|
|
31241
|
-
if (group.high && v === facts.high) color = colors.colorHigh;
|
|
31242
|
-
if (group.low && v === facts.low) color = colors.colorLow;
|
|
31243
|
-
if (group.first && i2 === facts.first) color = colors.colorFirst;
|
|
31244
|
-
if (group.last && i2 === facts.last) color = colors.colorLast;
|
|
31245
|
-
return color;
|
|
31246
|
-
}
|
|
31247
|
-
function resolveColors(group, theme2) {
|
|
31248
|
-
const out = { ...DEFAULTS };
|
|
31249
|
-
for (const key of Object.keys(DEFAULTS)) {
|
|
31250
|
-
const color = group[key];
|
|
31251
|
-
out[key] = resolveColor(color, theme2, DEFAULTS[key]) ?? DEFAULTS[key];
|
|
31252
|
-
}
|
|
31253
|
-
return out;
|
|
31254
|
-
}
|
|
31255
|
-
function sparklineView(group, data, scale2, theme2) {
|
|
31256
|
-
const colors = resolveColors(group, theme2);
|
|
31257
|
-
const view = {
|
|
31258
|
-
type: group.type,
|
|
31259
|
-
color: colors.colorSeries,
|
|
31260
|
-
lineWeightPt: group.lineWeight,
|
|
31261
|
-
lines: [],
|
|
31262
|
-
markers: [],
|
|
31263
|
-
columns: []
|
|
31264
|
-
};
|
|
31265
|
-
const values2 = sparklineValues(group, data.values);
|
|
31266
|
-
const n2 = values2.length;
|
|
31267
|
-
if (!n2 || !scale2) return view;
|
|
31268
|
-
const facts = pointFacts(values2);
|
|
31269
|
-
const xs = positions(group, data, n2);
|
|
31270
|
-
const flip = (x) => group.rightToLeft ? 1 - x : x;
|
|
31271
|
-
const range = scale2.max - scale2.min;
|
|
31272
|
-
const yOf = (v) => range ? Math.max(0, Math.min(1, (scale2.max - v) / range)) : 0.5;
|
|
31273
|
-
if (group.type === "line") {
|
|
31274
|
-
let segment = [];
|
|
31275
|
-
values2.forEach((v, i2) => {
|
|
31276
|
-
const x = xs[i2];
|
|
31277
|
-
if (v === null || x === null || x === void 0) {
|
|
31278
|
-
if (group.displayEmptyCellsAs === "gap" && segment.length) {
|
|
31279
|
-
view.lines.push(segment);
|
|
31280
|
-
segment = [];
|
|
31281
|
-
}
|
|
31282
|
-
return;
|
|
31283
|
-
}
|
|
31284
|
-
const point = { x: flip(x), y: yOf(v) };
|
|
31285
|
-
segment.push(point);
|
|
31286
|
-
const color = pointColor(group, v, i2, facts, colors, true);
|
|
31287
|
-
if (color) view.markers.push({ ...point, color });
|
|
31288
|
-
});
|
|
31289
|
-
if (segment.length) view.lines.push(segment);
|
|
31290
|
-
} else {
|
|
31291
|
-
const slot2 = 1 / n2;
|
|
31292
|
-
const w = slot2 * (1 - COLUMN_GAP);
|
|
31293
|
-
const base = yOf(Math.max(scale2.min, Math.min(scale2.max, 0)));
|
|
31294
|
-
values2.forEach((v, i2) => {
|
|
31295
|
-
const position = xs[i2];
|
|
31296
|
-
if (v === null || position === null || position === void 0) return;
|
|
31297
|
-
if (v === 0) return;
|
|
31298
|
-
let top;
|
|
31299
|
-
let bottom;
|
|
31300
|
-
if (group.type === "stacked") [top, bottom] = v > 0 ? [0, 0.5] : [0.5, 1];
|
|
31301
|
-
else if (!range) [top, bottom] = [0, 1];
|
|
31302
|
-
else [top, bottom] = [Math.min(base, yOf(v)), Math.max(base, yOf(v))];
|
|
31303
|
-
const centre = flip(slot2 / 2 + position * (1 - slot2));
|
|
31304
|
-
const color = pointColor(group, v, i2, facts, colors, false) ?? view.color;
|
|
31305
|
-
view.columns.push({ x: centre - w / 2, y: top, w, h: bottom - top, color });
|
|
31306
|
-
});
|
|
31307
|
-
}
|
|
31308
|
-
if (group.type === "stacked") {
|
|
31309
|
-
if (group.displayXAxis) view.axis = { y: 0.5, color: colors.colorAxis };
|
|
31310
|
-
} else if (group.displayXAxis && range && scale2.min <= 0 && scale2.max >= 0)
|
|
31311
|
-
view.axis = { y: yOf(0), color: colors.colorAxis };
|
|
31312
|
-
return view;
|
|
31313
|
-
}
|
|
31314
|
-
|
|
31315
|
-
// xlsx/layout/sparkline-data.ts
|
|
31316
|
-
var MAX_POINTS = 1e4;
|
|
31317
|
-
var hostIndex = /* @__PURE__ */ new WeakMap();
|
|
31318
|
-
function hosts(sheet) {
|
|
31319
|
-
const groups = sheetSparklineGroups(sheet);
|
|
31320
|
-
let index2 = hostIndex.get(groups);
|
|
31321
|
-
if (!index2) {
|
|
31322
|
-
index2 = /* @__PURE__ */ new Map();
|
|
31323
|
-
for (const group of groups)
|
|
31324
|
-
group.sparklines.forEach((line3, i2) => {
|
|
31325
|
-
const key = cellKey(line3.host.start.row, line3.host.start.col);
|
|
31326
|
-
if (!index2.has(key)) index2.set(key, { group, index: i2 });
|
|
31327
|
-
});
|
|
31328
|
-
hostIndex.set(groups, index2);
|
|
31329
|
-
}
|
|
31330
|
-
return index2;
|
|
31331
|
-
}
|
|
31332
|
-
function hasSparklineAt(sheet, row2, col) {
|
|
31333
|
-
return hosts(sheet).has(cellKey(row2, col));
|
|
31334
|
-
}
|
|
31335
|
-
function resolveSparklineRange(workbook, sheet, formula) {
|
|
31336
|
-
const ref = formula.trim().replace(/^=/, "");
|
|
31337
|
-
const bang = ref.lastIndexOf("!");
|
|
31338
|
-
let target = sheet;
|
|
31339
|
-
if (bang >= 0) {
|
|
31340
|
-
const raw2 = ref.slice(0, bang);
|
|
31341
|
-
const name = /^'.*'$/.test(raw2) ? raw2.slice(1, -1).replace(/''/g, "'") : raw2;
|
|
31342
|
-
target = sheetByName(workbook, name);
|
|
31343
|
-
}
|
|
31344
|
-
const range = parseRange(ref.slice(bang + 1).replace(/\$/g, ""));
|
|
31345
|
-
return target && range ? { sheet: target, range: normalizeRange(range) } : void 0;
|
|
31346
|
-
}
|
|
31347
|
-
var rowHidden = (sheet, row2) => sheet.rowInfo.get(row2)?.hidden === true;
|
|
31348
|
-
var colHidden = (sheet, col) => sheet.columns.some((c2) => c2.hidden === true && col >= c2.min && col <= c2.max);
|
|
31349
|
-
function readSparklineValues(sheet, range, displayHidden) {
|
|
31350
|
-
let endRow = range.end.row;
|
|
31351
|
-
if (endRow - range.start.row >= MAX_POINTS) {
|
|
31352
|
-
let lastRow = range.start.row;
|
|
31353
|
-
for (const row2 of sheet.rows.keys()) if (row2 > lastRow) lastRow = row2;
|
|
31354
|
-
endRow = Math.min(endRow, lastRow);
|
|
31355
|
-
}
|
|
31356
|
-
const out = [];
|
|
31357
|
-
for (let row2 = range.start.row; row2 <= endRow && out.length < MAX_POINTS; row2++) {
|
|
31358
|
-
if (!displayHidden && rowHidden(sheet, row2)) continue;
|
|
31359
|
-
for (let col = range.start.col; col <= range.end.col && out.length < MAX_POINTS; col++) {
|
|
31360
|
-
if (!displayHidden && colHidden(sheet, col)) continue;
|
|
31361
|
-
const value = getCell(sheet, row2, col)?.value;
|
|
31362
|
-
out.push(typeof value === "number" && Number.isFinite(value) ? value : null);
|
|
31363
|
-
}
|
|
31364
|
-
}
|
|
31365
|
-
return out;
|
|
31366
|
-
}
|
|
31367
|
-
function groupData(workbook, sheet, group) {
|
|
31368
|
-
const dateRange = group.dateAxis && group.dateFormula;
|
|
31369
|
-
const dates = dateRange ? resolveSparklineRange(workbook, sheet, dateRange) : void 0;
|
|
31370
|
-
const dateValues = dates ? readSparklineValues(dates.sheet, dates.range, group.displayHidden) : void 0;
|
|
31371
|
-
return group.sparklines.map((line3) => {
|
|
31372
|
-
const source2 = line3.formula ? resolveSparklineRange(workbook, sheet, line3.formula) : void 0;
|
|
31373
|
-
const values2 = source2 ? readSparklineValues(source2.sheet, source2.range, group.displayHidden) : [];
|
|
31374
|
-
return dateValues ? { values: values2, dates: dateValues } : { values: values2 };
|
|
31375
|
-
});
|
|
31376
|
-
}
|
|
31377
|
-
function sparklineViewAt(workbook, sheetIndex2, row2, col) {
|
|
31378
|
-
const sheet = workbook.sheets[sheetIndex2];
|
|
31379
|
-
if (!sheet) return void 0;
|
|
31380
|
-
const entry3 = hosts(sheet).get(cellKey(row2, col));
|
|
31381
|
-
if (!entry3) return void 0;
|
|
31382
|
-
const { group, index: index2 } = entry3;
|
|
31383
|
-
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
31384
|
-
const data = needsGroup ? groupData(workbook, sheet, group) : groupData(workbook, sheet, { ...group, sparklines: [group.sparklines[index2]] });
|
|
31385
|
-
const at = needsGroup ? index2 : 0;
|
|
31386
|
-
return sparklineView(
|
|
31387
|
-
group,
|
|
31388
|
-
data[at] ?? { values: [] },
|
|
31389
|
-
sparklineScale(group, data, at),
|
|
31390
|
-
workbook.theme
|
|
31391
|
-
);
|
|
31392
|
-
}
|
|
31393
|
-
|
|
31394
31439
|
// xlsx/layout/units.ts
|
|
31395
31440
|
var DEFAULT_MAX_DIGIT_WIDTH = 7;
|
|
31396
31441
|
var DEFAULT_BASE_COL_WIDTH = 8;
|
|
@@ -31975,13 +32020,14 @@ function duplicateSheet(ctx, index2) {
|
|
|
31975
32020
|
delete next.partName;
|
|
31976
32021
|
return next;
|
|
31977
32022
|
});
|
|
31978
|
-
|
|
31979
|
-
|
|
31980
|
-
|
|
31981
|
-
|
|
31982
|
-
|
|
32023
|
+
const rewrite2 = (formula) => renames.reduce(
|
|
32024
|
+
(f6, [from, to]) => renameTableInFormula(f6, from, to),
|
|
32025
|
+
renameSheetInFormula(formula, sheet.name, copy.name)
|
|
32026
|
+
);
|
|
32027
|
+
rewriteSheetFormulas(copy, rewrite2);
|
|
31983
32028
|
for (const drawing of copy.drawings) if (drawing.kind === "chart") delete drawing.partName;
|
|
31984
32029
|
const copiedNames = namesForCopy(workbook, index2, sheet.name, copy.name);
|
|
32030
|
+
for (const name of copiedNames) name.formula = rewrite2(name.formula);
|
|
31985
32031
|
workbook.sheets.splice(at, 0, copy);
|
|
31986
32032
|
remapSheets(workbook, (i2) => i2 >= at ? i2 + 1 : i2);
|
|
31987
32033
|
for (const n2 of copiedNames) workbook.definedNames.push({ ...n2, localSheet: at });
|