@cj-tech-master/excelts 2.0.1-canary.20251228093548.379d895 → 3.0.0-canary.20251228183403.d3eb98d
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/browser/excelts.esm.js +40 -22
- package/dist/browser/excelts.esm.js.map +1 -1
- package/dist/browser/excelts.esm.min.js +16 -10
- package/dist/browser/excelts.iife.js +40 -22
- package/dist/browser/excelts.iife.js.map +1 -1
- package/dist/browser/excelts.iife.min.js +16 -10
- package/dist/cjs/doc/pivot-table.js +12 -5
- package/dist/cjs/xlsx/xform/pivot-table/cache-field-xform.js +17 -21
- package/dist/cjs/xlsx/xform/pivot-table/cache-field.js +37 -8
- package/dist/cjs/xlsx/xform/pivot-table/pivot-cache-records-xform.js +1 -1
- package/dist/cjs/xlsx/xform/pivot-table/pivot-table-xform.js +15 -16
- package/dist/esm/doc/pivot-table.js +12 -5
- package/dist/esm/xlsx/xform/pivot-table/cache-field-xform.js +17 -21
- package/dist/esm/xlsx/xform/pivot-table/cache-field.js +37 -8
- package/dist/esm/xlsx/xform/pivot-table/pivot-cache-records-xform.js +1 -1
- package/dist/esm/xlsx/xform/pivot-table/pivot-table-xform.js +15 -16
- package/dist/types/xlsx/xform/pivot-table/cache-field-xform.d.ts +1 -1
- package/dist/types/xlsx/xform/pivot-table/cache-field.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cj-tech-master/excelts
|
|
2
|
+
* @cj-tech-master/excelts v3.0.0-canary.20251228183403.d3eb98d
|
|
3
3
|
* TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.
|
|
4
4
|
* (c) 2025 cjnoname
|
|
5
5
|
* Released under the MIT License
|
|
@@ -3002,7 +3002,7 @@ var ExcelTS = (function(exports) {
|
|
|
3002
3002
|
validate(worksheet, model, source);
|
|
3003
3003
|
const { rows, values } = model;
|
|
3004
3004
|
const columns = model.columns ?? [];
|
|
3005
|
-
const cacheFields = makeCacheFields(source, [...rows, ...columns]);
|
|
3005
|
+
const cacheFields = makeCacheFields(source, [...rows, ...columns], values);
|
|
3006
3006
|
const nameToIndex = cacheFields.reduce((result, cacheField, index) => {
|
|
3007
3007
|
result[cacheField.name] = index;
|
|
3008
3008
|
return result;
|
|
@@ -3037,9 +3037,10 @@ var ExcelTS = (function(exports) {
|
|
|
3037
3037
|
if (model.values.length < 1) throw new Error("Must have at least one value.");
|
|
3038
3038
|
if (model.values.length > 1 && columns.length > 0) throw new Error("It is currently not possible to have multiple values when columns are specified. Please either supply an empty array for columns or a single value.");
|
|
3039
3039
|
}
|
|
3040
|
-
function makeCacheFields(source, fieldNamesWithSharedItems) {
|
|
3040
|
+
function makeCacheFields(source, fieldNamesWithSharedItems, valueFieldNames) {
|
|
3041
3041
|
const names = source.getRow(1).values;
|
|
3042
3042
|
const sharedItemsFields = new Set(fieldNamesWithSharedItems);
|
|
3043
|
+
const valueFields = new Set(valueFieldNames);
|
|
3043
3044
|
const aggregate = (columnIndex) => {
|
|
3044
3045
|
const columnValues = source.getColumn(columnIndex).values;
|
|
3045
3046
|
const uniqueValues = /* @__PURE__ */ new Set();
|
|
@@ -3074,7 +3075,7 @@ var ExcelTS = (function(exports) {
|
|
|
3074
3075
|
name,
|
|
3075
3076
|
sharedItems: aggregate(columnIndex)
|
|
3076
3077
|
});
|
|
3077
|
-
else {
|
|
3078
|
+
else if (valueFields.has(name)) {
|
|
3078
3079
|
const minMax = getMinMax(columnIndex);
|
|
3079
3080
|
result.push({
|
|
3080
3081
|
name,
|
|
@@ -3082,7 +3083,10 @@ var ExcelTS = (function(exports) {
|
|
|
3082
3083
|
minValue: minMax?.minValue,
|
|
3083
3084
|
maxValue: minMax?.maxValue
|
|
3084
3085
|
});
|
|
3085
|
-
}
|
|
3086
|
+
} else result.push({
|
|
3087
|
+
name,
|
|
3088
|
+
sharedItems: null
|
|
3089
|
+
});
|
|
3086
3090
|
}
|
|
3087
3091
|
return result;
|
|
3088
3092
|
}
|
|
@@ -14683,9 +14687,25 @@ var ExcelTS = (function(exports) {
|
|
|
14683
14687
|
}
|
|
14684
14688
|
render() {
|
|
14685
14689
|
const escapedName = xmlEncode(this.name);
|
|
14686
|
-
if (this.sharedItems === null)
|
|
14687
|
-
|
|
14690
|
+
if (this.sharedItems === null) {
|
|
14691
|
+
if (this.minValue === void 0 || this.maxValue === void 0) return `<cacheField name="${escapedName}" numFmtId="0">
|
|
14692
|
+
<sharedItems />
|
|
14693
|
+
</cacheField>`;
|
|
14694
|
+
return `<cacheField name="${escapedName}" numFmtId="0">
|
|
14695
|
+
<sharedItems containsSemiMixedTypes="0" containsString="0" containsNumber="1" containsInteger="1" minValue="${this.minValue}" maxValue="${this.maxValue}" />
|
|
14688
14696
|
</cacheField>`;
|
|
14697
|
+
}
|
|
14698
|
+
const allNumeric = this.sharedItems.length > 0 && this.sharedItems.every((item) => typeof item === "number" && Number.isFinite(item));
|
|
14699
|
+
const allInteger = allNumeric && this.sharedItems.every((item) => Number.isInteger(item));
|
|
14700
|
+
if (allNumeric) {
|
|
14701
|
+
const minValue = Math.min(...this.sharedItems);
|
|
14702
|
+
const maxValue = Math.max(...this.sharedItems);
|
|
14703
|
+
return `<cacheField name="${escapedName}" numFmtId="0">
|
|
14704
|
+
<sharedItems containsSemiMixedTypes="0" containsString="0" containsNumber="1"${allInteger ? " containsInteger=\"1\"" : ""} minValue="${minValue}" maxValue="${maxValue}" count="${this.sharedItems.length}">
|
|
14705
|
+
${this.sharedItems.map((item) => `<n v="${item}" />`).join("")}
|
|
14706
|
+
</sharedItems>
|
|
14707
|
+
</cacheField>`;
|
|
14708
|
+
}
|
|
14689
14709
|
return `<cacheField name="${escapedName}" numFmtId="0">
|
|
14690
14710
|
<sharedItems count="${this.sharedItems.length}">
|
|
14691
14711
|
${this.sharedItems.map((item) => `<s v="${xmlEncode(String(item))}" />`).join("")}
|
|
@@ -14739,16 +14759,13 @@ var ExcelTS = (function(exports) {
|
|
|
14739
14759
|
break;
|
|
14740
14760
|
case "sharedItems":
|
|
14741
14761
|
this.inSharedItems = true;
|
|
14742
|
-
if (
|
|
14743
|
-
|
|
14744
|
-
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
if (attributes.maxValue !== void 0) this.model.maxValue = parseFloat(attributes.maxValue);
|
|
14748
|
-
this.model.sharedItems = null;
|
|
14749
|
-
}
|
|
14750
|
-
} else if (this.model) {
|
|
14762
|
+
if (this.model) {
|
|
14763
|
+
this.model.containsNumber = attributes.containsNumber === "1";
|
|
14764
|
+
this.model.containsInteger = attributes.containsInteger === "1";
|
|
14765
|
+
if (attributes.minValue !== void 0) this.model.minValue = parseFloat(attributes.minValue);
|
|
14766
|
+
if (attributes.maxValue !== void 0) this.model.maxValue = parseFloat(attributes.maxValue);
|
|
14751
14767
|
if (parseInt(attributes.count || "0", 10) > 0) this.model.sharedItems = [];
|
|
14768
|
+
else this.model.sharedItems = null;
|
|
14752
14769
|
}
|
|
14753
14770
|
break;
|
|
14754
14771
|
case "s":
|
|
@@ -15412,13 +15429,14 @@ var ExcelTS = (function(exports) {
|
|
|
15412
15429
|
const colSet = new Set(pivotTable.columns);
|
|
15413
15430
|
const valueSet = new Set(pivotTable.values);
|
|
15414
15431
|
return pivotTable.cacheFields.map((cacheField, fieldIndex) => {
|
|
15415
|
-
return renderPivotField(rowSet.has(fieldIndex)
|
|
15432
|
+
return renderPivotField(rowSet.has(fieldIndex), colSet.has(fieldIndex), valueSet.has(fieldIndex), cacheField.sharedItems);
|
|
15416
15433
|
}).join("");
|
|
15417
15434
|
}
|
|
15418
|
-
function renderPivotField(
|
|
15419
|
-
if (
|
|
15420
|
-
const axis =
|
|
15421
|
-
|
|
15435
|
+
function renderPivotField(isRow, isCol, isValue, sharedItems) {
|
|
15436
|
+
if (isRow || isCol) {
|
|
15437
|
+
const axis = isRow ? "axisRow" : "axisCol";
|
|
15438
|
+
let axisAttributes = "compact=\"0\" outline=\"0\" showAll=\"0\"";
|
|
15439
|
+
if (isValue) axisAttributes = `dataField="1" ${axisAttributes}`;
|
|
15422
15440
|
const itemsXml = [...sharedItems.map((_item, index) => `<item x="${index}" />`), "<item t=\"default\" />"].join("\n ");
|
|
15423
15441
|
return `
|
|
15424
15442
|
<pivotField axis="${axis}" ${axisAttributes}>
|
|
@@ -15430,7 +15448,7 @@ var ExcelTS = (function(exports) {
|
|
|
15430
15448
|
}
|
|
15431
15449
|
return `
|
|
15432
15450
|
<pivotField
|
|
15433
|
-
${
|
|
15451
|
+
${isValue ? "dataField=\"1\"" : ""}
|
|
15434
15452
|
compact="0" outline="0" showAll="0" defaultSubtotal="0"
|
|
15435
15453
|
/>
|
|
15436
15454
|
`;
|