@cj-tech-master/excelts 2.0.0-canary.20251228024848.8822305 → 2.0.1-canary.20251228093548.379d895

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.
Files changed (53) hide show
  1. package/dist/browser/excelts.esm.js +146 -116
  2. package/dist/browser/excelts.esm.js.map +1 -1
  3. package/dist/browser/excelts.esm.min.js +22 -22
  4. package/dist/browser/excelts.iife.js +146 -116
  5. package/dist/browser/excelts.iife.js.map +1 -1
  6. package/dist/browser/excelts.iife.min.js +22 -22
  7. package/dist/cjs/doc/pivot-table.js +37 -3
  8. package/dist/cjs/doc/worksheet.js +0 -1
  9. package/dist/cjs/stream/xlsx/worksheet-writer.js +0 -1
  10. package/dist/cjs/xlsx/xform/book/sheet-xform.js +3 -2
  11. package/dist/cjs/xlsx/xform/book/workbook-properties-xform.js +1 -1
  12. package/dist/cjs/xlsx/xform/core/content-types-xform.js +12 -6
  13. package/dist/cjs/xlsx/xform/pivot-table/cache-field.js +11 -4
  14. package/dist/cjs/xlsx/xform/pivot-table/pivot-cache-definition-xform.js +1 -10
  15. package/dist/cjs/xlsx/xform/pivot-table/pivot-table-xform.js +39 -17
  16. package/dist/cjs/xlsx/xform/sheet/page-setup-xform.js +4 -3
  17. package/dist/cjs/xlsx/xform/sheet/row-xform.js +1 -1
  18. package/dist/cjs/xlsx/xform/sheet/sheet-format-properties-xform.js +6 -3
  19. package/dist/cjs/xlsx/xform/sheet/sheet-view-xform.js +8 -4
  20. package/dist/cjs/xlsx/xform/sheet/worksheet-xform.js +2 -2
  21. package/dist/cjs/xlsx/xform/style/font-xform.js +36 -23
  22. package/dist/cjs/xlsx/xform/table/auto-filter-xform.js +3 -1
  23. package/dist/cjs/xlsx/xform/table/table-column-xform.js +2 -1
  24. package/dist/cjs/xlsx/xform/table/table-xform.js +5 -9
  25. package/dist/esm/doc/pivot-table.js +37 -3
  26. package/dist/esm/doc/worksheet.js +0 -1
  27. package/dist/esm/stream/xlsx/worksheet-writer.js +0 -1
  28. package/dist/esm/xlsx/xform/book/sheet-xform.js +3 -2
  29. package/dist/esm/xlsx/xform/book/workbook-properties-xform.js +1 -1
  30. package/dist/esm/xlsx/xform/core/content-types-xform.js +12 -6
  31. package/dist/esm/xlsx/xform/pivot-table/cache-field.js +11 -4
  32. package/dist/esm/xlsx/xform/pivot-table/pivot-cache-definition-xform.js +1 -10
  33. package/dist/esm/xlsx/xform/pivot-table/pivot-table-xform.js +39 -17
  34. package/dist/esm/xlsx/xform/sheet/page-setup-xform.js +4 -3
  35. package/dist/esm/xlsx/xform/sheet/row-xform.js +1 -1
  36. package/dist/esm/xlsx/xform/sheet/sheet-format-properties-xform.js +6 -3
  37. package/dist/esm/xlsx/xform/sheet/sheet-view-xform.js +8 -4
  38. package/dist/esm/xlsx/xform/sheet/worksheet-xform.js +2 -2
  39. package/dist/esm/xlsx/xform/style/font-xform.js +36 -23
  40. package/dist/esm/xlsx/xform/table/auto-filter-xform.js +3 -1
  41. package/dist/esm/xlsx/xform/table/table-column-xform.js +2 -1
  42. package/dist/esm/xlsx/xform/table/table-xform.js +5 -9
  43. package/dist/types/doc/pivot-table.d.ts +5 -1
  44. package/dist/types/stream/xlsx/worksheet-writer.d.ts +1 -1
  45. package/dist/types/types.d.ts +1 -1
  46. package/dist/types/xlsx/xform/pivot-table/cache-field.d.ts +5 -1
  47. package/dist/types/xlsx/xform/pivot-table/pivot-cache-definition-xform.d.ts +0 -5
  48. package/dist/types/xlsx/xform/pivot-table/pivot-table-xform.d.ts +0 -3
  49. package/dist/types/xlsx/xform/sheet/sheet-format-properties-xform.d.ts +1 -1
  50. package/dist/types/xlsx/xform/sheet/worksheet-xform.d.ts +1 -1
  51. package/dist/types/xlsx/xform/style/font-xform.d.ts +1 -0
  52. package/dist/types/xlsx/xform/table/table-xform.d.ts +0 -4
  53. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v2.0.0-canary.20251228024848.8822305
2
+ * @cj-tech-master/excelts v2.0.1-canary.20251228093548.379d895
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
@@ -2962,7 +2962,7 @@ function createTableSourceAdapter(table) {
2962
2962
  const endCol = startCol + columnNames.length - 1;
2963
2963
  const shortRange = colCache.encode(startRow, startCol, endRow, endCol);
2964
2964
  return {
2965
- name: tableModel.name,
2965
+ name: table.worksheet.name,
2966
2966
  getRow(rowNumber) {
2967
2967
  if (rowNumber === 1) return { values: headerRow };
2968
2968
  const dataIndex = rowNumber - 2;
@@ -3046,14 +3046,40 @@ function makeCacheFields(source, fieldNamesWithSharedItems) {
3046
3046
  }
3047
3047
  return toSortedArray(uniqueValues);
3048
3048
  };
3049
+ const getMinMax = (columnIndex) => {
3050
+ const columnValues = source.getColumn(columnIndex).values;
3051
+ let min = Infinity;
3052
+ let max = -Infinity;
3053
+ let hasNumeric = false;
3054
+ for (let i = 2; i < columnValues.length; i++) {
3055
+ const v = columnValues[i];
3056
+ if (typeof v === "number" && !isNaN(v)) {
3057
+ hasNumeric = true;
3058
+ if (v < min) min = v;
3059
+ if (v > max) max = v;
3060
+ }
3061
+ }
3062
+ return hasNumeric ? {
3063
+ minValue: min,
3064
+ maxValue: max
3065
+ } : null;
3066
+ };
3049
3067
  const result = [];
3050
3068
  for (const columnIndex of range(1, names.length)) {
3051
3069
  const name = names[columnIndex];
3052
- const sharedItems = sharedItemsFields.has(name) ? aggregate(columnIndex) : null;
3053
- result.push({
3070
+ if (sharedItemsFields.has(name)) result.push({
3054
3071
  name,
3055
- sharedItems
3072
+ sharedItems: aggregate(columnIndex)
3056
3073
  });
3074
+ else {
3075
+ const minMax = getMinMax(columnIndex);
3076
+ result.push({
3077
+ name,
3078
+ sharedItems: null,
3079
+ minValue: minMax?.minValue,
3080
+ maxValue: minMax?.maxValue
3081
+ });
3082
+ }
3057
3083
  }
3058
3084
  return result;
3059
3085
  }
@@ -3115,7 +3141,6 @@ var Worksheet = class {
3115
3141
  this.colBreaks = [];
3116
3142
  this.properties = Object.assign({}, {
3117
3143
  defaultRowHeight: 15,
3118
- dyDescent: 55,
3119
3144
  outlineLevelCol: 0,
3120
3145
  outlineLevelRow: 0
3121
3146
  }, options.properties);
@@ -7489,116 +7514,136 @@ var FontXform = class FontXform extends BaseXform {
7489
7514
  constructor(options) {
7490
7515
  super();
7491
7516
  this.options = options || FontXform.OPTIONS;
7492
- this.map = {
7493
- b: {
7517
+ const fontProperties = [
7518
+ {
7519
+ tag: "b",
7494
7520
  prop: "bold",
7495
7521
  xform: new BooleanXform({
7496
7522
  tag: "b",
7497
7523
  attr: "val"
7498
7524
  })
7499
7525
  },
7500
- i: {
7526
+ {
7527
+ tag: "i",
7501
7528
  prop: "italic",
7502
7529
  xform: new BooleanXform({
7503
7530
  tag: "i",
7504
7531
  attr: "val"
7505
7532
  })
7506
7533
  },
7507
- u: {
7534
+ {
7535
+ tag: "u",
7508
7536
  prop: "underline",
7509
7537
  xform: new UnderlineXform()
7510
7538
  },
7511
- charset: {
7512
- prop: "charset",
7513
- xform: new IntegerXform({
7514
- tag: "charset",
7539
+ {
7540
+ tag: "strike",
7541
+ prop: "strike",
7542
+ xform: new BooleanXform({
7543
+ tag: "strike",
7515
7544
  attr: "val"
7516
7545
  })
7517
7546
  },
7518
- color: {
7519
- prop: "color",
7520
- xform: new ColorXform()
7521
- },
7522
- condense: {
7547
+ {
7548
+ tag: "condense",
7523
7549
  prop: "condense",
7524
7550
  xform: new BooleanXform({
7525
7551
  tag: "condense",
7526
7552
  attr: "val"
7527
7553
  })
7528
7554
  },
7529
- extend: {
7555
+ {
7556
+ tag: "extend",
7530
7557
  prop: "extend",
7531
7558
  xform: new BooleanXform({
7532
7559
  tag: "extend",
7533
7560
  attr: "val"
7534
7561
  })
7535
7562
  },
7536
- family: {
7537
- prop: "family",
7538
- xform: new IntegerXform({
7539
- tag: "family",
7563
+ {
7564
+ tag: "outline",
7565
+ prop: "outline",
7566
+ xform: new BooleanXform({
7567
+ tag: "outline",
7540
7568
  attr: "val"
7541
7569
  })
7542
7570
  },
7543
- outline: {
7544
- prop: "outline",
7571
+ {
7572
+ tag: "shadow",
7573
+ prop: "shadow",
7545
7574
  xform: new BooleanXform({
7546
- tag: "outline",
7575
+ tag: "shadow",
7547
7576
  attr: "val"
7548
7577
  })
7549
7578
  },
7550
- vertAlign: {
7551
- prop: "vertAlign",
7552
- xform: new StringXform({
7553
- tag: "vertAlign",
7579
+ {
7580
+ tag: "sz",
7581
+ prop: "size",
7582
+ xform: new IntegerXform({
7583
+ tag: "sz",
7554
7584
  attr: "val"
7555
7585
  })
7556
7586
  },
7557
- scheme: {
7558
- prop: "scheme",
7587
+ {
7588
+ tag: "color",
7589
+ prop: "color",
7590
+ xform: new ColorXform()
7591
+ },
7592
+ {
7593
+ tag: this.options.fontNameTag,
7594
+ prop: "name",
7559
7595
  xform: new StringXform({
7560
- tag: "scheme",
7596
+ tag: this.options.fontNameTag,
7561
7597
  attr: "val"
7562
7598
  })
7563
7599
  },
7564
- shadow: {
7565
- prop: "shadow",
7566
- xform: new BooleanXform({
7567
- tag: "shadow",
7600
+ {
7601
+ tag: "family",
7602
+ prop: "family",
7603
+ xform: new IntegerXform({
7604
+ tag: "family",
7568
7605
  attr: "val"
7569
7606
  })
7570
7607
  },
7571
- strike: {
7572
- prop: "strike",
7573
- xform: new BooleanXform({
7574
- tag: "strike",
7608
+ {
7609
+ tag: "scheme",
7610
+ prop: "scheme",
7611
+ xform: new StringXform({
7612
+ tag: "scheme",
7575
7613
  attr: "val"
7576
7614
  })
7577
7615
  },
7578
- sz: {
7579
- prop: "size",
7616
+ {
7617
+ tag: "charset",
7618
+ prop: "charset",
7580
7619
  xform: new IntegerXform({
7581
- tag: "sz",
7620
+ tag: "charset",
7621
+ attr: "val"
7622
+ })
7623
+ },
7624
+ {
7625
+ tag: "vertAlign",
7626
+ prop: "vertAlign",
7627
+ xform: new StringXform({
7628
+ tag: "vertAlign",
7582
7629
  attr: "val"
7583
7630
  })
7584
7631
  }
7585
- };
7586
- this.map[this.options.fontNameTag] = {
7587
- prop: "name",
7588
- xform: new StringXform({
7589
- tag: this.options.fontNameTag,
7590
- attr: "val"
7591
- })
7592
- };
7632
+ ];
7633
+ this.map = Object.fromEntries(fontProperties.map((p) => [p.tag, {
7634
+ prop: p.prop,
7635
+ xform: p.xform
7636
+ }]));
7637
+ this.renderOrder = fontProperties.map((p) => p.tag);
7593
7638
  }
7594
7639
  get tag() {
7595
7640
  return this.options.tagName;
7596
7641
  }
7597
7642
  render(xmlStream, model) {
7598
- const { map } = this;
7643
+ const { map, renderOrder } = this;
7599
7644
  xmlStream.openNode(this.options.tagName);
7600
- Object.entries(this.map).forEach(([tag, defn]) => {
7601
- map[tag].xform.render(xmlStream, model[defn.prop]);
7645
+ renderOrder.forEach((tag) => {
7646
+ map[tag].xform.render(xmlStream, model[map[tag].prop]);
7602
7647
  });
7603
7648
  xmlStream.closeNode();
7604
7649
  }
@@ -9677,10 +9722,6 @@ var ContentTypesXform = class ContentTypesXform extends BaseXform {
9677
9722
  PartName: `/xl/pivotCache/pivotCacheRecords${n}.xml`,
9678
9723
  ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml"
9679
9724
  });
9680
- xmlStream.leafNode("Override", {
9681
- PartName: `/xl/pivotTables/pivotTable${n}.xml`,
9682
- ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"
9683
- });
9684
9725
  });
9685
9726
  xmlStream.leafNode("Override", {
9686
9727
  PartName: "/xl/theme/theme1.xml",
@@ -9700,13 +9741,20 @@ var ContentTypesXform = class ContentTypesXform extends BaseXform {
9700
9741
  ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"
9701
9742
  });
9702
9743
  });
9744
+ if ((model.pivotTables || []).length) (model.pivotTables || []).forEach((pivotTable) => {
9745
+ const n = pivotTable.tableNumber;
9746
+ xmlStream.leafNode("Override", {
9747
+ PartName: `/xl/pivotTables/pivotTable${n}.xml`,
9748
+ ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"
9749
+ });
9750
+ });
9703
9751
  if (model.drawings) model.drawings.forEach((drawing) => {
9704
9752
  xmlStream.leafNode("Override", {
9705
9753
  PartName: `/xl/drawings/${drawing.name}.xml`,
9706
9754
  ContentType: "application/vnd.openxmlformats-officedocument.drawing+xml"
9707
9755
  });
9708
9756
  });
9709
- if (model.commentRefs) {
9757
+ if (model.commentRefs && model.commentRefs.length) {
9710
9758
  xmlStream.leafNode("Default", {
9711
9759
  Extension: "vml",
9712
9760
  ContentType: "application/vnd.openxmlformats-officedocument.vmlDrawing"
@@ -9955,9 +10003,9 @@ function extractRanges(parsedText) {
9955
10003
  var WorksheetXform = class extends BaseXform {
9956
10004
  render(xmlStream, model) {
9957
10005
  xmlStream.leafNode("sheet", {
9958
- sheetId: model.id,
9959
10006
  name: model.name,
9960
- state: model.state,
10007
+ sheetId: model.id,
10008
+ state: model.state === "visible" ? void 0 : model.state,
9961
10009
  "r:id": model.rId
9962
10010
  });
9963
10011
  }
@@ -10027,7 +10075,6 @@ var WorkbookPropertiesXform = class extends BaseXform {
10027
10075
  render(xmlStream, model) {
10028
10076
  xmlStream.leafNode("workbookPr", {
10029
10077
  date1904: model.date1904 ? 1 : void 0,
10030
- defaultThemeVersion: 164011,
10031
10078
  filterPrivacy: 1
10032
10079
  });
10033
10080
  }
@@ -10724,7 +10771,6 @@ var RowXform = class extends BaseXform {
10724
10771
  xmlStream.addAttribute("s", model.styleId);
10725
10772
  xmlStream.addAttribute("customFormat", "1");
10726
10773
  }
10727
- xmlStream.addAttribute("x14ac:dyDescent", "0.25");
10728
10774
  if (model.outlineLevel) xmlStream.addAttribute("outlineLevel", model.outlineLevel);
10729
10775
  if (model.collapsed) xmlStream.addAttribute("collapsed", "1");
10730
10776
  const cellXform = this.map.c;
@@ -11257,9 +11303,9 @@ var SheetFormatPropertiesXform = class extends BaseXform {
11257
11303
  if (model) {
11258
11304
  const attributes = {
11259
11305
  defaultRowHeight: model.defaultRowHeight,
11260
- outlineLevelRow: model.outlineLevelRow,
11261
- outlineLevelCol: model.outlineLevelCol,
11262
- "x14ac:dyDescent": model.dyDescent
11306
+ outlineLevelRow: model.outlineLevelRow || void 0,
11307
+ outlineLevelCol: model.outlineLevelCol || void 0,
11308
+ "x14ac:dyDescent": model.dyDescent || void 0
11263
11309
  };
11264
11310
  if (model.defaultColWidth) attributes.defaultColWidth = model.defaultColWidth;
11265
11311
  if (!model.defaultRowHeight || model.defaultRowHeight !== 15) attributes.customHeight = "1";
@@ -11306,12 +11352,14 @@ var SheetViewXform = class extends BaseXform {
11306
11352
  }
11307
11353
  }
11308
11354
  render(xmlStream, model) {
11309
- xmlStream.openNode("sheetView", { workbookViewId: model.workbookViewId || 0 });
11355
+ const initialAttrs = {};
11356
+ if (model.tabSelected) initialAttrs.tabSelected = "1";
11357
+ initialAttrs.workbookViewId = model.workbookViewId || 0;
11358
+ xmlStream.openNode("sheetView", initialAttrs);
11310
11359
  const add = function(name, value, included) {
11311
11360
  if (included) xmlStream.addAttribute(name, value);
11312
11361
  };
11313
11362
  add("rightToLeft", "1", model.rightToLeft === true);
11314
- add("tabSelected", "1", model.tabSelected);
11315
11363
  add("showRuler", "0", model.showRuler === false);
11316
11364
  add("showRowColHeaders", "0", model.showRowColHeaders === false);
11317
11365
  add("showGridLines", "0", model.showGridLines === false);
@@ -11611,9 +11659,9 @@ var PageSetupXform = class extends BaseXform {
11611
11659
  draft: booleanToXml$1(model.draft),
11612
11660
  cellComments: cellCommentsToXml(model.cellComments),
11613
11661
  errors: errorsToXml(model.errors),
11614
- scale: model.scale,
11615
- fitToWidth: model.fitToWidth,
11616
- fitToHeight: model.fitToHeight,
11662
+ scale: model.scale !== 100 ? model.scale : void 0,
11663
+ fitToWidth: model.fitToWidth !== 1 ? model.fitToWidth : void 0,
11664
+ fitToHeight: model.fitToHeight !== 1 ? model.fitToHeight : void 0,
11617
11665
  firstPageNumber: model.firstPageNumber,
11618
11666
  useFirstPageNumber: booleanToXml$1(!!model.firstPageNumber),
11619
11667
  usePrinterDefaults: booleanToXml$1(model.usePrinterDefaults),
@@ -13005,8 +13053,8 @@ var WorkSheetXform = class WorkSheetXform extends BaseXform {
13005
13053
  xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
13006
13054
  "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
13007
13055
  "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
13008
- "mc:Ignorable": "x14ac",
13009
- "xmlns:x14ac": "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"
13056
+ "xmlns:x14ac": "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac",
13057
+ "mc:Ignorable": "x14ac"
13010
13058
  };
13011
13059
  }
13012
13060
  constructor(options) {
@@ -14273,7 +14321,7 @@ var TableColumnXform = class extends BaseXform {
14273
14321
  id: model.id.toString(),
14274
14322
  name: model.name,
14275
14323
  totalsRowLabel: model.totalsRowLabel,
14276
- totalsRowFunction: model.totalsRowFunction,
14324
+ totalsRowFunction: model.totalsRowFunction === "none" ? void 0 : model.totalsRowFunction,
14277
14325
  dxfId: model.dxfId
14278
14326
  });
14279
14327
  }
@@ -14379,8 +14427,7 @@ var TableXform = class TableXform extends BaseXform {
14379
14427
  displayName: model.displayName || model.name,
14380
14428
  ref: model.tableRef,
14381
14429
  totalsRowCount: model.totalsRow ? "1" : void 0,
14382
- totalsRowShown: model.totalsRow ? void 0 : "1",
14383
- headerRowCount: model.headerRow ? "1" : "0"
14430
+ headerRowCount: model.headerRow ? void 0 : "0"
14384
14431
  });
14385
14432
  this.map.autoFilter.render(xmlStream, model);
14386
14433
  this.map.tableColumns.render(xmlStream, model.columns);
@@ -14401,7 +14448,7 @@ var TableXform = class TableXform extends BaseXform {
14401
14448
  displayName: attributes.displayName || attributes.name,
14402
14449
  tableRef: attributes.ref,
14403
14450
  totalsRow: attributes.totalsRowCount === "1",
14404
- headerRow: attributes.headerRowCount === "1"
14451
+ headerRow: attributes.headerRowCount !== "0"
14405
14452
  };
14406
14453
  break;
14407
14454
  default:
@@ -14441,13 +14488,7 @@ var TableXform = class TableXform extends BaseXform {
14441
14488
  });
14442
14489
  }
14443
14490
  static {
14444
- this.TABLE_ATTRIBUTES = {
14445
- xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
14446
- "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
14447
- "mc:Ignorable": "xr xr3",
14448
- "xmlns:xr": "http://schemas.microsoft.com/office/spreadsheetml/2014/revision",
14449
- "xmlns:xr3": "http://schemas.microsoft.com/office/spreadsheetml/2016/revision3"
14450
- };
14491
+ this.TABLE_ATTRIBUTES = { xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main" };
14451
14492
  }
14452
14493
  };
14453
14494
 
@@ -14631,14 +14672,16 @@ var PivotCacheRecordsXform = class PivotCacheRecordsXform extends BaseXform {
14631
14672
  //#endregion
14632
14673
  //#region src/xlsx/xform/pivot-table/cache-field.ts
14633
14674
  var CacheField = class {
14634
- constructor({ name, sharedItems }) {
14675
+ constructor({ name, sharedItems, minValue, maxValue }) {
14635
14676
  this.name = name;
14636
14677
  this.sharedItems = sharedItems;
14678
+ this.minValue = minValue;
14679
+ this.maxValue = maxValue;
14637
14680
  }
14638
14681
  render() {
14639
14682
  const escapedName = xmlEncode(this.name);
14640
14683
  if (this.sharedItems === null) return `<cacheField name="${escapedName}" numFmtId="0">
14641
- <sharedItems containsSemiMixedTypes="0" containsString="0" containsNumber="1" containsInteger="1" />
14684
+ <sharedItems containsSemiMixedTypes="0" containsString="0" containsNumber="1" containsInteger="1"${this.minValue !== void 0 && this.maxValue !== void 0 ? ` minValue="${this.minValue}" maxValue="${this.maxValue}"` : ""} />
14642
14685
  </cacheField>`;
14643
14686
  return `<cacheField name="${escapedName}" numFmtId="0">
14644
14687
  <sharedItems count="${this.sharedItems.length}">
@@ -14793,8 +14836,6 @@ var PivotCacheDefinitionXform = class PivotCacheDefinitionXform extends BaseXfor
14793
14836
  ...PivotCacheDefinitionXform.PIVOT_CACHE_DEFINITION_ATTRIBUTES,
14794
14837
  "r:id": "rId1",
14795
14838
  refreshOnLoad: "1",
14796
- refreshedBy: "Author",
14797
- refreshedDate: "45125.026046874998",
14798
14839
  createdVersion: "8",
14799
14840
  refreshedVersion: "8",
14800
14841
  minRefreshableVersion: "3",
@@ -14821,8 +14862,6 @@ var PivotCacheDefinitionXform = class PivotCacheDefinitionXform extends BaseXfor
14821
14862
  ...PivotCacheDefinitionXform.PIVOT_CACHE_DEFINITION_ATTRIBUTES,
14822
14863
  "r:id": model.rId || "rId1",
14823
14864
  refreshOnLoad: model.refreshOnLoad || "1",
14824
- refreshedBy: model.refreshedBy || "Author",
14825
- refreshedDate: model.refreshedDate || "45125.026046874998",
14826
14865
  createdVersion: model.createdVersion || "8",
14827
14866
  refreshedVersion: model.refreshedVersion || "8",
14828
14867
  minRefreshableVersion: model.minRefreshableVersion || "3",
@@ -14852,8 +14891,6 @@ var PivotCacheDefinitionXform = class PivotCacheDefinitionXform extends BaseXfor
14852
14891
  cacheFields: [],
14853
14892
  rId: attributes["r:id"],
14854
14893
  refreshOnLoad: attributes.refreshOnLoad,
14855
- refreshedBy: attributes.refreshedBy,
14856
- refreshedDate: attributes.refreshedDate,
14857
14894
  createdVersion: attributes.createdVersion,
14858
14895
  refreshedVersion: attributes.refreshedVersion,
14859
14896
  minRefreshableVersion: attributes.minRefreshableVersion,
@@ -14908,10 +14945,7 @@ var PivotCacheDefinitionXform = class PivotCacheDefinitionXform extends BaseXfor
14908
14945
  static {
14909
14946
  this.PIVOT_CACHE_DEFINITION_ATTRIBUTES = {
14910
14947
  xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
14911
- "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
14912
- "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
14913
- "mc:Ignorable": "xr",
14914
- "xmlns:xr": "http://schemas.microsoft.com/office/spreadsheetml/2014/revision"
14948
+ "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
14915
14949
  };
14916
14950
  }
14917
14951
  };
@@ -14964,18 +14998,16 @@ var PivotTableXform = class PivotTableXform extends BaseXform {
14964
14998
  */
14965
14999
  renderNew(xmlStream, model) {
14966
15000
  const { rows, columns, values, cacheFields, cacheId, applyWidthHeightFormats } = model;
14967
- const uniqueUid = `{${crypto.randomUUID().toUpperCase()}}`;
14968
15001
  const rowItems = buildRowItems(rows, cacheFields);
14969
15002
  const colItems = buildColItems(columns, cacheFields, values.length);
14970
15003
  const rowFieldItemCount = rows.length > 0 ? cacheFields[rows[0]]?.sharedItems?.length || 0 : 0;
14971
15004
  const colFieldItemCount = columns.length > 0 ? cacheFields[columns[0]]?.sharedItems?.length || 0 : 0;
14972
- const endRow = 3 + rowFieldItemCount + 1;
15005
+ const endRow = 4 + rowFieldItemCount + 1;
14973
15006
  const endCol = 1 + colFieldItemCount + 1;
14974
15007
  const locationRef = `A3:${String.fromCharCode(64 + endCol)}${endRow}`;
14975
15008
  xmlStream.openXml(XmlStream.StdDocAttributes);
14976
15009
  xmlStream.openNode(this.tag, {
14977
15010
  ...PivotTableXform.PIVOT_TABLE_ATTRIBUTES,
14978
- "xr:uid": uniqueUid,
14979
15011
  name: "PivotTable2",
14980
15012
  cacheId,
14981
15013
  applyNumberFormats: "0",
@@ -15050,11 +15082,9 @@ var PivotTableXform = class PivotTableXform extends BaseXform {
15050
15082
  * Render loaded pivot table (preserving original structure)
15051
15083
  */
15052
15084
  renderLoaded(xmlStream, model) {
15053
- const uniqueUid = model.uid || `{${crypto.randomUUID().toUpperCase()}}`;
15054
15085
  xmlStream.openXml(XmlStream.StdDocAttributes);
15055
15086
  xmlStream.openNode(this.tag, {
15056
15087
  ...PivotTableXform.PIVOT_TABLE_ATTRIBUTES,
15057
- "xr:uid": uniqueUid,
15058
15088
  name: model.name || "PivotTable1",
15059
15089
  cacheId: model.cacheId,
15060
15090
  applyNumberFormats: model.applyNumberFormats || "0",
@@ -15303,19 +15333,15 @@ var PivotTableXform = class PivotTableXform extends BaseXform {
15303
15333
  }
15304
15334
  reconcile(_model, _options) {}
15305
15335
  static {
15306
- this.PIVOT_TABLE_ATTRIBUTES = {
15307
- xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
15308
- "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
15309
- "mc:Ignorable": "xr",
15310
- "xmlns:xr": "http://schemas.microsoft.com/office/spreadsheetml/2014/revision"
15311
- };
15336
+ this.PIVOT_TABLE_ATTRIBUTES = { xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main" };
15312
15337
  }
15313
15338
  };
15314
15339
  /**
15315
15340
  * Build rowItems XML - one item for each unique value in row fields, plus grand total.
15316
15341
  * Each <i> represents a row in the pivot table.
15317
- * - Regular items: <i><x v="index"/></i> where index is the position in sharedItems
15342
+ * - Regular items: <i><x/></i> for index 0, <i><x v="index"/></i> for index > 0
15318
15343
  * - Grand total: <i t="grand"><x/></i>
15344
+ * Note: When v=0, the v attribute should be omitted (Excel convention)
15319
15345
  */
15320
15346
  function buildRowItems(rows, cacheFields) {
15321
15347
  if (rows.length === 0) return {
@@ -15324,7 +15350,8 @@ function buildRowItems(rows, cacheFields) {
15324
15350
  };
15325
15351
  const itemCount = (cacheFields[rows[0]]?.sharedItems || []).length;
15326
15352
  const items = [];
15327
- for (let i = 0; i < itemCount; i++) items.push(`<i><x v="${i}" /></i>`);
15353
+ for (let i = 0; i < itemCount; i++) if (i === 0) items.push("<i><x /></i>");
15354
+ else items.push(`<i><x v="${i}" /></i>`);
15328
15355
  items.push("<i t=\"grand\"><x /></i>");
15329
15356
  return {
15330
15357
  count: items.length,
@@ -15334,12 +15361,14 @@ function buildRowItems(rows, cacheFields) {
15334
15361
  /**
15335
15362
  * Build colItems XML - one item for each unique value in column fields, plus grand total.
15336
15363
  * When there are multiple data fields (values), each column value may have sub-columns.
15364
+ * Note: When v=0, the v attribute should be omitted (Excel convention)
15337
15365
  */
15338
15366
  function buildColItems(columns, cacheFields, valueCount) {
15339
15367
  if (columns.length === 0) {
15340
15368
  if (valueCount > 1) {
15341
15369
  const items$1 = [];
15342
- for (let i = 0; i < valueCount; i++) items$1.push(`<i><x v="${i}" /></i>`);
15370
+ for (let i = 0; i < valueCount; i++) if (i === 0) items$1.push("<i><x /></i>");
15371
+ else items$1.push(`<i><x v="${i}" /></i>`);
15343
15372
  items$1.push("<i t=\"grand\"><x /></i>");
15344
15373
  return {
15345
15374
  count: items$1.length,
@@ -15353,7 +15382,8 @@ function buildColItems(columns, cacheFields, valueCount) {
15353
15382
  }
15354
15383
  const itemCount = (cacheFields[columns[0]]?.sharedItems || []).length;
15355
15384
  const items = [];
15356
- for (let i = 0; i < itemCount; i++) items.push(`<i><x v="${i}" /></i>`);
15385
+ for (let i = 0; i < itemCount; i++) if (i === 0) items.push("<i><x /></i>");
15386
+ else items.push(`<i><x v="${i}" /></i>`);
15357
15387
  items.push("<i t=\"grand\"><x /></i>");
15358
15388
  return {
15359
15389
  count: items.length,
@@ -15383,12 +15413,12 @@ function renderPivotFields(pivotTable) {
15383
15413
  }).join("");
15384
15414
  }
15385
15415
  function renderPivotField(fieldType, sharedItems) {
15386
- const defaultAttributes = "compact=\"0\" outline=\"0\" showAll=\"0\" defaultSubtotal=\"0\"";
15387
15416
  if (fieldType === "row" || fieldType === "column") {
15388
15417
  const axis = fieldType === "row" ? "axisRow" : "axisCol";
15418
+ const axisAttributes = "compact=\"0\" outline=\"0\" showAll=\"0\"";
15389
15419
  const itemsXml = [...sharedItems.map((_item, index) => `<item x="${index}" />`), "<item t=\"default\" />"].join("\n ");
15390
15420
  return `
15391
- <pivotField axis="${axis}" ${defaultAttributes}>
15421
+ <pivotField axis="${axis}" ${axisAttributes}>
15392
15422
  <items count="${sharedItems.length + 1}">
15393
15423
  ${itemsXml}
15394
15424
  </items>
@@ -15398,7 +15428,7 @@ function renderPivotField(fieldType, sharedItems) {
15398
15428
  return `
15399
15429
  <pivotField
15400
15430
  ${fieldType === "value" ? "dataField=\"1\"" : ""}
15401
- ${defaultAttributes}
15431
+ compact="0" outline="0" showAll="0" defaultSubtotal="0"
15402
15432
  />
15403
15433
  `;
15404
15434
  }