@cj-tech-master/excelts 3.0.0-canary.20251228183403.d3eb98d → 3.0.0

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v3.0.0-canary.20251228183403.d3eb98d
2
+ * @cj-tech-master/excelts v3.0.0
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], values);
3005
+ const cacheFields = makeCacheFields(source, [...rows, ...columns]);
3006
3006
  const nameToIndex = cacheFields.reduce((result, cacheField, index) => {
3007
3007
  result[cacheField.name] = index;
3008
3008
  return result;
@@ -3037,10 +3037,9 @@ 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, valueFieldNames) {
3040
+ function makeCacheFields(source, fieldNamesWithSharedItems) {
3041
3041
  const names = source.getRow(1).values;
3042
3042
  const sharedItemsFields = new Set(fieldNamesWithSharedItems);
3043
- const valueFields = new Set(valueFieldNames);
3044
3043
  const aggregate = (columnIndex) => {
3045
3044
  const columnValues = source.getColumn(columnIndex).values;
3046
3045
  const uniqueValues = /* @__PURE__ */ new Set();
@@ -3075,7 +3074,7 @@ var ExcelTS = (function(exports) {
3075
3074
  name,
3076
3075
  sharedItems: aggregate(columnIndex)
3077
3076
  });
3078
- else if (valueFields.has(name)) {
3077
+ else {
3079
3078
  const minMax = getMinMax(columnIndex);
3080
3079
  result.push({
3081
3080
  name,
@@ -3083,10 +3082,7 @@ var ExcelTS = (function(exports) {
3083
3082
  minValue: minMax?.minValue,
3084
3083
  maxValue: minMax?.maxValue
3085
3084
  });
3086
- } else result.push({
3087
- name,
3088
- sharedItems: null
3089
- });
3085
+ }
3090
3086
  }
3091
3087
  return result;
3092
3088
  }
@@ -14687,25 +14683,9 @@ var ExcelTS = (function(exports) {
14687
14683
  }
14688
14684
  render() {
14689
14685
  const escapedName = xmlEncode(this.name);
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}" />
14686
+ if (this.sharedItems === null) return `<cacheField name="${escapedName}" numFmtId="0">
14687
+ <sharedItems containsSemiMixedTypes="0" containsString="0" containsNumber="1" containsInteger="1"${this.minValue !== void 0 && this.maxValue !== void 0 ? ` minValue="${this.minValue}" maxValue="${this.maxValue}"` : ""} />
14696
14688
  </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
- }
14709
14689
  return `<cacheField name="${escapedName}" numFmtId="0">
14710
14690
  <sharedItems count="${this.sharedItems.length}">
14711
14691
  ${this.sharedItems.map((item) => `<s v="${xmlEncode(String(item))}" />`).join("")}
@@ -14759,13 +14739,16 @@ var ExcelTS = (function(exports) {
14759
14739
  break;
14760
14740
  case "sharedItems":
14761
14741
  this.inSharedItems = true;
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);
14742
+ if (attributes.containsNumber === "1" || attributes.containsInteger === "1") {
14743
+ if (this.model) {
14744
+ this.model.containsNumber = attributes.containsNumber === "1";
14745
+ this.model.containsInteger = attributes.containsInteger === "1";
14746
+ if (attributes.minValue !== void 0) this.model.minValue = parseFloat(attributes.minValue);
14747
+ if (attributes.maxValue !== void 0) this.model.maxValue = parseFloat(attributes.maxValue);
14748
+ this.model.sharedItems = null;
14749
+ }
14750
+ } else if (this.model) {
14767
14751
  if (parseInt(attributes.count || "0", 10) > 0) this.model.sharedItems = [];
14768
- else this.model.sharedItems = null;
14769
14752
  }
14770
14753
  break;
14771
14754
  case "s":
@@ -15429,14 +15412,13 @@ var ExcelTS = (function(exports) {
15429
15412
  const colSet = new Set(pivotTable.columns);
15430
15413
  const valueSet = new Set(pivotTable.values);
15431
15414
  return pivotTable.cacheFields.map((cacheField, fieldIndex) => {
15432
- return renderPivotField(rowSet.has(fieldIndex), colSet.has(fieldIndex), valueSet.has(fieldIndex), cacheField.sharedItems);
15415
+ return renderPivotField(rowSet.has(fieldIndex) ? "row" : colSet.has(fieldIndex) ? "column" : valueSet.has(fieldIndex) ? "value" : null, cacheField.sharedItems);
15433
15416
  }).join("");
15434
15417
  }
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}`;
15418
+ function renderPivotField(fieldType, sharedItems) {
15419
+ if (fieldType === "row" || fieldType === "column") {
15420
+ const axis = fieldType === "row" ? "axisRow" : "axisCol";
15421
+ const axisAttributes = "compact=\"0\" outline=\"0\" showAll=\"0\"";
15440
15422
  const itemsXml = [...sharedItems.map((_item, index) => `<item x="${index}" />`), "<item t=\"default\" />"].join("\n ");
15441
15423
  return `
15442
15424
  <pivotField axis="${axis}" ${axisAttributes}>
@@ -15448,7 +15430,7 @@ var ExcelTS = (function(exports) {
15448
15430
  }
15449
15431
  return `
15450
15432
  <pivotField
15451
- ${isValue ? "dataField=\"1\"" : ""}
15433
+ ${fieldType === "value" ? "dataField=\"1\"" : ""}
15452
15434
  compact="0" outline="0" showAll="0" defaultSubtotal="0"
15453
15435
  />
15454
15436
  `;