@cj-tech-master/excelts 2.0.0 → 2.0.1
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 +78 -17
- package/dist/browser/excelts.esm.js.map +1 -1
- package/dist/browser/excelts.esm.min.js +34 -31
- package/dist/browser/excelts.iife.js +78 -17
- package/dist/browser/excelts.iife.js.map +1 -1
- package/dist/browser/excelts.iife.min.js +32 -29
- package/dist/cjs/utils/datetime.js +7 -156
- package/dist/cjs/xlsx/xform/pivot-table/pivot-cache-definition-xform.js +3 -1
- package/dist/cjs/xlsx/xform/pivot-table/pivot-table-xform.js +91 -6
- package/dist/esm/utils/datetime.js +7 -153
- package/dist/esm/xlsx/xform/pivot-table/pivot-cache-definition-xform.js +3 -1
- package/dist/esm/xlsx/xform/pivot-table/pivot-table-xform.js +91 -6
- package/dist/types/csv/csv-core.d.ts +0 -6
- package/dist/types/stream/xlsx/workbook-reader.d.ts +1 -1
- package/dist/types/stream/xlsx/worksheet-reader.d.ts +1 -1
- package/dist/types/utils/datetime.d.ts +0 -29
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cj-tech-master/excelts v2.0.
|
|
2
|
+
* @cj-tech-master/excelts v2.0.1
|
|
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
|
|
@@ -14790,6 +14790,7 @@ var ExcelTS = (function(exports) {
|
|
|
14790
14790
|
*/
|
|
14791
14791
|
renderNew(xmlStream, model) {
|
|
14792
14792
|
const { source, cacheFields } = model;
|
|
14793
|
+
const recordCount = source.getSheetValues().slice(2).length;
|
|
14793
14794
|
xmlStream.openXml(XmlStream.StdDocAttributes);
|
|
14794
14795
|
xmlStream.openNode(this.tag, {
|
|
14795
14796
|
...PivotCacheDefinitionXform.PIVOT_CACHE_DEFINITION_ATTRIBUTES,
|
|
@@ -14800,7 +14801,7 @@ var ExcelTS = (function(exports) {
|
|
|
14800
14801
|
createdVersion: "8",
|
|
14801
14802
|
refreshedVersion: "8",
|
|
14802
14803
|
minRefreshableVersion: "3",
|
|
14803
|
-
recordCount
|
|
14804
|
+
recordCount
|
|
14804
14805
|
});
|
|
14805
14806
|
xmlStream.openNode("cacheSource", { type: "worksheet" });
|
|
14806
14807
|
xmlStream.leafNode("worksheetSource", {
|
|
@@ -14967,6 +14968,13 @@ var ExcelTS = (function(exports) {
|
|
|
14967
14968
|
renderNew(xmlStream, model) {
|
|
14968
14969
|
const { rows, columns, values, cacheFields, cacheId, applyWidthHeightFormats } = model;
|
|
14969
14970
|
const uniqueUid = `{${crypto.randomUUID().toUpperCase()}}`;
|
|
14971
|
+
const rowItems = buildRowItems(rows, cacheFields);
|
|
14972
|
+
const colItems = buildColItems(columns, cacheFields, values.length);
|
|
14973
|
+
const rowFieldItemCount = rows.length > 0 ? cacheFields[rows[0]]?.sharedItems?.length || 0 : 0;
|
|
14974
|
+
const colFieldItemCount = columns.length > 0 ? cacheFields[columns[0]]?.sharedItems?.length || 0 : 0;
|
|
14975
|
+
const endRow = 3 + rowFieldItemCount + 1;
|
|
14976
|
+
const endCol = 1 + colFieldItemCount + 1;
|
|
14977
|
+
const locationRef = `A3:${String.fromCharCode(64 + endCol)}${endRow}`;
|
|
14970
14978
|
xmlStream.openXml(XmlStream.StdDocAttributes);
|
|
14971
14979
|
xmlStream.openNode(this.tag, {
|
|
14972
14980
|
...PivotTableXform.PIVOT_TABLE_ATTRIBUTES,
|
|
@@ -14991,21 +14999,21 @@ var ExcelTS = (function(exports) {
|
|
|
14991
14999
|
multipleFieldFilters: "0"
|
|
14992
15000
|
});
|
|
14993
15001
|
xmlStream.writeXml(`
|
|
14994
|
-
<location ref="
|
|
15002
|
+
<location ref="${locationRef}" firstHeaderRow="1" firstDataRow="2" firstDataCol="1" />
|
|
14995
15003
|
<pivotFields count="${cacheFields.length}">
|
|
14996
15004
|
${renderPivotFields(model)}
|
|
14997
15005
|
</pivotFields>
|
|
14998
15006
|
<rowFields count="${rows.length}">
|
|
14999
15007
|
${rows.map((rowIndex) => `<field x="${rowIndex}" />`).join("\n ")}
|
|
15000
15008
|
</rowFields>
|
|
15001
|
-
<rowItems count="
|
|
15002
|
-
|
|
15009
|
+
<rowItems count="${rowItems.count}">
|
|
15010
|
+
${rowItems.xml}
|
|
15003
15011
|
</rowItems>
|
|
15004
15012
|
<colFields count="${columns.length === 0 ? 1 : columns.length}">
|
|
15005
15013
|
${columns.length === 0 ? "<field x=\"-2\" />" : columns.map((columnIndex) => `<field x="${columnIndex}" />`).join("\n ")}
|
|
15006
15014
|
</colFields>
|
|
15007
|
-
<colItems count="
|
|
15008
|
-
|
|
15015
|
+
<colItems count="${colItems.count}">
|
|
15016
|
+
${colItems.xml}
|
|
15009
15017
|
</colItems>
|
|
15010
15018
|
<dataFields count="${values.length}">
|
|
15011
15019
|
${buildDataFields(cacheFields, values, model.metric)}
|
|
@@ -15307,6 +15315,55 @@ var ExcelTS = (function(exports) {
|
|
|
15307
15315
|
}
|
|
15308
15316
|
};
|
|
15309
15317
|
/**
|
|
15318
|
+
* Build rowItems XML - one item for each unique value in row fields, plus grand total.
|
|
15319
|
+
* Each <i> represents a row in the pivot table.
|
|
15320
|
+
* - Regular items: <i><x v="index"/></i> where index is the position in sharedItems
|
|
15321
|
+
* - Grand total: <i t="grand"><x/></i>
|
|
15322
|
+
*/
|
|
15323
|
+
function buildRowItems(rows, cacheFields) {
|
|
15324
|
+
if (rows.length === 0) return {
|
|
15325
|
+
count: 1,
|
|
15326
|
+
xml: "<i t=\"grand\"><x /></i>"
|
|
15327
|
+
};
|
|
15328
|
+
const itemCount = (cacheFields[rows[0]]?.sharedItems || []).length;
|
|
15329
|
+
const items = [];
|
|
15330
|
+
for (let i = 0; i < itemCount; i++) items.push(`<i><x v="${i}" /></i>`);
|
|
15331
|
+
items.push("<i t=\"grand\"><x /></i>");
|
|
15332
|
+
return {
|
|
15333
|
+
count: items.length,
|
|
15334
|
+
xml: items.join("\n ")
|
|
15335
|
+
};
|
|
15336
|
+
}
|
|
15337
|
+
/**
|
|
15338
|
+
* Build colItems XML - one item for each unique value in column fields, plus grand total.
|
|
15339
|
+
* When there are multiple data fields (values), each column value may have sub-columns.
|
|
15340
|
+
*/
|
|
15341
|
+
function buildColItems(columns, cacheFields, valueCount) {
|
|
15342
|
+
if (columns.length === 0) {
|
|
15343
|
+
if (valueCount > 1) {
|
|
15344
|
+
const items$1 = [];
|
|
15345
|
+
for (let i = 0; i < valueCount; i++) items$1.push(`<i><x v="${i}" /></i>`);
|
|
15346
|
+
items$1.push("<i t=\"grand\"><x /></i>");
|
|
15347
|
+
return {
|
|
15348
|
+
count: items$1.length,
|
|
15349
|
+
xml: items$1.join("\n ")
|
|
15350
|
+
};
|
|
15351
|
+
}
|
|
15352
|
+
return {
|
|
15353
|
+
count: 1,
|
|
15354
|
+
xml: "<i t=\"grand\"><x /></i>"
|
|
15355
|
+
};
|
|
15356
|
+
}
|
|
15357
|
+
const itemCount = (cacheFields[columns[0]]?.sharedItems || []).length;
|
|
15358
|
+
const items = [];
|
|
15359
|
+
for (let i = 0; i < itemCount; i++) items.push(`<i><x v="${i}" /></i>`);
|
|
15360
|
+
items.push("<i t=\"grand\"><x /></i>");
|
|
15361
|
+
return {
|
|
15362
|
+
count: items.length,
|
|
15363
|
+
xml: items.join("\n ")
|
|
15364
|
+
};
|
|
15365
|
+
}
|
|
15366
|
+
/**
|
|
15310
15367
|
* Build dataField XML elements for all values in the pivot table.
|
|
15311
15368
|
* Supports multiple values when columns is empty.
|
|
15312
15369
|
*/
|
|
@@ -15330,13 +15387,17 @@ var ExcelTS = (function(exports) {
|
|
|
15330
15387
|
}
|
|
15331
15388
|
function renderPivotField(fieldType, sharedItems) {
|
|
15332
15389
|
const defaultAttributes = "compact=\"0\" outline=\"0\" showAll=\"0\" defaultSubtotal=\"0\"";
|
|
15333
|
-
if (fieldType === "row" || fieldType === "column")
|
|
15334
|
-
|
|
15390
|
+
if (fieldType === "row" || fieldType === "column") {
|
|
15391
|
+
const axis = fieldType === "row" ? "axisRow" : "axisCol";
|
|
15392
|
+
const itemsXml = [...sharedItems.map((_item, index) => `<item x="${index}" />`), "<item t=\"default\" />"].join("\n ");
|
|
15393
|
+
return `
|
|
15394
|
+
<pivotField axis="${axis}" ${defaultAttributes}>
|
|
15335
15395
|
<items count="${sharedItems.length + 1}">
|
|
15336
|
-
${
|
|
15396
|
+
${itemsXml}
|
|
15337
15397
|
</items>
|
|
15338
15398
|
</pivotField>
|
|
15339
15399
|
`;
|
|
15400
|
+
}
|
|
15340
15401
|
return `
|
|
15341
15402
|
<pivotField
|
|
15342
15403
|
${fieldType === "value" ? "dataField=\"1\"" : ""}
|
|
@@ -16785,13 +16846,6 @@ var ExcelTS = (function(exports) {
|
|
|
16785
16846
|
[25, [parseISOOffset]],
|
|
16786
16847
|
[29, [parseISOMsOffset]]
|
|
16787
16848
|
];
|
|
16788
|
-
function tzOffset(d) {
|
|
16789
|
-
const off = -d.getTimezoneOffset();
|
|
16790
|
-
const sign = off >= 0 ? "+" : "-";
|
|
16791
|
-
const h = Math.abs(off) / 60 | 0;
|
|
16792
|
-
const m = Math.abs(off) % 60;
|
|
16793
|
-
return `${sign}${PAD2[h]}:${PAD2[m]}`;
|
|
16794
|
-
}
|
|
16795
16849
|
/**
|
|
16796
16850
|
* Optimized date parser for batch processing
|
|
16797
16851
|
*
|
|
@@ -16845,6 +16899,13 @@ var ExcelTS = (function(exports) {
|
|
|
16845
16899
|
return out;
|
|
16846
16900
|
}
|
|
16847
16901
|
};
|
|
16902
|
+
function tzOffset(d) {
|
|
16903
|
+
const off = -d.getTimezoneOffset();
|
|
16904
|
+
const sign = off >= 0 ? "+" : "-";
|
|
16905
|
+
const h = Math.abs(off) / 60 | 0;
|
|
16906
|
+
const m = Math.abs(off) % 60;
|
|
16907
|
+
return `${sign}${PAD2[h]}:${PAD2[m]}`;
|
|
16908
|
+
}
|
|
16848
16909
|
/**
|
|
16849
16910
|
* Optimized date formatter for batch processing
|
|
16850
16911
|
*
|