@office-open/xlsx 0.6.7 → 0.6.9

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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { AppProperties, BaseXmlComponent, ChartCollection, ChartSpace, Formatter, IgnoreIfEmptyXmlComponent, OoxmlMimeType, Relationships, buildCorePropertiesXml, buildCorePropertiesXmlString, compileMapping, createPacker, parseArchive, parseCorePropsElement, strFromU8, toJson, unzipSync, zipAndConvert } from "@office-open/core";
1
+ import { AppProperties, BaseXmlComponent, ChartCollection, ChartSpace, Formatter, IgnoreIfEmptyXmlComponent, OoxmlMimeType, Relationships, buildCorePropertiesXmlString, compileMapping, createPacker, parseArchive, parseCorePropsElement, strFromU8, toJson, unzipSync, zipAndConvert } from "@office-open/core";
2
2
  import { attr, attrNum, attrs, escapeXml, findChild, js2xml, selfCloseElement, textOf } from "@office-open/xml";
3
3
  import { toUint8Array } from "undio";
4
4
  //#region src/file/content-types.ts
@@ -13,7 +13,7 @@ const XLSX_STYLES = "application/vnd.openxmlformats-officedocument.spreadsheetml
13
13
  const XLSX_SHARED_STRINGS = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml";
14
14
  const XLSX_THEME = "application/vnd.openxmlformats-officedocument.theme+xml";
15
15
  const XLSX_CHART = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
16
- const STATIC_ENTRIES = [
16
+ const STATIC_XML = [
17
17
  {
18
18
  type: "Default",
19
19
  contentType: "application/vnd.openxmlformats-package.relationships+xml",
@@ -39,18 +39,7 @@ const STATIC_ENTRIES = [
39
39
  contentType: "application/vnd.openxmlformats-officedocument.extended-properties+xml",
40
40
  key: "/docProps/app.xml"
41
41
  }
42
- ];
43
- const STATIC_CHILDREN = [{ _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/content-types" } }, ...STATIC_ENTRIES.map((e) => {
44
- if (e.type === "Default") return { Default: { _attr: {
45
- ContentType: e.contentType,
46
- Extension: e.key
47
- } } };
48
- return { Override: { _attr: {
49
- ContentType: e.contentType,
50
- PartName: e.key
51
- } } };
52
- })];
53
- const STATIC_XML = STATIC_ENTRIES.map((e) => e.type === "Default" ? `<Default ContentType="${e.contentType}" Extension="${e.key}"/>` : `<Override ContentType="${e.contentType}" PartName="${e.key}"/>`).join("");
42
+ ].map((e) => e.type === "Default" ? `<Default ContentType="${e.contentType}" Extension="${e.key}"/>` : `<Override ContentType="${e.contentType}" PartName="${e.key}"/>`).join("");
54
43
  var ContentTypes = class extends BaseXmlComponent {
55
44
  dynamicEntries = [];
56
45
  constructor() {
@@ -107,18 +96,6 @@ var ContentTypes = class extends BaseXmlComponent {
107
96
  key: extension
108
97
  });
109
98
  }
110
- prepForXml(_context) {
111
- const children = [...STATIC_CHILDREN];
112
- for (const e of this.dynamicEntries) if (e.type === "Default") children.push({ Default: { _attr: {
113
- ContentType: e.contentType,
114
- Extension: e.key
115
- } } });
116
- else children.push({ Override: { _attr: {
117
- ContentType: e.contentType,
118
- PartName: e.key
119
- } } });
120
- return { Types: children };
121
- }
122
99
  toXml(_context) {
123
100
  const p = ["<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">", STATIC_XML];
124
101
  for (const e of this.dynamicEntries) if (e.type === "Default") p.push(`<Default ContentType="${e.contentType}" Extension="${e.key}"/>`);
@@ -140,9 +117,6 @@ var CoreProperties = class extends BaseXmlComponent {
140
117
  super("cp:coreProperties");
141
118
  this.options = options;
142
119
  }
143
- prepForXml(_context) {
144
- return buildCorePropertiesXml(this.options);
145
- }
146
120
  toXml(_context) {
147
121
  return buildCorePropertiesXmlString(this.options);
148
122
  }
@@ -199,15 +173,6 @@ var SharedStrings = class extends BaseXmlComponent {
199
173
  p.push("</sst>");
200
174
  return p.join("");
201
175
  }
202
- prepForXml(_context) {
203
- const children = [{ _attr: {
204
- xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
205
- count: this.strings.length,
206
- uniqueCount: this.indexMap.size
207
- } }];
208
- for (const s of this.strings) children.push({ si: [{ t: [s] }] });
209
- return { sst: children };
210
- }
211
176
  };
212
177
  //#endregion
213
178
  //#region src/file/styles.ts
@@ -435,112 +400,6 @@ var Styles = class extends BaseXmlComponent {
435
400
  if (a.indent !== void 0) aAttrs.indent = a.indent;
436
401
  return `<alignment${attrs(aAttrs)}/>`;
437
402
  }
438
- prepForXml(_context) {
439
- const children = [{ _attr: { xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main" } }];
440
- if (this.customNumFmts.size > 0) {
441
- const fmtElements = [{ _attr: { count: this.customNumFmts.size } }];
442
- for (const [fmt, id] of this.customNumFmts) fmtElements.push({ numFmt: { _attr: {
443
- numFmtId: id,
444
- formatCode: fmt
445
- } } });
446
- children.push({ numFmts: fmtElements });
447
- }
448
- children.push(this.buildFonts());
449
- children.push(this.buildFills());
450
- children.push(this.buildBorders());
451
- children.push({ cellStyleXfs: [{ _attr: { count: 1 } }, { xf: [{ _attr: {
452
- numFmtId: 0,
453
- fontId: 0,
454
- fillId: 0,
455
- borderId: 0
456
- } }] }] });
457
- children.push(this.buildCellXfs());
458
- children.push({ cellStyles: [{ _attr: { count: 1 } }, { cellStyle: [{ _attr: {
459
- name: "Normal",
460
- xfId: 0,
461
- builtinId: 0
462
- } }] }] });
463
- children.push({ dxfs: { _attr: { count: 0 } } });
464
- children.push({ tableStyles: { _attr: {
465
- count: 0,
466
- defaultTableStyle: "TableStyleMedium2",
467
- defaultPivotStyle: "PivotStyleLight16"
468
- } } });
469
- children.push({ extLst: [] });
470
- return { styleSheet: children };
471
- }
472
- buildFonts() {
473
- const elements = [{ _attr: { count: this.fonts.length } }];
474
- for (const f of this.fonts) elements.push({ font: this.fontXml(f) });
475
- return { fonts: elements };
476
- }
477
- fontXml(f) {
478
- const parts = [];
479
- if (f.bold) parts.push({ b: [] });
480
- if (f.italic) parts.push({ i: [] });
481
- if (f.underline) parts.push({ u: [] });
482
- if (f.strike) parts.push({ strike: [] });
483
- if (f.size) parts.push({ sz: [{ _attr: { val: f.size } }] });
484
- if (f.color) parts.push({ color: [{ _attr: { rgb: `FF${f.color}` } }] });
485
- if (f.fontName) parts.push({ name: [{ _attr: { val: f.fontName } }] });
486
- return parts;
487
- }
488
- buildFills() {
489
- const elements = [{ _attr: { count: this.fills.length } }];
490
- for (const f of this.fills) elements.push({ fill: [{ patternFill: [{ _attr: { patternType: f.patternType ?? "solid" } }, ...f.color ? [{ fgColor: [{ _attr: { rgb: `FF${f.color}` } }] }] : []] }] });
491
- return { fills: elements };
492
- }
493
- buildBorders() {
494
- const elements = [{ _attr: { count: this.borders.length } }];
495
- for (const b of this.borders) elements.push({ border: this.borderXml(b) });
496
- return { borders: elements };
497
- }
498
- borderXml(b) {
499
- const parts = [];
500
- for (const side of [
501
- "left",
502
- "right",
503
- "top",
504
- "bottom",
505
- "diagonal"
506
- ]) {
507
- const opts = b[side];
508
- if (opts && opts.style && opts.style !== "none") {
509
- const children = [{ _attr: { style: opts.style } }];
510
- if (opts.color) children.push({ color: [{ _attr: { rgb: `FF${opts.color}` } }] });
511
- parts.push({ [side]: children });
512
- } else parts.push({ [side]: [] });
513
- }
514
- return parts;
515
- }
516
- buildCellXfs() {
517
- const elements = [{ _attr: { count: this.cellXfs.length } }];
518
- for (const xf of this.cellXfs) {
519
- const attrs = {
520
- numFmtId: xf.numFmtId,
521
- fontId: xf.fontId,
522
- fillId: xf.fillId,
523
- borderId: xf.borderId
524
- };
525
- if (xf.alignment) attrs.applyAlignment = 1;
526
- if (xf.fontId > 0) attrs.applyFont = 1;
527
- if (xf.fillId > 0) attrs.applyFill = 1;
528
- if (xf.borderId > 0) attrs.applyBorder = 1;
529
- const children = [{ _attr: attrs }];
530
- if (xf.alignment) children.push(this.alignmentXml(xf.alignment));
531
- elements.push({ xf: children });
532
- }
533
- return { cellXfs: elements };
534
- }
535
- alignmentXml(a) {
536
- const attrs = {};
537
- if (a.horizontal) attrs.horizontal = a.horizontal;
538
- if (a.vertical) attrs.vertical = a.vertical;
539
- if (a.wrapText) attrs.wrapText = 1;
540
- if (a.textRotation !== void 0) attrs.textRotation = a.textRotation;
541
- if (a.indent !== void 0) attrs.indent = a.indent;
542
- return { alignment: [{ _attr: attrs }] };
543
- }
544
403
  };
545
404
  //#endregion
546
405
  //#region src/file/theme.ts
@@ -563,12 +422,6 @@ var DefaultTheme = class extends BaseXmlComponent {
563
422
  toXml(_context) {
564
423
  return THEME_XML;
565
424
  }
566
- prepForXml(_context) {
567
- return { "a:theme": [{ _attr: {
568
- "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
569
- name: "Office Theme"
570
- } }] };
571
- }
572
425
  };
573
426
  //#endregion
574
427
  //#region src/file/workbook.ts
@@ -583,32 +436,6 @@ var WorkbookXml = class extends BaseXmlComponent {
583
436
  super("workbook");
584
437
  this.sheets = sheets;
585
438
  }
586
- prepForXml(_context) {
587
- const sheetElements = [];
588
- for (const s of this.sheets) {
589
- const attrs = {
590
- name: s.name,
591
- sheetId: String(s.sheetId),
592
- "r:id": s.rId
593
- };
594
- if (s.state && s.state !== "visible") attrs.state = s.state;
595
- sheetElements.push({ sheet: { _attr: attrs } });
596
- }
597
- return { workbook: [
598
- { _attr: {
599
- xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
600
- "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
601
- } },
602
- { bookViews: [{ workbookView: { _attr: {
603
- xWindow: 0,
604
- yWindow: 0,
605
- windowWidth: 28800,
606
- windowHeight: 12300
607
- } } }] },
608
- { sheets: sheetElements },
609
- { calcPr: { _attr: { calcId: 191029 } } }
610
- ] };
611
- }
612
439
  toXml(_context) {
613
440
  const p = [
614
441
  "<workbook xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">",
@@ -630,6 +457,12 @@ var WorkbookXml = class extends BaseXmlComponent {
630
457
  *
631
458
  * @module
632
459
  */
460
+ /** Cell formula type (maps to ST_CellFormulaType). */
461
+ const FormulaType = {
462
+ NORMAL: "normal",
463
+ ARRAY: "array",
464
+ SHARED: "shared"
465
+ };
633
466
  var Worksheet = class extends IgnoreIfEmptyXmlComponent {
634
467
  rows;
635
468
  columns;
@@ -658,135 +491,6 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
658
491
  get charts() {
659
492
  return this.chartOptions;
660
493
  }
661
- prepForXml(context) {
662
- const fileData = context.fileData;
663
- const sharedStrings = fileData?.sharedStrings;
664
- const styles = fileData?.styles;
665
- const children = [{ _attr: {
666
- xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
667
- "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
668
- } }];
669
- const maxRow = this.rows.length;
670
- let maxCol = 0;
671
- for (const row of this.rows) if (row.cells && row.cells.length > maxCol) maxCol = row.cells.length;
672
- if (maxRow > 0 && maxCol > 0) {
673
- const dimRef = `A1:${this.defaultCellRef(maxRow, maxCol)}`;
674
- children.push({ dimension: { _attr: { ref: dimRef } } });
675
- }
676
- if (this.freezePanes) {
677
- const fp = this.freezePanes;
678
- const ySplit = fp.row ? fp.row : 0;
679
- const xSplit = fp.col ? fp.col : 0;
680
- const topRow = fp.row ? fp.row + 1 : 1;
681
- const leftCol = fp.col ? fp.col + 1 : 1;
682
- const attr = {
683
- ySplit,
684
- xSplit,
685
- topLeftCell: this.defaultCellRef(topRow, leftCol),
686
- activePane: ySplit > 0 && xSplit > 0 ? "bottomRight" : ySplit > 0 ? "bottomLeft" : "topRight",
687
- state: "frozen"
688
- };
689
- children.push({ sheetViews: [{ sheetView: [{ _attr: {
690
- tabSelected: 1,
691
- workbookViewId: 0
692
- } }, { pane: { _attr: attr } }] }] });
693
- } else children.push({ sheetViews: [{ sheetView: [{ _attr: {
694
- tabSelected: 1,
695
- workbookViewId: 0
696
- } }] }] });
697
- children.push({ sheetFormatPr: { _attr: { defaultRowHeight: 15 } } });
698
- if (this.columns.length > 0) {
699
- const colElements = [];
700
- for (const col of this.columns) {
701
- const colAttrs = {
702
- min: col.min,
703
- max: col.max
704
- };
705
- if (col.width !== void 0) {
706
- colAttrs.width = col.width;
707
- colAttrs.customWidth = 1;
708
- }
709
- if (col.hidden) colAttrs.hidden = 1;
710
- colElements.push({ col: { _attr: colAttrs } });
711
- }
712
- children.push({ cols: colElements });
713
- }
714
- const sheetDataChildren = [];
715
- for (let i = 0; i < this.rows.length; i++) {
716
- const rowOpts = this.rows[i];
717
- const rowNumber = rowOpts.rowNumber ?? i + 1;
718
- const rowAttrs = { r: rowNumber };
719
- if (rowOpts.height !== void 0) {
720
- rowAttrs.ht = rowOpts.height;
721
- rowAttrs.customHeight = 1;
722
- }
723
- if (rowOpts.hidden) rowAttrs.hidden = 1;
724
- const cellElements = [];
725
- if (rowOpts.cells) for (let j = 0; j < rowOpts.cells.length; j++) {
726
- const cell = rowOpts.cells[j];
727
- const ref = cell.reference ?? this.defaultCellRef(rowNumber, j + 1);
728
- const cellObj = this.buildCell(ref, cell, sharedStrings, styles);
729
- if (cellObj) cellElements.push(cellObj);
730
- }
731
- sheetDataChildren.push({ row: [{ _attr: rowAttrs }, ...cellElements] });
732
- }
733
- children.push({ sheetData: sheetDataChildren });
734
- if (this.autoFilter) children.push({ autoFilter: { _attr: { ref: this.autoFilter } } });
735
- if (this.mergeCells.length > 0) {
736
- const mergeElements = [{ _attr: { count: this.mergeCells.length } }];
737
- for (const mc of this.mergeCells) {
738
- const fromRef = this.defaultCellRef(mc.from.row, mc.from.col);
739
- const toRef = this.defaultCellRef(mc.to.row, mc.to.col);
740
- mergeElements.push({ mergeCell: { _attr: { ref: `${fromRef}:${toRef}` } } });
741
- }
742
- children.push({ mergeCells: mergeElements });
743
- }
744
- if (this.conditionalFormats.length > 0) for (const cf of this.conditionalFormats) {
745
- const rules = [];
746
- for (let ri = 0; ri < cf.rules.length; ri++) {
747
- const rule = cf.rules[ri];
748
- const ruleAttrs = {
749
- type: rule.type,
750
- priority: rule.priority ?? ri + 1
751
- };
752
- if (rule.operator) ruleAttrs.operator = rule.operator;
753
- if (rule.dxfId !== void 0) ruleAttrs.dxfId = rule.dxfId;
754
- const ruleChildren = [{ _attr: ruleAttrs }];
755
- if (rule.formulas) for (const f of rule.formulas) ruleChildren.push({ formula: [f] });
756
- rules.push({ cfRule: ruleChildren });
757
- }
758
- children.push({ conditionalFormatting: [{ _attr: { sqref: cf.sqref } }, ...rules] });
759
- }
760
- if (this.dataValidations.length > 0) {
761
- const dvElements = [{ _attr: { count: this.dataValidations.length } }];
762
- for (const dv of this.dataValidations) {
763
- const dvAttrs = { sqref: dv.sqref };
764
- if (dv.type && dv.type !== "none") dvAttrs.type = dv.type;
765
- if (dv.operator) dvAttrs.operator = dv.operator;
766
- if (dv.allowBlank) dvAttrs.allowBlank = 1;
767
- if (dv.showErrorMessage) dvAttrs.showErrorMessage = 1;
768
- if (dv.showInputMessage) dvAttrs.showInputMessage = 1;
769
- if (dv.errorTitle) dvAttrs.errorTitle = dv.errorTitle;
770
- if (dv.error) dvAttrs.error = dv.error;
771
- if (dv.promptTitle) dvAttrs.promptTitle = dv.promptTitle;
772
- if (dv.prompt) dvAttrs.prompt = dv.prompt;
773
- const dvChildren = [{ _attr: dvAttrs }];
774
- if (dv.formula1 !== void 0) dvChildren.push({ formula1: [dv.formula1] });
775
- if (dv.formula2 !== void 0) dvChildren.push({ formula2: [dv.formula2] });
776
- dvElements.push({ dataValidation: dvChildren });
777
- }
778
- children.push({ dataValidations: dvElements });
779
- }
780
- children.push({ pageMargins: { _attr: {
781
- left: .75,
782
- right: .75,
783
- top: 1,
784
- bottom: 1,
785
- header: .5,
786
- footer: .5
787
- } } });
788
- return { worksheet: children };
789
- }
790
494
  /**
791
495
  * Zero-allocation fast path: directly concatenate XML string.
792
496
  * Bypasses the IXmlableObject intermediate tree entirely.
@@ -905,6 +609,18 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
905
609
  return p.join("");
906
610
  }
907
611
  /**
612
+ * Build the <f> element string for a cell formula.
613
+ */
614
+ buildFormulaString(fOpts) {
615
+ const fAttrs = {};
616
+ if (fOpts.type && fOpts.type !== FormulaType.NORMAL) fAttrs.t = fOpts.type;
617
+ if (fOpts.reference) fAttrs.ref = fOpts.reference;
618
+ if (fOpts.sharedIndex !== void 0) fAttrs.si = fOpts.sharedIndex;
619
+ if (fOpts.formula !== void 0 && fOpts.formula !== "") return `<f${attrs(fAttrs)}>${escapeXml(fOpts.formula)}</f>`;
620
+ if (Object.keys(fAttrs).length > 0) return selfCloseElement("f", attrs(fAttrs));
621
+ return "";
622
+ }
623
+ /**
908
624
  * Direct string serialization of a single cell — zero intermediate objects.
909
625
  */
910
626
  buildCellString(ref, cell, sharedStrings, styles) {
@@ -912,6 +628,21 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
912
628
  if (cell.style !== void 0 && styles) cellAttrs.s = styles.register(cell.style);
913
629
  else if (cell.styleIndex !== void 0) cellAttrs.s = cell.styleIndex;
914
630
  const value = cell.value;
631
+ if (cell.formula) {
632
+ const fStr = this.buildFormulaString(cell.formula);
633
+ let vStr = "";
634
+ if (value === null || value === void 0) return `<c${attrs(cellAttrs)}>${fStr}</c>`;
635
+ if (typeof value === "number") vStr = `<v>${value}</v>`;
636
+ else if (typeof value === "boolean") {
637
+ cellAttrs.t = "b";
638
+ vStr = `<v>${value ? 1 : 0}</v>`;
639
+ } else if (typeof value === "string") {
640
+ cellAttrs.t = "str";
641
+ vStr = `<v>${escapeXml(value)}</v>`;
642
+ } else if (value instanceof Date) vStr = `<v>${this.dateToSerialNumber(value)}</v>`;
643
+ if (vStr) return `<c${attrs(cellAttrs)}>${fStr}${vStr}</c>`;
644
+ return `<c${attrs(cellAttrs)}>${fStr}</c>`;
645
+ }
915
646
  if (value === null || value === void 0) {
916
647
  if (cell.styleIndex !== void 0) return selfCloseElement("c", attrs(cellAttrs));
917
648
  return "";
@@ -949,34 +680,6 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
949
680
  }
950
681
  return result;
951
682
  }
952
- buildCell(ref, cell, sharedStrings, styles) {
953
- const attrs = { r: ref };
954
- if (cell.style !== void 0 && styles) attrs.s = styles.register(cell.style);
955
- else if (cell.styleIndex !== void 0) attrs.s = cell.styleIndex;
956
- const value = cell.value;
957
- if (value === null || value === void 0) {
958
- if (cell.styleIndex !== void 0) return { c: [{ _attr: attrs }] };
959
- return;
960
- }
961
- if (typeof value === "string") {
962
- if (sharedStrings) {
963
- attrs.t = "s";
964
- const idx = sharedStrings.register(value);
965
- return { c: [{ _attr: attrs }, { v: [idx] }] };
966
- }
967
- attrs.t = "inlineStr";
968
- return { c: [{ _attr: attrs }, { is: [{ t: [value] }] }] };
969
- }
970
- if (typeof value === "number") return { c: [{ _attr: attrs }, { v: [value] }] };
971
- if (typeof value === "boolean") {
972
- attrs.t = "b";
973
- return { c: [{ _attr: attrs }, { v: [value ? 1 : 0] }] };
974
- }
975
- if (value instanceof Date) {
976
- const serial = this.dateToSerialNumber(value);
977
- return { c: [{ _attr: attrs }, { v: [serial] }] };
978
- }
979
- }
980
683
  dateToSerialNumber(date) {
981
684
  const epoch = new Date(1899, 11, 30);
982
685
  return (date.getTime() - epoch.getTime()) / 864e5;
@@ -1097,33 +800,6 @@ var Drawing = class extends BaseXmlComponent {
1097
800
  this.images = images;
1098
801
  this.charts = charts;
1099
802
  }
1100
- prepForXml(_context) {
1101
- const children = [{ _attr: {
1102
- xmlns: XDR_NS,
1103
- "xmlns:a": A_NS,
1104
- "xmlns:r": R_NS
1105
- } }];
1106
- let nextId = 1;
1107
- for (const img of this.images) children.push(this.buildImageAnchor(img, nextId++));
1108
- for (const chart of this.charts) children.push(this.buildChartAnchor(chart, nextId++));
1109
- return { wsDr: children };
1110
- }
1111
- buildFromAnchor(col, row, colOffset, rowOffset) {
1112
- return { from: [
1113
- { col: [col - 1] },
1114
- { colOff: [colOffset ?? 0] },
1115
- { row: [row - 1] },
1116
- { rowOff: [rowOffset ?? 0] }
1117
- ] };
1118
- }
1119
- buildToAnchor(col, row) {
1120
- return { to: [
1121
- { col: [col] },
1122
- { colOff: [0] },
1123
- { row: [row] },
1124
- { rowOff: [0] }
1125
- ] };
1126
- }
1127
803
  toXml(_context) {
1128
804
  const p = [`<wsDr xmlns="${XDR_NS}" xmlns:a="${A_NS}" xmlns:r="${R_NS}">`];
1129
805
  let id = 1;
@@ -1138,54 +814,6 @@ var Drawing = class extends BaseXmlComponent {
1138
814
  p.push("</wsDr>");
1139
815
  return p.join("");
1140
816
  }
1141
- buildImageAnchor(img, id) {
1142
- return { twoCellAnchor: [
1143
- { _attr: { editAs: "oneCell" } },
1144
- this.buildFromAnchor(img.col, img.row, img.colOffset, img.rowOffset),
1145
- this.buildToAnchor(img.col, img.row),
1146
- { pic: [
1147
- { nvPicPr: [{ cNvPr: { _attr: {
1148
- id,
1149
- name: `Picture ${id}`
1150
- } } }, { cNvPicPr: [{ _attr: { preferRelativeResize: 1 } }] }] },
1151
- { blipFill: [{ "a:blip": { _attr: { "r:embed": img.rId } } }, { "a:stretch": [{ "a:fillRect": [] }] }] },
1152
- { spPr: [{ "a:xfrm": [{ "a:off": { _attr: {
1153
- x: 0,
1154
- y: 0
1155
- } } }, { "a:ext": { _attr: {
1156
- cx: 4e5,
1157
- cy: 3e5
1158
- } } }] }, { "a:prstGeom": [{ _attr: { prst: "rect" } }, { "a:avLst": [] }] }] }
1159
- ] },
1160
- { clientData: [] }
1161
- ] };
1162
- }
1163
- buildChartAnchor(chart, id) {
1164
- return { twoCellAnchor: [
1165
- { _attr: { editAs: "oneCell" } },
1166
- this.buildFromAnchor(chart.col, chart.row, chart.colOffset, chart.rowOffset),
1167
- this.buildToAnchor(chart.col + 8, chart.row + 15),
1168
- { graphicFrame: [
1169
- { nvGraphicFramePr: [{ cNvPr: { _attr: {
1170
- id,
1171
- name: `Chart ${id}`
1172
- } } }, { cNvGraphicFramePr: [{ "a:graphicFrameLocks": { _attr: { noGrp: 1 } } }] }] },
1173
- { xfrm: [{ "a:off": { _attr: {
1174
- x: 0,
1175
- y: 0
1176
- } } }, { "a:ext": { _attr: {
1177
- cx: 0,
1178
- cy: 0
1179
- } } }] },
1180
- { "a:graphic": [{ "a:graphicData": [{ _attr: { uri: C_URI } }, { "c:chart": { _attr: {
1181
- "xmlns:c": "http://schemas.openxmlformats.org/drawingml/2006/chart",
1182
- "xmlns:r": R_NS,
1183
- "r:id": chart.rId
1184
- } } }] }] }
1185
- ] },
1186
- { clientData: [] }
1187
- ] };
1188
- }
1189
817
  };
1190
818
  //#endregion
1191
819
  //#region src/export/packer/next-compiler.ts