@cj-tech-master/excelts 6.1.0 → 6.1.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.
Files changed (36) hide show
  1. package/dist/browser/modules/csv/worker/worker-script.generated.d.ts +1 -1
  2. package/dist/browser/modules/csv/worker/worker-script.generated.js +1 -1
  3. package/dist/browser/modules/excel/stream/sheet-rels-writer.d.ts +2 -1
  4. package/dist/browser/modules/excel/stream/sheet-rels-writer.js +10 -1
  5. package/dist/browser/modules/excel/stream/workbook-writer.browser.js +2 -1
  6. package/dist/browser/modules/excel/stream/worksheet-reader.d.ts +2 -1
  7. package/dist/browser/modules/excel/stream/worksheet-reader.js +4 -1
  8. package/dist/browser/modules/excel/workbook.browser.js +2 -1
  9. package/dist/browser/modules/excel/worksheet.js +2 -1
  10. package/dist/browser/modules/excel/xlsx/xform/sheet/hyperlink-xform.d.ts +8 -3
  11. package/dist/browser/modules/excel/xlsx/xform/sheet/hyperlink-xform.js +20 -10
  12. package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +11 -1
  13. package/dist/cjs/modules/csv/worker/worker-script.generated.js +1 -1
  14. package/dist/cjs/modules/excel/stream/sheet-rels-writer.js +10 -1
  15. package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +2 -1
  16. package/dist/cjs/modules/excel/stream/worksheet-reader.js +4 -1
  17. package/dist/cjs/modules/excel/workbook.browser.js +2 -1
  18. package/dist/cjs/modules/excel/worksheet.js +2 -1
  19. package/dist/cjs/modules/excel/xlsx/xform/sheet/hyperlink-xform.js +20 -9
  20. package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +11 -1
  21. package/dist/esm/modules/csv/worker/worker-script.generated.js +1 -1
  22. package/dist/esm/modules/excel/stream/sheet-rels-writer.js +10 -1
  23. package/dist/esm/modules/excel/stream/workbook-writer.browser.js +2 -1
  24. package/dist/esm/modules/excel/stream/worksheet-reader.js +4 -1
  25. package/dist/esm/modules/excel/workbook.browser.js +2 -1
  26. package/dist/esm/modules/excel/worksheet.js +2 -1
  27. package/dist/esm/modules/excel/xlsx/xform/sheet/hyperlink-xform.js +20 -10
  28. package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +11 -1
  29. package/dist/iife/excelts.iife.js +77 -72
  30. package/dist/iife/excelts.iife.js.map +1 -1
  31. package/dist/iife/excelts.iife.min.js +34 -34
  32. package/dist/types/modules/csv/worker/worker-script.generated.d.ts +1 -1
  33. package/dist/types/modules/excel/stream/sheet-rels-writer.d.ts +2 -1
  34. package/dist/types/modules/excel/stream/worksheet-reader.d.ts +2 -1
  35. package/dist/types/modules/excel/xlsx/xform/sheet/hyperlink-xform.d.ts +8 -3
  36. package/package.json +13 -13
@@ -141,7 +141,8 @@ class Worksheet {
141
141
  }
142
142
  name = name.substring(0, 31);
143
143
  }
144
- if (this._workbook.worksheets.find(ws => ws && ws.name.toLowerCase() === name.toLowerCase())) {
144
+ const nameLower = name.toLowerCase();
145
+ if (this._workbook.worksheets.find(ws => ws && ws !== this && ws.name.toLowerCase() === nameLower)) {
145
146
  throw new errors_1.WorksheetNameError(`Worksheet name already exists: ${name}`);
146
147
  }
147
148
  this._name = name;
@@ -1,21 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HyperlinkXform = void 0;
4
+ exports.isInternalLink = isInternalLink;
4
5
  const base_xform_1 = require("../base-xform.js");
5
6
  class HyperlinkXform extends base_xform_1.BaseXform {
6
7
  get tag() {
7
8
  return "hyperlink";
8
9
  }
9
10
  render(xmlStream, model) {
10
- if (this.isInternalLink(model)) {
11
+ if (model.target && isInternalLink(model.target)) {
12
+ // Internal link: use location attribute only (no relationship)
13
+ // Strip the leading "#" — OOXML location attribute is without "#"
11
14
  xmlStream.leafNode("hyperlink", {
12
15
  ref: model.address,
13
- "r:id": model.rId,
14
16
  tooltip: model.tooltip,
15
- location: model.target
17
+ location: model.target.slice(1)
16
18
  });
17
19
  }
18
20
  else {
21
+ // External link: use r:id relationship reference
19
22
  xmlStream.leafNode("hyperlink", {
20
23
  ref: model.address,
21
24
  "r:id": model.rId,
@@ -30,9 +33,13 @@ class HyperlinkXform extends base_xform_1.BaseXform {
30
33
  rId: node.attributes["r:id"],
31
34
  tooltip: node.attributes.tooltip
32
35
  };
33
- // This is an internal link
36
+ // Internal link: location attribute stores the target without "#"
37
+ // Normalize: always store as "#Location" in the model regardless of
38
+ // whether the source had a leading "#" (our old buggy output) or not
39
+ // (correct OOXML from Excel or the fixed writer).
34
40
  if (node.attributes.location) {
35
- this.model.target = node.attributes.location;
41
+ const loc = node.attributes.location;
42
+ this.model.target = loc.startsWith("#") ? loc : `#${loc}`;
36
43
  }
37
44
  return true;
38
45
  }
@@ -42,9 +49,13 @@ class HyperlinkXform extends base_xform_1.BaseXform {
42
49
  parseClose() {
43
50
  return false;
44
51
  }
45
- isInternalLink(model) {
46
- // @example: Sheet2!D3, return true
47
- return !!(model.target && /^[^!]+![a-zA-Z]+[\d]+$/.test(model.target));
48
- }
49
52
  }
50
53
  exports.HyperlinkXform = HyperlinkXform;
54
+ /**
55
+ * Internal hyperlinks start with "#" (e.g. "#Sheet2!A1").
56
+ * This matches Excel's convention and the OOXML spec where internal links
57
+ * use the `location` attribute instead of a relationship.
58
+ */
59
+ function isInternalLink(target) {
60
+ return target.startsWith("#");
61
+ }
@@ -6,11 +6,11 @@ const xml_stream_1 = require("../../../utils/xml-stream.js");
6
6
  const rel_type_1 = require("../../rel-type.js");
7
7
  const merges_1 = require("./merges.js");
8
8
  const base_xform_1 = require("../base-xform.js");
9
+ const hyperlink_xform_1 = require("./hyperlink-xform.js");
9
10
  const list_xform_1 = require("../list-xform.js");
10
11
  const row_xform_1 = require("./row-xform.js");
11
12
  const col_xform_1 = require("./col-xform.js");
12
13
  const dimension_xform_1 = require("./dimension-xform.js");
13
- const hyperlink_xform_1 = require("./hyperlink-xform.js");
14
14
  const merge_cell_xform_1 = require("./merge-cell-xform.js");
15
15
  const data_validations_xform_1 = require("./data-validations-xform.js");
16
16
  const sheet_properties_xform_1 = require("./sheet-properties-xform.js");
@@ -161,6 +161,11 @@ class WorkSheetXform extends base_xform_1.BaseXform {
161
161
  return `rId${r.length + 1}`;
162
162
  }
163
163
  model.hyperlinks.forEach(hyperlink => {
164
+ // Internal links (e.g. "#Sheet2!A1") use the location attribute only,
165
+ // no relationship is needed in the .rels file.
166
+ if ((0, hyperlink_xform_1.isInternalLink)(hyperlink.target)) {
167
+ return;
168
+ }
164
169
  const rId = nextRid(rels);
165
170
  hyperlink.rId = rId;
166
171
  rels.push({
@@ -597,8 +602,13 @@ class WorkSheetXform extends base_xform_1.BaseXform {
597
602
  }, {});
598
603
  options.hyperlinkMap = (model.hyperlinks ?? []).reduce((h, hyperlink) => {
599
604
  if (hyperlink.rId) {
605
+ // External link: resolve target from relationship
600
606
  h[hyperlink.address] = rels[hyperlink.rId].Target;
601
607
  }
608
+ else if (hyperlink.target) {
609
+ // Internal link: target was restored from location attribute (with "#" prefix)
610
+ h[hyperlink.address] = hyperlink.target;
611
+ }
602
612
  return h;
603
613
  }, {});
604
614
  options.formulae = {};