@rowsncolumns/toolkit 24.4.3 → 24.4.4

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 (86) hide show
  1. package/dist/cjs/excel-parser/interface.d.ts +5 -1
  2. package/dist/cjs/excel-parser/interface.d.ts.map +1 -1
  3. package/dist/cjs/excel-parser/plugins/base/index.d.ts +2 -0
  4. package/dist/cjs/excel-parser/plugins/base/index.d.ts.map +1 -1
  5. package/dist/cjs/excel-parser/plugins/base/index.js +3 -0
  6. package/dist/cjs/excel-parser/plugins/xls/index.d.ts +55 -9
  7. package/dist/cjs/excel-parser/plugins/xls/index.d.ts.map +1 -1
  8. package/dist/cjs/excel-parser/plugins/xls/index.js +487 -24
  9. package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
  10. package/dist/cjs/excel-parser/plugins/xlsb/index.js +12 -5
  11. package/dist/cjs/excel-parser/plugins/xlsx/chartex.d.ts +37 -0
  12. package/dist/cjs/excel-parser/plugins/xlsx/chartex.d.ts.map +1 -0
  13. package/dist/cjs/excel-parser/plugins/xlsx/chartex.js +244 -0
  14. package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts +70 -0
  15. package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -0
  16. package/dist/cjs/excel-parser/plugins/xlsx/form-controls.js +295 -0
  17. package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +9 -1
  18. package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
  19. package/dist/cjs/excel-parser/plugins/xlsx/index.js +251 -104
  20. package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts +15 -1
  21. package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
  22. package/dist/cjs/excel-parser/plugins/xlsx/styles.js +90 -4
  23. package/dist/cjs/excel-parser/registry.d.ts +7 -0
  24. package/dist/cjs/excel-parser/registry.d.ts.map +1 -1
  25. package/dist/cjs/excel-parser/registry.js +28 -1
  26. package/dist/cjs/excel-parser/types.d.ts +10 -1
  27. package/dist/cjs/excel-parser/types.d.ts.map +1 -1
  28. package/dist/cjs/excel-parser/workbook.d.ts +2 -0
  29. package/dist/cjs/excel-parser/workbook.d.ts.map +1 -1
  30. package/dist/cjs/excel-parser/workbook.js +20 -14
  31. package/dist/cjs/excel-parser/worker.js +128 -130
  32. package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -1
  33. package/dist/cjs/exporter/xlsx/chart-builder.js +5 -33
  34. package/dist/cjs/exporter/xlsx/chartex-builder.d.ts +36 -0
  35. package/dist/cjs/exporter/xlsx/chartex-builder.d.ts.map +1 -0
  36. package/dist/cjs/exporter/xlsx/chartex-builder.js +109 -0
  37. package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts +61 -0
  38. package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts.map +1 -0
  39. package/dist/cjs/exporter/xlsx/form-controls-builder.js +197 -0
  40. package/dist/cjs/exporter/xlsx/xlsx-export.d.ts.map +1 -1
  41. package/dist/cjs/exporter/xlsx/xlsx-export.js +431 -193
  42. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  43. package/dist/esm/excel-parser/interface.d.ts +5 -1
  44. package/dist/esm/excel-parser/interface.d.ts.map +1 -1
  45. package/dist/esm/excel-parser/plugins/base/index.d.ts +2 -0
  46. package/dist/esm/excel-parser/plugins/base/index.d.ts.map +1 -1
  47. package/dist/esm/excel-parser/plugins/base/index.js +3 -0
  48. package/dist/esm/excel-parser/plugins/xls/index.d.ts +55 -9
  49. package/dist/esm/excel-parser/plugins/xls/index.d.ts.map +1 -1
  50. package/dist/esm/excel-parser/plugins/xls/index.js +429 -23
  51. package/dist/esm/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
  52. package/dist/esm/excel-parser/plugins/xlsb/index.js +10 -3
  53. package/dist/esm/excel-parser/plugins/xlsx/chartex.d.ts +37 -0
  54. package/dist/esm/excel-parser/plugins/xlsx/chartex.d.ts.map +1 -0
  55. package/dist/esm/excel-parser/plugins/xlsx/chartex.js +199 -0
  56. package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts +70 -0
  57. package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -0
  58. package/dist/esm/excel-parser/plugins/xlsx/form-controls.js +246 -0
  59. package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +9 -1
  60. package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
  61. package/dist/esm/excel-parser/plugins/xlsx/index.js +92 -6
  62. package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts +15 -1
  63. package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
  64. package/dist/esm/excel-parser/plugins/xlsx/styles.js +80 -0
  65. package/dist/esm/excel-parser/registry.d.ts +7 -0
  66. package/dist/esm/excel-parser/registry.d.ts.map +1 -1
  67. package/dist/esm/excel-parser/registry.js +18 -1
  68. package/dist/esm/excel-parser/types.d.ts +10 -1
  69. package/dist/esm/excel-parser/types.d.ts.map +1 -1
  70. package/dist/esm/excel-parser/workbook.d.ts +2 -0
  71. package/dist/esm/excel-parser/workbook.d.ts.map +1 -1
  72. package/dist/esm/excel-parser/workbook.js +16 -10
  73. package/dist/esm/excel-parser/worker.js +10 -18
  74. package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -1
  75. package/dist/esm/exporter/xlsx/chart-builder.js +0 -28
  76. package/dist/esm/exporter/xlsx/chartex-builder.d.ts +36 -0
  77. package/dist/esm/exporter/xlsx/chartex-builder.d.ts.map +1 -0
  78. package/dist/esm/exporter/xlsx/chartex-builder.js +97 -0
  79. package/dist/esm/exporter/xlsx/form-controls-builder.d.ts +61 -0
  80. package/dist/esm/exporter/xlsx/form-controls-builder.d.ts.map +1 -0
  81. package/dist/esm/exporter/xlsx/form-controls-builder.js +173 -0
  82. package/dist/esm/exporter/xlsx/xlsx-export.d.ts.map +1 -1
  83. package/dist/esm/exporter/xlsx/xlsx-export.js +228 -19
  84. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  85. package/package.json +3 -3
  86. package/xlsx.d.ts +14 -0
@@ -3,6 +3,8 @@ import { cellRangeToAddress, cellToAddress, escapeCharacters, getCellEffectiveFo
3
3
  import { zipSync } from "fflate";
4
4
  import { omitInvalidDataValidationError } from "../invalid-data-validation";
5
5
  import { buildAutoFilterConditionXml } from "../../autofilter-condition";
6
+ import { buildControlElementXml, buildControlsXml, buildCtrlPropXml, buildFormControlVmlShape, buildVmlDrawingXml, CTRL_PROP_CONTENT_TYPE, CTRL_PROP_REL_TYPE, FORM_CONTROL_VML_SHAPETYPE, } from "./form-controls-builder";
7
+ import { buildChartExGraphicFrameXml, buildChartExXml, CHART_EX_CONTENT_TYPE, CHART_EX_REL_TYPE, isChartExType, } from "./chartex-builder";
6
8
  import { applyPowerQueryParts } from "./power-query-builder";
7
9
  import { encodeImplicitIntersection } from "../../helpers/implicit-intersection";
8
10
  import { qualifyFutureFunctions } from "./future-functions";
@@ -29,12 +31,12 @@ var pixelToPoints = function (px) {
29
31
  return Math.max(1, Number(((px * 72) / 96).toFixed(2)));
30
32
  };
31
33
  export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
32
- var sortedSheets, sharedStrings, personRegistry, styleBuilder, exportableTables, tableIdMap, preparedTables, embedsBySheet, textBoxesBySheet, shapesBySheet, chartsBySheet, remappedSlicers, slicersBySheet, workbookSheetNames, sheetNameById, dataValidationsById, globalSlicerIndex, slicerCacheEntries, slicerEntries, globalPivotIndex, pivotCacheEntries, pivotCacheRelsEntries, pivotTableEntries, pivotTableRelsEntries, pivotsByTargetSheet, pivotTables_1, pivotTables_1_1, p, sid, list, workbookPivotCacheRefs, worksheetEntries, _d, workbookRelationshipsXml, sheetRelationshipIds, slicerCacheRelationshipIds, pivotCacheRelationshipIds, externalLinkRelationshipIds, workbookXml, sharedStringsXml, rootRelationshipsXml, appXml, coreXml, stylesXml, themeXml, files, worksheetEntries_1, worksheetEntries_1_1, entry, personsXml, preparedTables_1, preparedTables_1_1, table, rows, tableXml, globalImageIndex, globalChartIndex, drawingSheets, imageExtensions, chartEntries, worksheetEntries_2, worksheetEntries_2_1, entry, placements, textBoxesForSheet, shapesForSheet, chartsForSheet, slicersForSheet, drawingParts, _e, _f, media, _g, _h, chartEntry, e_1_1, chartEntries_1, chartEntries_1_1, chartEntry, slicerCacheEntries_1, slicerCacheEntries_1_1, slicerCacheEntry, slicerEntries_1, slicerEntries_1_1, slicerEntry, pivotCacheEntries_1, pivotCacheEntries_1_1, cacheEntry, pivotCacheRelsEntries_1, pivotCacheRelsEntries_1_1, cacheRels, pivotTableEntries_1, pivotTableEntries_1_1, tableEntry, pivotTableRelsEntries_1, pivotTableRelsEntries_1_1, tableRels, i, link, linkPath, relsPath, commentsSheets, threadedCommentsSheets, contentTypesXml, zipBytes;
33
- var e_2, _j, e_3, _k, e_4, _l, e_1, _m, e_5, _o, e_6, _p, e_7, _q, e_8, _s, e_9, _t, e_10, _u, e_11, _v, e_12, _w, e_13, _x;
34
- var _y, _z, _0, _1, _2, _3;
35
- var _conditionalFormats = _b.conditionalFormats, _dataValidations = _b.dataValidations, sheets = _b.sheets, sheetData = _b.sheetData, sourceSharedStrings = _b.sharedStrings, _4 = _b.tables, _tables = _4 === void 0 ? [] : _4, cellXfs = _b.cellXfs, theme = _b.theme, defaultFont = _b.defaultFont, _5 = _b.embeds, embeds = _5 === void 0 ? [] : _5, _6 = _b.charts, charts = _6 === void 0 ? [] : _6, _7 = _b.slicers, slicers = _7 === void 0 ? [] : _7, _8 = _b.pivotTables, pivotTables = _8 === void 0 ? [] : _8, _9 = _b.externalLinks, externalLinks = _9 === void 0 ? [] : _9, _10 = _b.namedRanges, namedRanges = _10 === void 0 ? [] : _10, _11 = _b.protectedRanges, protectedRanges = _11 === void 0 ? [] : _11, namedCellStyles = _b.namedCellStyles, customTableStyles = _b.customTableStyles, iterativeCalculationOptions = _b.iterativeCalculationOptions, ignoreFormulaPatterns = _b.ignoreFormulaPatterns, citations = _b.citations, comments = _b.comments, password = _b.password, locale = _b.locale, _12 = _b.use1904, use1904 = _12 === void 0 ? false : _12, properties = _b.properties, powerQuery = _b.powerQuery;
36
- return __generator(this, function (_13) {
37
- switch (_13.label) {
34
+ var sortedSheets, sharedStrings, personRegistry, styleBuilder, exportableTables, tableIdMap, preparedTables, embedsBySheet, textBoxesBySheet, shapesBySheet, formControlsBySheet, ctrlProps, chartsBySheet, remappedSlicers, slicersBySheet, workbookSheetNames, sheetNameById, dataValidationsById, globalSlicerIndex, slicerCacheEntries, slicerEntries, globalPivotIndex, pivotCacheEntries, pivotCacheRelsEntries, pivotTableEntries, pivotTableRelsEntries, pivotsByTargetSheet, pivotTables_1, pivotTables_1_1, p, sid, list, workbookPivotCacheRefs, worksheetEntries, _d, workbookRelationshipsXml, sheetRelationshipIds, slicerCacheRelationshipIds, pivotCacheRelationshipIds, externalLinkRelationshipIds, workbookXml, sharedStringsXml, rootRelationshipsXml, appXml, coreXml, stylesXml, themeXml, files, worksheetEntries_1, worksheetEntries_1_1, entry, personsXml, preparedTables_1, preparedTables_1_1, table, rows, tableXml, globalImageIndex, globalChartIndex, drawingSheets, imageExtensions, chartEntries, chartExEntries, globalChartExIndex, worksheetEntries_2, worksheetEntries_2_1, entry, placements, textBoxesForSheet, shapesForSheet, chartsForSheet, slicersForSheet, drawingParts, _e, _f, media, _g, _h, chartEntry, _j, _k, chartExEntry, e_1_1, chartEntries_1, chartEntries_1_1, chartEntry, chartExEntries_1, chartExEntries_1_1, chartExEntry, slicerCacheEntries_1, slicerCacheEntries_1_1, slicerCacheEntry, slicerEntries_1, slicerEntries_1_1, slicerEntry, pivotCacheEntries_1, pivotCacheEntries_1_1, cacheEntry, pivotCacheRelsEntries_1, pivotCacheRelsEntries_1_1, cacheRels, pivotTableEntries_1, pivotTableEntries_1_1, tableEntry, pivotTableRelsEntries_1, pivotTableRelsEntries_1_1, tableRels, i, link, linkPath, relsPath, commentsSheets, hasVmlDrawings, _l, _m, part, threadedCommentsSheets, contentTypesXml, zipBytes;
35
+ var e_2, _o, e_3, _p, e_4, _q, e_1, _s, e_5, _t, e_6, _u, e_7, _v, e_8, _w, e_9, _x, e_10, _y, e_11, _z, e_12, _0, e_13, _1, e_14, _2, e_15, _3, e_16, _4;
36
+ var _5, _6, _7, _8, _9, _10;
37
+ var _conditionalFormats = _b.conditionalFormats, _dataValidations = _b.dataValidations, sheets = _b.sheets, sheetData = _b.sheetData, sourceSharedStrings = _b.sharedStrings, _11 = _b.tables, _tables = _11 === void 0 ? [] : _11, cellXfs = _b.cellXfs, theme = _b.theme, defaultFont = _b.defaultFont, _12 = _b.embeds, embeds = _12 === void 0 ? [] : _12, _13 = _b.charts, charts = _13 === void 0 ? [] : _13, _14 = _b.slicers, slicers = _14 === void 0 ? [] : _14, _15 = _b.pivotTables, pivotTables = _15 === void 0 ? [] : _15, _16 = _b.externalLinks, externalLinks = _16 === void 0 ? [] : _16, _17 = _b.namedRanges, namedRanges = _17 === void 0 ? [] : _17, _18 = _b.protectedRanges, protectedRanges = _18 === void 0 ? [] : _18, namedCellStyles = _b.namedCellStyles, customTableStyles = _b.customTableStyles, iterativeCalculationOptions = _b.iterativeCalculationOptions, ignoreFormulaPatterns = _b.ignoreFormulaPatterns, citations = _b.citations, comments = _b.comments, password = _b.password, locale = _b.locale, _19 = _b.use1904, use1904 = _19 === void 0 ? false : _19, properties = _b.properties, powerQuery = _b.powerQuery;
38
+ return __generator(this, function (_20) {
39
+ switch (_20.label) {
38
40
  case 0:
39
41
  sortedSheets = sortSheetsByIndex(sheets, true);
40
42
  sharedStrings = new SharedStrings();
@@ -59,6 +61,8 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
59
61
  embedsBySheet = groupEmbedsBySheet(embeds !== null && embeds !== void 0 ? embeds : []);
60
62
  textBoxesBySheet = groupTextBoxesBySheet(embeds !== null && embeds !== void 0 ? embeds : []);
61
63
  shapesBySheet = groupShapesBySheet(embeds !== null && embeds !== void 0 ? embeds : []);
64
+ formControlsBySheet = groupFormControlsBySheet(embeds !== null && embeds !== void 0 ? embeds : []);
65
+ ctrlProps = { parts: [] };
62
66
  chartsBySheet = groupChartsBySheet(charts !== null && charts !== void 0 ? charts : []);
63
67
  remappedSlicers = slicers.map(function (slicer) {
64
68
  if (slicer.spec.type !== "table")
@@ -76,10 +80,10 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
76
80
  var _a;
77
81
  sheetNameById.set((_a = sheet.sheetId) !== null && _a !== void 0 ? _a : index + 1, workbookSheetNames[index]);
78
82
  });
79
- dataValidationsById = (_y = _dataValidations === null || _dataValidations === void 0 ? void 0 : _dataValidations.reduce(function (acc, rule) {
83
+ dataValidationsById = (_5 = _dataValidations === null || _dataValidations === void 0 ? void 0 : _dataValidations.reduce(function (acc, rule) {
80
84
  acc[rule.id] = rule;
81
85
  return acc;
82
- }, {})) !== null && _y !== void 0 ? _y : undefined;
86
+ }, {})) !== null && _5 !== void 0 ? _5 : undefined;
83
87
  globalSlicerIndex = 1;
84
88
  slicerCacheEntries = [];
85
89
  slicerEntries = [];
@@ -92,7 +96,7 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
92
96
  try {
93
97
  for (pivotTables_1 = __values(pivotTables), pivotTables_1_1 = pivotTables_1.next(); !pivotTables_1_1.done; pivotTables_1_1 = pivotTables_1.next()) {
94
98
  p = pivotTables_1_1.value;
95
- sid = (_z = p.targetPosition) === null || _z === void 0 ? void 0 : _z.sheetId;
99
+ sid = (_6 = p.targetPosition) === null || _6 === void 0 ? void 0 : _6.sheetId;
96
100
  if (sid == null)
97
101
  continue;
98
102
  list = pivotsByTargetSheet.get(sid);
@@ -105,22 +109,23 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
105
109
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
106
110
  finally {
107
111
  try {
108
- if (pivotTables_1_1 && !pivotTables_1_1.done && (_j = pivotTables_1.return)) _j.call(pivotTables_1);
112
+ if (pivotTables_1_1 && !pivotTables_1_1.done && (_o = pivotTables_1.return)) _o.call(pivotTables_1);
109
113
  }
110
114
  finally { if (e_2) throw e_2.error; }
111
115
  }
112
116
  workbookPivotCacheRefs = [];
113
117
  worksheetEntries = sortedSheets.map(function (sheet, index) {
114
- var e_14, _a, e_15, _b;
115
- var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _s, _t;
118
+ var e_17, _a, e_18, _b;
119
+ var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _s, _t, _u;
116
120
  var rows = getRowsForSheet(sheetData, sheet.sheetId);
117
121
  var sheetRelationships = new RelationshipsBuilder();
118
122
  var sheetTables = preparedTables.filter(function (table) { return table.sheetId === sheet.sheetId; });
119
123
  var embedImages = (_d = embedsBySheet.get(sheet.sheetId)) !== null && _d !== void 0 ? _d : [];
120
124
  var textBoxes = (_e = textBoxesBySheet.get(sheet.sheetId)) !== null && _e !== void 0 ? _e : [];
121
125
  var sheetShapes = (_f = shapesBySheet.get(sheet.sheetId)) !== null && _f !== void 0 ? _f : [];
122
- var sheetCharts = (_g = chartsBySheet.get(sheet.sheetId)) !== null && _g !== void 0 ? _g : [];
123
- var sheetSlicers = (_h = slicersBySheet.get(sheet.sheetId)) !== null && _h !== void 0 ? _h : [];
126
+ var sheetFormControls = (_g = formControlsBySheet.get(sheet.sheetId)) !== null && _g !== void 0 ? _g : [];
127
+ var sheetCharts = (_h = chartsBySheet.get(sheet.sheetId)) !== null && _h !== void 0 ? _h : [];
128
+ var sheetSlicers = (_j = slicersBySheet.get(sheet.sheetId)) !== null && _j !== void 0 ? _j : [];
124
129
  var worksheetSlicerRelIds = [];
125
130
  var drawingSlicers = [];
126
131
  var sheetConditionalFormats = (_conditionalFormats !== null && _conditionalFormats !== void 0 ? _conditionalFormats : []).filter(function (rule) { var _a; return (_a = rule.ranges) === null || _a === void 0 ? void 0 : _a.some(function (range) { return range.sheetId === sheet.sheetId; }); });
@@ -168,24 +173,24 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
168
173
  }
169
174
  }
170
175
  }
171
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
176
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
172
177
  finally {
173
178
  try {
174
179
  if (sheetSlicers_1_1 && !sheetSlicers_1_1.done && (_a = sheetSlicers_1.return)) _a.call(sheetSlicers_1);
175
180
  }
176
- finally { if (e_14) throw e_14.error; }
181
+ finally { if (e_17) throw e_17.error; }
177
182
  }
178
183
  // Phase D2 — emit pivot table XMLs + relationships for this
179
184
  // sheet. PivotTable lives on the rendering sheet; its cache
180
185
  // definition is workbook-scoped (added to <pivotCaches> after
181
186
  // this loop).
182
- var sheetPivots = (_j = pivotsByTargetSheet.get(sheet.sheetId)) !== null && _j !== void 0 ? _j : [];
187
+ var sheetPivots = (_k = pivotsByTargetSheet.get(sheet.sheetId)) !== null && _k !== void 0 ? _k : [];
183
188
  var _loop_1 = function (pivot) {
184
- var e_16, _u, e_17, _v, e_18, _w, e_19, _x, e_20, _y, e_21, _z;
189
+ var e_19, _v, e_20, _w, e_21, _x, e_22, _y, e_23, _z, e_24, _0;
185
190
  var cacheIndex = globalPivotIndex;
186
191
  var tableIndex = globalPivotIndex;
187
192
  var sourceSheet = sortedSheets.find(function (s) { var _a; return s.sheetId === ((_a = pivot.source) === null || _a === void 0 ? void 0 : _a.sheetId); });
188
- var sourceSheetName = (_l = (_k = sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.title) !== null && _k !== void 0 ? _k : sheet.title) !== null && _l !== void 0 ? _l : "Sheet".concat(sheet.sheetId);
193
+ var sourceSheetName = (_m = (_l = sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.title) !== null && _l !== void 0 ? _l : sheet.title) !== null && _m !== void 0 ? _m : "Sheet".concat(sheet.sheetId);
189
194
  // Field universe: union of every field referenced by the
190
195
  // pivot. PivotCacheDefinition requires one <cacheField>
191
196
  // entry per field, and pivotTable.fld indices reference them.
@@ -197,88 +202,88 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
197
202
  fieldIndex.set(name, fieldNameList.length);
198
203
  fieldNameList.push(name);
199
204
  };
200
- var calculatedNames = new Set(((_m = pivot.calculatedFields) !== null && _m !== void 0 ? _m : []).map(function (c) { return c.name; }));
205
+ var calculatedNames = new Set(((_o = pivot.calculatedFields) !== null && _o !== void 0 ? _o : []).map(function (c) { return c.name; }));
201
206
  try {
202
- for (var _0 = (e_16 = void 0, __values((_o = pivot.rows) !== null && _o !== void 0 ? _o : [])), _1 = _0.next(); !_1.done; _1 = _0.next()) {
203
- var r = _1.value;
207
+ for (var _1 = (e_19 = void 0, __values((_p = pivot.rows) !== null && _p !== void 0 ? _p : [])), _2 = _1.next(); !_2.done; _2 = _1.next()) {
208
+ var r = _2.value;
204
209
  registerField(r.field);
205
210
  }
206
211
  }
207
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
212
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
208
213
  finally {
209
214
  try {
210
- if (_1 && !_1.done && (_u = _0.return)) _u.call(_0);
215
+ if (_2 && !_2.done && (_v = _1.return)) _v.call(_1);
211
216
  }
212
- finally { if (e_16) throw e_16.error; }
217
+ finally { if (e_19) throw e_19.error; }
213
218
  }
214
219
  try {
215
- for (var _2 = (e_17 = void 0, __values((_p = pivot.columns) !== null && _p !== void 0 ? _p : [])), _3 = _2.next(); !_3.done; _3 = _2.next()) {
216
- var c = _3.value;
220
+ for (var _3 = (e_20 = void 0, __values((_q = pivot.columns) !== null && _q !== void 0 ? _q : [])), _4 = _3.next(); !_4.done; _4 = _3.next()) {
221
+ var c = _4.value;
217
222
  registerField(c.field);
218
223
  }
219
224
  }
220
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
225
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
221
226
  finally {
222
227
  try {
223
- if (_3 && !_3.done && (_v = _2.return)) _v.call(_2);
228
+ if (_4 && !_4.done && (_w = _3.return)) _w.call(_3);
224
229
  }
225
- finally { if (e_17) throw e_17.error; }
230
+ finally { if (e_20) throw e_20.error; }
226
231
  }
227
232
  try {
228
- for (var _4 = (e_18 = void 0, __values((_q = pivot.values) !== null && _q !== void 0 ? _q : [])), _5 = _4.next(); !_5.done; _5 = _4.next()) {
229
- var v = _5.value;
233
+ for (var _5 = (e_21 = void 0, __values((_s = pivot.values) !== null && _s !== void 0 ? _s : [])), _6 = _5.next(); !_6.done; _6 = _5.next()) {
234
+ var v = _6.value;
230
235
  if (!calculatedNames.has(v.field))
231
236
  registerField(v.field);
232
237
  }
233
238
  }
234
- catch (e_18_1) { e_18 = { error: e_18_1 }; }
239
+ catch (e_21_1) { e_21 = { error: e_21_1 }; }
235
240
  finally {
236
241
  try {
237
- if (_5 && !_5.done && (_w = _4.return)) _w.call(_4);
242
+ if (_6 && !_6.done && (_x = _5.return)) _x.call(_5);
238
243
  }
239
- finally { if (e_18) throw e_18.error; }
244
+ finally { if (e_21) throw e_21.error; }
240
245
  }
241
246
  try {
242
247
  // Source fields a calculated field reads must exist in the cache
243
248
  // for Excel to evaluate the formula; the calculated fields
244
249
  // themselves come last, as Excel orders them.
245
- for (var _6 = (e_19 = void 0, __values((_s = pivot.calculatedFields) !== null && _s !== void 0 ? _s : [])), _7 = _6.next(); !_7.done; _7 = _6.next()) {
246
- var c = _7.value;
250
+ for (var _7 = (e_22 = void 0, __values((_t = pivot.calculatedFields) !== null && _t !== void 0 ? _t : [])), _8 = _7.next(); !_8.done; _8 = _7.next()) {
251
+ var c = _8.value;
247
252
  try {
248
- for (var _8 = (e_20 = void 0, __values(calculatedFieldReferences(c.formula))), _9 = _8.next(); !_9.done; _9 = _8.next()) {
249
- var ref = _9.value;
253
+ for (var _9 = (e_23 = void 0, __values(calculatedFieldReferences(c.formula))), _10 = _9.next(); !_10.done; _10 = _9.next()) {
254
+ var ref = _10.value;
250
255
  if (!calculatedNames.has(ref))
251
256
  registerField(ref);
252
257
  }
253
258
  }
254
- catch (e_20_1) { e_20 = { error: e_20_1 }; }
259
+ catch (e_23_1) { e_23 = { error: e_23_1 }; }
255
260
  finally {
256
261
  try {
257
- if (_9 && !_9.done && (_y = _8.return)) _y.call(_8);
262
+ if (_10 && !_10.done && (_z = _9.return)) _z.call(_9);
258
263
  }
259
- finally { if (e_20) throw e_20.error; }
264
+ finally { if (e_23) throw e_23.error; }
260
265
  }
261
266
  }
262
267
  }
263
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
268
+ catch (e_22_1) { e_22 = { error: e_22_1 }; }
264
269
  finally {
265
270
  try {
266
- if (_7 && !_7.done && (_x = _6.return)) _x.call(_6);
271
+ if (_8 && !_8.done && (_y = _7.return)) _y.call(_7);
267
272
  }
268
- finally { if (e_19) throw e_19.error; }
273
+ finally { if (e_22) throw e_22.error; }
269
274
  }
270
275
  try {
271
- for (var _10 = (e_21 = void 0, __values((_t = pivot.calculatedFields) !== null && _t !== void 0 ? _t : [])), _11 = _10.next(); !_11.done; _11 = _10.next()) {
272
- var c = _11.value;
276
+ for (var _11 = (e_24 = void 0, __values((_u = pivot.calculatedFields) !== null && _u !== void 0 ? _u : [])), _12 = _11.next(); !_12.done; _12 = _11.next()) {
277
+ var c = _12.value;
273
278
  registerField(c.name);
274
279
  }
275
280
  }
276
- catch (e_21_1) { e_21 = { error: e_21_1 }; }
281
+ catch (e_24_1) { e_24 = { error: e_24_1 }; }
277
282
  finally {
278
283
  try {
279
- if (_11 && !_11.done && (_z = _10.return)) _z.call(_10);
284
+ if (_12 && !_12.done && (_0 = _11.return)) _0.call(_11);
280
285
  }
281
- finally { if (e_21) throw e_21.error; }
286
+ finally { if (e_24) throw e_24.error; }
282
287
  }
283
288
  var cacheXml = buildPivotCacheDefinitionXml(pivot, sourceSheetName, fieldNameList);
284
289
  var tableXml = buildPivotTableXml(pivot, cacheIndex, fieldIndex);
@@ -309,12 +314,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
309
314
  _loop_1(pivot);
310
315
  }
311
316
  }
312
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
317
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
313
318
  finally {
314
319
  try {
315
320
  if (sheetPivots_1_1 && !sheetPivots_1_1.done && (_b = sheetPivots_1.return)) _b.call(sheetPivots_1);
316
321
  }
317
- finally { if (e_15) throw e_15.error; }
322
+ finally { if (e_18) throw e_18.error; }
318
323
  }
319
324
  var result = buildWorksheetXml({
320
325
  sheet: sheet,
@@ -338,6 +343,8 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
338
343
  sheets: sortedSheets,
339
344
  locale: locale,
340
345
  protectedRanges: protectedRanges,
346
+ formControls: sheetFormControls,
347
+ ctrlProps: ctrlProps,
341
348
  });
342
349
  return {
343
350
  index: index,
@@ -399,7 +406,7 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
399
406
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
400
407
  finally {
401
408
  try {
402
- if (worksheetEntries_1_1 && !worksheetEntries_1_1.done && (_k = worksheetEntries_1.return)) _k.call(worksheetEntries_1);
409
+ if (worksheetEntries_1_1 && !worksheetEntries_1_1.done && (_p = worksheetEntries_1.return)) _p.call(worksheetEntries_1);
403
410
  }
404
411
  finally { if (e_3) throw e_3.error; }
405
412
  }
@@ -420,7 +427,7 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
420
427
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
421
428
  finally {
422
429
  try {
423
- if (preparedTables_1_1 && !preparedTables_1_1.done && (_l = preparedTables_1.return)) _l.call(preparedTables_1);
430
+ if (preparedTables_1_1 && !preparedTables_1_1.done && (_q = preparedTables_1.return)) _q.call(preparedTables_1);
424
431
  }
425
432
  finally { if (e_4) throw e_4.error; }
426
433
  }
@@ -429,19 +436,21 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
429
436
  drawingSheets = [];
430
437
  imageExtensions = new Set();
431
438
  chartEntries = [];
432
- _13.label = 1;
439
+ chartExEntries = [];
440
+ globalChartExIndex = 1;
441
+ _20.label = 1;
433
442
  case 1:
434
- _13.trys.push([1, 6, 7, 8]);
443
+ _20.trys.push([1, 6, 7, 8]);
435
444
  worksheetEntries_2 = __values(worksheetEntries), worksheetEntries_2_1 = worksheetEntries_2.next();
436
- _13.label = 2;
445
+ _20.label = 2;
437
446
  case 2:
438
447
  if (!!worksheetEntries_2_1.done) return [3 /*break*/, 5];
439
448
  entry = worksheetEntries_2_1.value;
440
449
  placements = __spreadArray(__spreadArray([], __read(entry.cellImages), false), __read(entry.embedImages), false);
441
- textBoxesForSheet = (_0 = entry.textBoxes) !== null && _0 !== void 0 ? _0 : [];
442
- shapesForSheet = (_1 = entry.shapes) !== null && _1 !== void 0 ? _1 : [];
443
- chartsForSheet = (_2 = entry.charts) !== null && _2 !== void 0 ? _2 : [];
444
- slicersForSheet = (_3 = entry.slicers) !== null && _3 !== void 0 ? _3 : [];
450
+ textBoxesForSheet = (_7 = entry.textBoxes) !== null && _7 !== void 0 ? _7 : [];
451
+ shapesForSheet = (_8 = entry.shapes) !== null && _8 !== void 0 ? _8 : [];
452
+ chartsForSheet = (_9 = entry.charts) !== null && _9 !== void 0 ? _9 : [];
453
+ slicersForSheet = (_10 = entry.slicers) !== null && _10 !== void 0 ? _10 : [];
445
454
  if (!placements.length &&
446
455
  !textBoxesForSheet.length &&
447
456
  !shapesForSheet.length &&
@@ -455,12 +464,13 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
455
464
  shapes: shapesForSheet,
456
465
  startImageIndex: globalImageIndex,
457
466
  startChartIndex: globalChartIndex,
467
+ startChartExIndex: globalChartExIndex,
458
468
  charts: chartsForSheet,
459
469
  slicers: slicersForSheet,
460
470
  sheetNameById: sheetNameById,
461
471
  })];
462
472
  case 3:
463
- drawingParts = _13.sent();
473
+ drawingParts = _20.sent();
464
474
  if (!drawingParts)
465
475
  return [3 /*break*/, 4];
466
476
  files[entry.drawingPath] = encodeXml(drawingParts.xml);
@@ -477,7 +487,7 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
477
487
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
478
488
  finally {
479
489
  try {
480
- if (_f && !_f.done && (_o = _e.return)) _o.call(_e);
490
+ if (_f && !_f.done && (_t = _e.return)) _t.call(_e);
481
491
  }
482
492
  finally { if (e_5) throw e_5.error; }
483
493
  }
@@ -490,25 +500,39 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
490
500
  catch (e_6_1) { e_6 = { error: e_6_1 }; }
491
501
  finally {
492
502
  try {
493
- if (_h && !_h.done && (_p = _g.return)) _p.call(_g);
503
+ if (_h && !_h.done && (_u = _g.return)) _u.call(_g);
494
504
  }
495
505
  finally { if (e_6) throw e_6.error; }
496
506
  }
507
+ try {
508
+ for (_j = (e_7 = void 0, __values(drawingParts.chartExs)), _k = _j.next(); !_k.done; _k = _j.next()) {
509
+ chartExEntry = _k.value;
510
+ chartExEntries.push(chartExEntry);
511
+ }
512
+ }
513
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
514
+ finally {
515
+ try {
516
+ if (_k && !_k.done && (_v = _j.return)) _v.call(_j);
517
+ }
518
+ finally { if (e_7) throw e_7.error; }
519
+ }
497
520
  globalImageIndex = drawingParts.nextImageIndex;
498
521
  globalChartIndex = drawingParts.nextChartIndex;
522
+ globalChartExIndex = drawingParts.nextChartExIndex;
499
523
  drawingSheets.push(entry.index + 1);
500
- _13.label = 4;
524
+ _20.label = 4;
501
525
  case 4:
502
526
  worksheetEntries_2_1 = worksheetEntries_2.next();
503
527
  return [3 /*break*/, 2];
504
528
  case 5: return [3 /*break*/, 8];
505
529
  case 6:
506
- e_1_1 = _13.sent();
530
+ e_1_1 = _20.sent();
507
531
  e_1 = { error: e_1_1 };
508
532
  return [3 /*break*/, 8];
509
533
  case 7:
510
534
  try {
511
- if (worksheetEntries_2_1 && !worksheetEntries_2_1.done && (_m = worksheetEntries_2.return)) _m.call(worksheetEntries_2);
535
+ if (worksheetEntries_2_1 && !worksheetEntries_2_1.done && (_s = worksheetEntries_2.return)) _s.call(worksheetEntries_2);
512
536
  }
513
537
  finally { if (e_1) throw e_1.error; }
514
538
  return [7 /*endfinally*/];
@@ -519,12 +543,25 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
519
543
  files[chartEntry.path] = encodeXml(chartEntry.xml);
520
544
  }
521
545
  }
522
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
546
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
523
547
  finally {
524
548
  try {
525
- if (chartEntries_1_1 && !chartEntries_1_1.done && (_q = chartEntries_1.return)) _q.call(chartEntries_1);
549
+ if (chartEntries_1_1 && !chartEntries_1_1.done && (_w = chartEntries_1.return)) _w.call(chartEntries_1);
526
550
  }
527
- finally { if (e_7) throw e_7.error; }
551
+ finally { if (e_8) throw e_8.error; }
552
+ }
553
+ try {
554
+ for (chartExEntries_1 = __values(chartExEntries), chartExEntries_1_1 = chartExEntries_1.next(); !chartExEntries_1_1.done; chartExEntries_1_1 = chartExEntries_1.next()) {
555
+ chartExEntry = chartExEntries_1_1.value;
556
+ files[chartExEntry.path] = encodeXml(chartExEntry.xml);
557
+ }
558
+ }
559
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
560
+ finally {
561
+ try {
562
+ if (chartExEntries_1_1 && !chartExEntries_1_1.done && (_x = chartExEntries_1.return)) _x.call(chartExEntries_1);
563
+ }
564
+ finally { if (e_9) throw e_9.error; }
528
565
  }
529
566
  try {
530
567
  for (slicerCacheEntries_1 = __values(slicerCacheEntries), slicerCacheEntries_1_1 = slicerCacheEntries_1.next(); !slicerCacheEntries_1_1.done; slicerCacheEntries_1_1 = slicerCacheEntries_1.next()) {
@@ -532,12 +569,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
532
569
  files[slicerCacheEntry.path] = encodeXml(slicerCacheEntry.xml);
533
570
  }
534
571
  }
535
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
572
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
536
573
  finally {
537
574
  try {
538
- if (slicerCacheEntries_1_1 && !slicerCacheEntries_1_1.done && (_s = slicerCacheEntries_1.return)) _s.call(slicerCacheEntries_1);
575
+ if (slicerCacheEntries_1_1 && !slicerCacheEntries_1_1.done && (_y = slicerCacheEntries_1.return)) _y.call(slicerCacheEntries_1);
539
576
  }
540
- finally { if (e_8) throw e_8.error; }
577
+ finally { if (e_10) throw e_10.error; }
541
578
  }
542
579
  try {
543
580
  for (slicerEntries_1 = __values(slicerEntries), slicerEntries_1_1 = slicerEntries_1.next(); !slicerEntries_1_1.done; slicerEntries_1_1 = slicerEntries_1.next()) {
@@ -545,12 +582,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
545
582
  files[slicerEntry.path] = encodeXml(slicerEntry.xml);
546
583
  }
547
584
  }
548
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
585
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
549
586
  finally {
550
587
  try {
551
- if (slicerEntries_1_1 && !slicerEntries_1_1.done && (_t = slicerEntries_1.return)) _t.call(slicerEntries_1);
588
+ if (slicerEntries_1_1 && !slicerEntries_1_1.done && (_z = slicerEntries_1.return)) _z.call(slicerEntries_1);
552
589
  }
553
- finally { if (e_9) throw e_9.error; }
590
+ finally { if (e_11) throw e_11.error; }
554
591
  }
555
592
  try {
556
593
  // Phase D2 — emit pivot files.
@@ -559,12 +596,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
559
596
  files[cacheEntry.path] = encodeXml(cacheEntry.xml);
560
597
  }
561
598
  }
562
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
599
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
563
600
  finally {
564
601
  try {
565
- if (pivotCacheEntries_1_1 && !pivotCacheEntries_1_1.done && (_u = pivotCacheEntries_1.return)) _u.call(pivotCacheEntries_1);
602
+ if (pivotCacheEntries_1_1 && !pivotCacheEntries_1_1.done && (_0 = pivotCacheEntries_1.return)) _0.call(pivotCacheEntries_1);
566
603
  }
567
- finally { if (e_10) throw e_10.error; }
604
+ finally { if (e_12) throw e_12.error; }
568
605
  }
569
606
  try {
570
607
  for (pivotCacheRelsEntries_1 = __values(pivotCacheRelsEntries), pivotCacheRelsEntries_1_1 = pivotCacheRelsEntries_1.next(); !pivotCacheRelsEntries_1_1.done; pivotCacheRelsEntries_1_1 = pivotCacheRelsEntries_1.next()) {
@@ -572,12 +609,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
572
609
  files[cacheRels.path] = encodeXml(cacheRels.xml);
573
610
  }
574
611
  }
575
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
612
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
576
613
  finally {
577
614
  try {
578
- if (pivotCacheRelsEntries_1_1 && !pivotCacheRelsEntries_1_1.done && (_v = pivotCacheRelsEntries_1.return)) _v.call(pivotCacheRelsEntries_1);
615
+ if (pivotCacheRelsEntries_1_1 && !pivotCacheRelsEntries_1_1.done && (_1 = pivotCacheRelsEntries_1.return)) _1.call(pivotCacheRelsEntries_1);
579
616
  }
580
- finally { if (e_11) throw e_11.error; }
617
+ finally { if (e_13) throw e_13.error; }
581
618
  }
582
619
  try {
583
620
  for (pivotTableEntries_1 = __values(pivotTableEntries), pivotTableEntries_1_1 = pivotTableEntries_1.next(); !pivotTableEntries_1_1.done; pivotTableEntries_1_1 = pivotTableEntries_1.next()) {
@@ -585,12 +622,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
585
622
  files[tableEntry.path] = encodeXml(tableEntry.xml);
586
623
  }
587
624
  }
588
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
625
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
589
626
  finally {
590
627
  try {
591
- if (pivotTableEntries_1_1 && !pivotTableEntries_1_1.done && (_w = pivotTableEntries_1.return)) _w.call(pivotTableEntries_1);
628
+ if (pivotTableEntries_1_1 && !pivotTableEntries_1_1.done && (_2 = pivotTableEntries_1.return)) _2.call(pivotTableEntries_1);
592
629
  }
593
- finally { if (e_12) throw e_12.error; }
630
+ finally { if (e_14) throw e_14.error; }
594
631
  }
595
632
  try {
596
633
  for (pivotTableRelsEntries_1 = __values(pivotTableRelsEntries), pivotTableRelsEntries_1_1 = pivotTableRelsEntries_1.next(); !pivotTableRelsEntries_1_1.done; pivotTableRelsEntries_1_1 = pivotTableRelsEntries_1.next()) {
@@ -598,12 +635,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
598
635
  files[tableRels.path] = encodeXml(tableRels.xml);
599
636
  }
600
637
  }
601
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
638
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
602
639
  finally {
603
640
  try {
604
- if (pivotTableRelsEntries_1_1 && !pivotTableRelsEntries_1_1.done && (_x = pivotTableRelsEntries_1.return)) _x.call(pivotTableRelsEntries_1);
641
+ if (pivotTableRelsEntries_1_1 && !pivotTableRelsEntries_1_1.done && (_3 = pivotTableRelsEntries_1.return)) _3.call(pivotTableRelsEntries_1);
605
642
  }
606
- finally { if (e_13) throw e_13.error; }
643
+ finally { if (e_15) throw e_15.error; }
607
644
  }
608
645
  // Add external link files (for formulas referencing other workbooks)
609
646
  for (i = 0; i < externalLinks.length; i++) {
@@ -619,6 +656,20 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
619
656
  commentsSheets = worksheetEntries
620
657
  .filter(function (entry) { return entry.commentsXml; })
621
658
  .map(function (entry) { var _a; return (_a = entry.sheet.sheetId) !== null && _a !== void 0 ? _a : entry.index + 1; });
659
+ hasVmlDrawings = worksheetEntries.some(function (entry) { return entry.vmlDrawingXml; });
660
+ try {
661
+ for (_l = __values(ctrlProps.parts), _m = _l.next(); !_m.done; _m = _l.next()) {
662
+ part = _m.value;
663
+ files[part.path] = encodeXml(part.xml);
664
+ }
665
+ }
666
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
667
+ finally {
668
+ try {
669
+ if (_m && !_m.done && (_4 = _l.return)) _4.call(_l);
670
+ }
671
+ finally { if (e_16) throw e_16.error; }
672
+ }
622
673
  threadedCommentsSheets = worksheetEntries
623
674
  .filter(function (entry) { return entry.threadedCommentsXml; })
624
675
  .map(function (entry) { var _a; return (_a = entry.sheet.sheetId) !== null && _a !== void 0 ? _a : entry.index + 1; });
@@ -628,6 +679,7 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
628
679
  drawingSheets: drawingSheets,
629
680
  mediaExtensions: Array.from(imageExtensions),
630
681
  chartCount: chartEntries.length,
682
+ chartExCount: chartExEntries.length,
631
683
  slicerCount: slicerEntries.length,
632
684
  slicerCacheCount: slicerCacheEntries.length,
633
685
  pivotTableCount: pivotTableEntries.length,
@@ -636,6 +688,8 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
636
688
  threadedCommentsSheets: threadedCommentsSheets,
637
689
  hasPersons: !personRegistry.isEmpty(),
638
690
  externalLinkCount: externalLinks.length,
691
+ hasVmlDrawings: hasVmlDrawings,
692
+ ctrlPropCount: ctrlProps.parts.length,
639
693
  });
640
694
  files["[Content_Types].xml"] = encodeXml(contentTypesXml);
641
695
  // Preserved Power Query machinery (DataMashup customXml, connections.xml, queryTable parts) is
@@ -803,6 +857,8 @@ var DataValidationCollector = /** @class */ (function () {
803
857
  };
804
858
  return DataValidationCollector;
805
859
  }());
860
+ /** First VML shape id the note shapes take (`_x0000_s1026`, `_x0000_s1027`, …). */
861
+ var NOTE_VML_SHAPE_ID_BASE = 1026;
806
862
  var CommentsCollector = /** @class */ (function () {
807
863
  function CommentsCollector() {
808
864
  this.entries = [];
@@ -830,13 +886,18 @@ var CommentsCollector = /** @class */ (function () {
830
886
  .join("");
831
887
  return "".concat(XML_DECLARATION, "<comments xmlns=\"").concat(WORKSHEET_NS, "\"><authors>").concat(authorsXml, "</authors><commentList>").concat(commentsXml, "</commentList></comments>");
832
888
  };
833
- CommentsCollector.prototype.toVmlXml = function () {
834
- if (!this.entries.length) {
835
- return undefined;
836
- }
837
- var shapes = this.entries
838
- .map(function (entry, index) {
839
- var shapeId = "_x0000_s".concat(1026 + index);
889
+ /**
890
+ * VML shape ids the note shapes occupy. Excel allocates notes and form
891
+ * controls from one per-sheet counter, so the form-control allocator must
892
+ * never hand these out again.
893
+ */
894
+ CommentsCollector.prototype.vmlShapeIds = function () {
895
+ return this.entries.map(function (_, index) { return NOTE_VML_SHAPE_ID_BASE + index; });
896
+ };
897
+ /** One `<v:shape>` per note (Excel's hidden `Note` object). */
898
+ CommentsCollector.prototype.toVmlShapes = function () {
899
+ return this.entries.map(function (entry, index) {
900
+ var shapeId = "_x0000_s".concat(NOTE_VML_SHAPE_ID_BASE + index);
840
901
  // Parse cell address to get row and column
841
902
  var match = entry.address.match(/^([A-Z]+)(\d+)$/);
842
903
  if (!match)
@@ -847,12 +908,12 @@ var CommentsCollector = /** @class */ (function () {
847
908
  .split("")
848
909
  .reduce(function (acc, char) { return acc * 26 + (char.charCodeAt(0) - 64); }, 0) - 1;
849
910
  return "<v:shape id=\"".concat(shapeId, "\" type=\"#_x0000_t202\" style='position:absolute;margin-left:59.25pt;margin-top:1.5pt;width:108pt;height:59.25pt;z-index:").concat(index + 1, ";visibility:hidden' fillcolor=\"#ffffe1\" o:insetmode=\"auto\"><v:fill color2=\"#ffffe1\"/><v:shadow on=\"t\" color=\"black\" obscured=\"t\"/><v:path o:connecttype=\"none\"/><v:textbox style='mso-direction-alt:auto'><div style='text-align:left'></div></v:textbox><x:ClientData ObjectType=\"Note\"><x:MoveWithCells/><x:SizeWithCells/><x:Anchor>1, 15, 0, 2, 3, 15, 3, 16</x:Anchor><x:AutoFill>False</x:AutoFill><x:Row>").concat(row - 1, "</x:Row><x:Column>").concat(colIndex, "</x:Column></x:ClientData></v:shape>");
850
- })
851
- .join("");
852
- return "<xml xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\"><o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout><v:shapetype id=\"_x0000_t202\" coordsize=\"21600,21600\" o:spt=\"202\" path=\"m,l,21600r21600,l21600,xe\"><v:stroke joinstyle=\"miter\"/><v:path gradientshapeok=\"t\" o:connecttype=\"rect\"/></v:shapetype>".concat(shapes, "</xml>");
911
+ }).filter(Boolean);
853
912
  };
854
913
  return CommentsCollector;
855
914
  }());
915
+ /** VML `<v:shapetype>` for legacy notes (`#_x0000_t202`). */
916
+ var NOTE_VML_SHAPETYPE = "<v:shapetype id=\"_x0000_t202\" coordsize=\"21600,21600\" o:spt=\"202\" path=\"m,l,21600r21600,l21600,xe\"><v:stroke joinstyle=\"miter\"/><v:path gradientshapeok=\"t\" o:connecttype=\"rect\"/></v:shapetype>";
856
917
  var INVALID_XML_CHAR_REGEX = /[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g;
857
918
  var sanitizeXmlText = function (value) {
858
919
  if (!value)
@@ -910,9 +971,9 @@ var getRowsForSheet = function (sheetData, sheetId) {
910
971
  return ((_d = (_b = (_a = sheetData[sheetId]) !== null && _a !== void 0 ? _a : sheetData[String(sheetId)]) !== null && _b !== void 0 ? _b : sheetData[Number(sheetId)]) !== null && _d !== void 0 ? _d : []);
911
972
  };
912
973
  var buildWorksheetXml = function (_a) {
913
- var e_22, _b, e_23, _d, e_24, _e, e_25, _f, e_26, _g, e_27, _h;
974
+ var e_25, _b, e_26, _d, e_27, _e, e_28, _f, e_29, _g, e_30, _h;
914
975
  var _j, _k;
915
- var sheet = _a.sheet, rows = _a.rows, sharedStrings = _a.sharedStrings, sourceSharedStrings = _a.sourceSharedStrings, cellXfs = _a.cellXfs, styleBuilder = _a.styleBuilder, tables = _a.tables, relationships = _a.relationships, drawingContext = _a.drawingContext, conditionalFormats = _a.conditionalFormats, dataValidationsById = _a.dataValidationsById, dataValidations = _a.dataValidations, ignoreFormulaPatterns = _a.ignoreFormulaPatterns, citations = _a.citations, comments = _a.comments, personRegistry = _a.personRegistry, slicerRelIds = _a.slicerRelIds, sheetData = _a.sheetData, sheets = _a.sheets, locale = _a.locale, protectedRanges = _a.protectedRanges;
976
+ var sheet = _a.sheet, rows = _a.rows, sharedStrings = _a.sharedStrings, sourceSharedStrings = _a.sourceSharedStrings, cellXfs = _a.cellXfs, styleBuilder = _a.styleBuilder, tables = _a.tables, relationships = _a.relationships, drawingContext = _a.drawingContext, conditionalFormats = _a.conditionalFormats, dataValidationsById = _a.dataValidationsById, dataValidations = _a.dataValidations, ignoreFormulaPatterns = _a.ignoreFormulaPatterns, citations = _a.citations, comments = _a.comments, personRegistry = _a.personRegistry, slicerRelIds = _a.slicerRelIds, sheetData = _a.sheetData, sheets = _a.sheets, locale = _a.locale, protectedRanges = _a.protectedRanges, _l = _a.formControls, formControls = _l === void 0 ? [] : _l, _m = _a.ctrlProps, ctrlProps = _m === void 0 ? { parts: [] } : _m;
916
977
  var tableNameMap = buildTableNameMap(tables);
917
978
  var bounds = {
918
979
  minRow: Number.POSITIVE_INFINITY,
@@ -947,12 +1008,12 @@ var buildWorksheetXml = function (_a) {
947
1008
  }
948
1009
  }
949
1010
  }
950
- catch (e_22_1) { e_22 = { error: e_22_1 }; }
1011
+ catch (e_25_1) { e_25 = { error: e_25_1 }; }
951
1012
  finally {
952
1013
  try {
953
1014
  if (citations_1_1 && !citations_1_1.done && (_b = citations_1.return)) _b.call(citations_1);
954
1015
  }
955
- finally { if (e_22) throw e_22.error; }
1016
+ finally { if (e_25) throw e_25.error; }
956
1017
  }
957
1018
  }
958
1019
  if (dataValidations) {
@@ -962,8 +1023,8 @@ var buildWorksheetXml = function (_a) {
962
1023
  if (!rule.ranges)
963
1024
  continue;
964
1025
  try {
965
- for (var _l = (e_24 = void 0, __values(rule.ranges)), _m = _l.next(); !_m.done; _m = _l.next()) {
966
- var range = _m.value;
1026
+ for (var _o = (e_27 = void 0, __values(rule.ranges)), _p = _o.next(); !_p.done; _p = _o.next()) {
1027
+ var range = _p.value;
967
1028
  if (range.sheetId !== sheet.sheetId)
968
1029
  continue;
969
1030
  // Ranges from the DV import are already 1-indexed (addressToSelection
@@ -976,21 +1037,21 @@ var buildWorksheetXml = function (_a) {
976
1037
  }
977
1038
  }
978
1039
  }
979
- catch (e_24_1) { e_24 = { error: e_24_1 }; }
1040
+ catch (e_27_1) { e_27 = { error: e_27_1 }; }
980
1041
  finally {
981
1042
  try {
982
- if (_m && !_m.done && (_e = _l.return)) _e.call(_l);
1043
+ if (_p && !_p.done && (_e = _o.return)) _e.call(_o);
983
1044
  }
984
- finally { if (e_24) throw e_24.error; }
1045
+ finally { if (e_27) throw e_27.error; }
985
1046
  }
986
1047
  }
987
1048
  }
988
- catch (e_23_1) { e_23 = { error: e_23_1 }; }
1049
+ catch (e_26_1) { e_26 = { error: e_26_1 }; }
989
1050
  finally {
990
1051
  try {
991
1052
  if (dataValidations_1_1 && !dataValidations_1_1.done && (_d = dataValidations_1.return)) _d.call(dataValidations_1);
992
1053
  }
993
- finally { if (e_23) throw e_23.error; }
1054
+ finally { if (e_26) throw e_26.error; }
994
1055
  }
995
1056
  }
996
1057
  // Pre-scan for valid shared-formula leaders in this sheet. The cell-emit
@@ -1010,7 +1071,7 @@ var buildWorksheetXml = function (_a) {
1010
1071
  if (!Array.isArray(rowValues))
1011
1072
  continue;
1012
1073
  try {
1013
- for (var rowValues_1 = (e_25 = void 0, __values(rowValues)), rowValues_1_1 = rowValues_1.next(); !rowValues_1_1.done; rowValues_1_1 = rowValues_1.next()) {
1074
+ for (var rowValues_1 = (e_28 = void 0, __values(rowValues)), rowValues_1_1 = rowValues_1.next(); !rowValues_1_1.done; rowValues_1_1 = rowValues_1.next()) {
1014
1075
  var cell = rowValues_1_1.value;
1015
1076
  var sf = cell === null || cell === void 0 ? void 0 : cell.sf;
1016
1077
  if (sf && sf.ref && Number.isFinite(sf.si)) {
@@ -1018,12 +1079,12 @@ var buildWorksheetXml = function (_a) {
1018
1079
  }
1019
1080
  }
1020
1081
  }
1021
- catch (e_25_1) { e_25 = { error: e_25_1 }; }
1082
+ catch (e_28_1) { e_28 = { error: e_28_1 }; }
1022
1083
  finally {
1023
1084
  try {
1024
1085
  if (rowValues_1_1 && !rowValues_1_1.done && (_f = rowValues_1.return)) _f.call(rowValues_1);
1025
1086
  }
1026
- finally { if (e_25) throw e_25.error; }
1087
+ finally { if (e_28) throw e_28.error; }
1027
1088
  }
1028
1089
  }
1029
1090
  for (var rowIndex = 1; rowIndex < maxRows; rowIndex++) {
@@ -1109,28 +1170,46 @@ var buildWorksheetXml = function (_a) {
1109
1170
  var threadedCommentsXml = threadedCommentsCollector.toXml();
1110
1171
  if (threadedCommentsXml) {
1111
1172
  try {
1112
- for (var _o = __values(threadedCommentsCollector.legacyEntries()), _p = _o.next(); !_p.done; _p = _o.next()) {
1113
- var entry = _p.value;
1173
+ for (var _q = __values(threadedCommentsCollector.legacyEntries()), _s = _q.next(); !_s.done; _s = _q.next()) {
1174
+ var entry = _s.value;
1114
1175
  commentsCollector.add(entry.address, entry.text, entry.author);
1115
1176
  }
1116
1177
  }
1117
- catch (e_26_1) { e_26 = { error: e_26_1 }; }
1178
+ catch (e_29_1) { e_29 = { error: e_29_1 }; }
1118
1179
  finally {
1119
1180
  try {
1120
- if (_p && !_p.done && (_g = _o.return)) _g.call(_o);
1181
+ if (_s && !_s.done && (_g = _q.return)) _g.call(_q);
1121
1182
  }
1122
- finally { if (e_26) throw e_26.error; }
1183
+ finally { if (e_29) throw e_29.error; }
1123
1184
  }
1124
1185
  relationships.add(THREADED_COMMENT_REL_TYPE, "../threadedComments/threadedComment".concat(sheet.sheetId, ".xml"));
1125
1186
  }
1126
1187
  // Generate comments XML (notes) and add relationships if there are comments
1127
1188
  var commentsXml = commentsCollector.toXml();
1128
- var legacyDrawingXml = "";
1129
1189
  if (commentsXml) {
1130
1190
  relationships.add(COMMENTS_REL_TYPE, "../comments".concat(sheet.sheetId, ".xml"));
1191
+ }
1192
+ // Notes and form controls share the sheet's one legacy VML part
1193
+ // (`<legacyDrawing>`); a control without its VML shape is dropped by Excel.
1194
+ var noteVmlShapes = commentsCollector.toVmlShapes();
1195
+ var formControlBuild = buildSheetFormControls({
1196
+ sheet: sheet,
1197
+ controls: formControls,
1198
+ relationships: relationships,
1199
+ ctrlProps: ctrlProps,
1200
+ zIndexStart: noteVmlShapes.length,
1201
+ reservedShapeIds: commentsCollector.vmlShapeIds(),
1202
+ });
1203
+ var vmlDrawingXml = buildVmlDrawingXml({
1204
+ shapeTypes: __spreadArray(__spreadArray([], __read((noteVmlShapes.length ? [NOTE_VML_SHAPETYPE] : [])), false), __read((formControlBuild.vmlShapes.length ? [FORM_CONTROL_VML_SHAPETYPE] : [])), false),
1205
+ shapes: __spreadArray(__spreadArray([], __read(noteVmlShapes), false), __read(formControlBuild.vmlShapes), false),
1206
+ });
1207
+ var legacyDrawingXml = "";
1208
+ if (vmlDrawingXml) {
1131
1209
  var legacyDrawingRelId = relationships.add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing", "../drawings/vmlDrawing".concat(sheet.sheetId, ".vml"));
1132
1210
  legacyDrawingXml = "<legacyDrawing r:id=\"".concat(legacyDrawingRelId, "\"/>");
1133
1211
  }
1212
+ var controlsXml = formControlBuild.controlsXml;
1134
1213
  var sheetDataXml = "<sheetData>".concat(rowXmlChunks.join(""), "</sheetData>");
1135
1214
  var protectionXml = buildSheetProtectionXml(sheet, protectedRanges);
1136
1215
  var printSettingsXml = buildPrintSettingsXml(sheet.printSettings);
@@ -1141,19 +1220,19 @@ var buildWorksheetXml = function (_a) {
1141
1220
  if (row === null || row === void 0 ? void 0 : row.values) {
1142
1221
  var rowValues = {};
1143
1222
  try {
1144
- for (var _q = (e_27 = void 0, __values(Object.entries(row.values))), _s = _q.next(); !_s.done; _s = _q.next()) {
1145
- var _t = __read(_s.value, 2), colIndex = _t[0], cell = _t[1];
1223
+ for (var _t = (e_30 = void 0, __values(Object.entries(row.values))), _u = _t.next(); !_u.done; _u = _t.next()) {
1224
+ var _v = __read(_u.value, 2), colIndex = _v[0], cell = _v[1];
1146
1225
  if (cell) {
1147
1226
  rowValues[parseInt(colIndex, 10)] = cell;
1148
1227
  }
1149
1228
  }
1150
1229
  }
1151
- catch (e_27_1) { e_27 = { error: e_27_1 }; }
1230
+ catch (e_30_1) { e_30 = { error: e_30_1 }; }
1152
1231
  finally {
1153
1232
  try {
1154
- if (_s && !_s.done && (_h = _q.return)) _h.call(_q);
1233
+ if (_u && !_u.done && (_h = _t.return)) _h.call(_t);
1155
1234
  }
1156
- finally { if (e_27) throw e_27.error; }
1235
+ finally { if (e_30) throw e_30.error; }
1157
1236
  }
1158
1237
  if (Object.keys(rowValues).length > 0) {
1159
1238
  rowDataMap[rowIndex] = rowValues;
@@ -1176,13 +1255,13 @@ var buildWorksheetXml = function (_a) {
1176
1255
  explicitDefaultColumnWidthPx > 0) {
1177
1256
  sheetFormatPrAttrs.push("defaultColWidth=\"".concat(columnPixelToChars(explicitDefaultColumnWidthPx).toFixed(2), "\""));
1178
1257
  }
1179
- var worksheetXml = "".concat(XML_DECLARATION, "<worksheet xmlns=\"").concat(WORKSHEET_NS, "\" xmlns:r=\"").concat(REL_NS, "\">").concat(sheetPrXml, "<dimension ref=\"").concat(dimension, "\"/>").concat(sheetViews, "<sheetFormatPr ").concat(sheetFormatPrAttrs.join(" "), "/>").concat(columnXml).concat(sheetDataXml).concat(protectionXml).concat(basicFilterXml).concat(mergeXml).concat(conditionalFormattingXml).concat(dataValidationsXml).concat(hyperlinksXml).concat(printSettingsXml).concat(drawingXml).concat(legacyDrawingXml).concat(tablePartsXml).concat(extLstXml, "</worksheet>");
1258
+ var worksheetXml = "".concat(XML_DECLARATION, "<worksheet xmlns=\"").concat(WORKSHEET_NS, "\" xmlns:r=\"").concat(REL_NS, "\">").concat(sheetPrXml, "<dimension ref=\"").concat(dimension, "\"/>").concat(sheetViews, "<sheetFormatPr ").concat(sheetFormatPrAttrs.join(" "), "/>").concat(columnXml).concat(sheetDataXml).concat(protectionXml).concat(basicFilterXml).concat(mergeXml).concat(conditionalFormattingXml).concat(dataValidationsXml).concat(hyperlinksXml).concat(printSettingsXml).concat(drawingXml).concat(legacyDrawingXml).concat(controlsXml).concat(tablePartsXml).concat(extLstXml, "</worksheet>");
1180
1259
  return {
1181
1260
  xml: worksheetXml,
1182
1261
  relationshipsXml: relationships.toXml(),
1183
1262
  images: collectedImages,
1184
1263
  commentsXml: commentsXml,
1185
- vmlDrawingXml: commentsCollector.toVmlXml(),
1264
+ vmlDrawingXml: vmlDrawingXml,
1186
1265
  threadedCommentsXml: threadedCommentsXml,
1187
1266
  };
1188
1267
  };
@@ -1237,7 +1316,7 @@ var sanitizeIndex = function (value) {
1237
1316
  return Math.max(1, Math.floor(value));
1238
1317
  };
1239
1318
  var normalizeMergeRanges = function (ranges) {
1240
- var e_28, _a;
1319
+ var e_31, _a;
1241
1320
  if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length))
1242
1321
  return [];
1243
1322
  var sanitized = ranges
@@ -1279,12 +1358,12 @@ var normalizeMergeRanges = function (ranges) {
1279
1358
  _loop_3(merge);
1280
1359
  }
1281
1360
  }
1282
- catch (e_28_1) { e_28 = { error: e_28_1 }; }
1361
+ catch (e_31_1) { e_31 = { error: e_31_1 }; }
1283
1362
  finally {
1284
1363
  try {
1285
1364
  if (sorted_1_1 && !sorted_1_1.done && (_a = sorted_1.return)) _a.call(sorted_1);
1286
1365
  }
1287
- finally { if (e_28) throw e_28.error; }
1366
+ finally { if (e_31) throw e_31.error; }
1288
1367
  }
1289
1368
  return valid;
1290
1369
  };
@@ -1651,7 +1730,7 @@ var buildWorksheetRow = function (_a) {
1651
1730
  };
1652
1731
  };
1653
1732
  var buildCellXml = function (_a) {
1654
- var e_29, _b;
1733
+ var e_32, _b;
1655
1734
  var _d, _e, _f, _g, _h, _j, _k, _l;
1656
1735
  var rowNumber = _a.rowNumber, columnIndex = _a.columnIndex, cell = _a.cell, sharedStrings = _a.sharedStrings, sourceSharedStrings = _a.sourceSharedStrings, cellXfs = _a.cellXfs, styleBuilder = _a.styleBuilder, onImage = _a.onImage, onHyperlink = _a.onHyperlink, dataValidationsById = _a.dataValidationsById, onDataValidation = _a.onDataValidation, tableNameMap = _a.tableNameMap, tables = _a.tables, ignoreFormulaPatterns = _a.ignoreFormulaPatterns, commentsCollector = _a.commentsCollector, onCommentThread = _a.onCommentThread, sheetId = _a.sheetId, sheetData = _a.sheetData, sheets = _a.sheets, locale = _a.locale, validSharedFormulaLeaders = _a.validSharedFormulaLeaders;
1657
1736
  var normalizedCell = cell;
@@ -1748,12 +1827,12 @@ var buildCellXml = function (_a) {
1748
1827
  sheetIdByName_1.set(s.title, s.sheetId);
1749
1828
  }
1750
1829
  }
1751
- catch (e_29_1) { e_29 = { error: e_29_1 }; }
1830
+ catch (e_32_1) { e_32 = { error: e_32_1 }; }
1752
1831
  finally {
1753
1832
  try {
1754
1833
  if (sheets_1_1 && !sheets_1_1.done && (_b = sheets_1.return)) _b.call(sheets_1);
1755
1834
  }
1756
- finally { if (e_29) throw e_29.error; }
1835
+ finally { if (e_32) throw e_32.error; }
1757
1836
  }
1758
1837
  // A real CellXfsRegistry so `SheetCell.assign` inside the derive
1759
1838
  // helper can resolve precedent cells whose `uf` is a `{ sid }` style
@@ -1990,7 +2069,7 @@ function isValidExcelDateSerial(value) {
1990
2069
  return value >= MIN_EXCEL_DATE_SERIAL && value <= MAX_EXCEL_DATE_SERIAL;
1991
2070
  }
1992
2071
  function rewriteTableNamesInFormula(formula, tableNameMap) {
1993
- var e_30, _a;
2072
+ var e_33, _a;
1994
2073
  if (!(tableNameMap === null || tableNameMap === void 0 ? void 0 : tableNameMap.size))
1995
2074
  return formula;
1996
2075
  var normalized = formula;
@@ -2005,12 +2084,12 @@ function rewriteTableNamesInFormula(formula, tableNameMap) {
2005
2084
  normalized = normalized.replace(new RegExp("".concat(escaped, "(?=\\[)"), "g"), exportedName);
2006
2085
  }
2007
2086
  }
2008
- catch (e_30_1) { e_30 = { error: e_30_1 }; }
2087
+ catch (e_33_1) { e_33 = { error: e_33_1 }; }
2009
2088
  finally {
2010
2089
  try {
2011
2090
  if (tableNameMap_1_1 && !tableNameMap_1_1.done && (_a = tableNameMap_1.return)) _a.call(tableNameMap_1);
2012
2091
  }
2013
- finally { if (e_30) throw e_30.error; }
2092
+ finally { if (e_33) throw e_33.error; }
2014
2093
  }
2015
2094
  return normalized;
2016
2095
  }
@@ -2410,7 +2489,7 @@ var buildRichRunProperties = function (format) {
2410
2489
  * style flag, but that's a cell-style concern, not a sharedString one.
2411
2490
  */
2412
2491
  var buildRichTextRuns = function (text, runs) {
2413
- var e_31, _a;
2492
+ var e_34, _a;
2414
2493
  var sorted = __spreadArray([], __read(runs), false).sort(function (a, b) { return a.startIndex - b.startIndex; });
2415
2494
  var out = [];
2416
2495
  var cursor = 0;
@@ -2443,12 +2522,12 @@ var buildRichTextRuns = function (text, runs) {
2443
2522
  cursor = end;
2444
2523
  }
2445
2524
  }
2446
- catch (e_31_1) { e_31 = { error: e_31_1 }; }
2525
+ catch (e_34_1) { e_34 = { error: e_34_1 }; }
2447
2526
  finally {
2448
2527
  try {
2449
2528
  if (sorted_2_1 && !sorted_2_1.done && (_a = sorted_2.return)) _a.call(sorted_2);
2450
2529
  }
2451
- finally { if (e_31) throw e_31.error; }
2530
+ finally { if (e_34) throw e_34.error; }
2452
2531
  }
2453
2532
  if (cursor < text.length) {
2454
2533
  emit(text.slice(cursor), "");
@@ -2469,7 +2548,7 @@ var buildSharedStringsXml = function (sharedStrings) {
2469
2548
  return "".concat(XML_DECLARATION, "<sst xmlns=\"").concat(WORKSHEET_NS, "\" count=\"").concat(sharedStrings.totalCount, "\" uniqueCount=\"").concat(sharedStrings.entries.length, "\">").concat(entries, "</sst>");
2470
2549
  };
2471
2550
  var buildTableNameMap = function (tables) {
2472
- var e_32, _a;
2551
+ var e_35, _a;
2473
2552
  var _b;
2474
2553
  var map = new Map();
2475
2554
  try {
@@ -2481,12 +2560,12 @@ var buildTableNameMap = function (tables) {
2481
2560
  map.set(tableTitle, table.name);
2482
2561
  }
2483
2562
  }
2484
- catch (e_32_1) { e_32 = { error: e_32_1 }; }
2563
+ catch (e_35_1) { e_35 = { error: e_35_1 }; }
2485
2564
  finally {
2486
2565
  try {
2487
2566
  if (tables_1_1 && !tables_1_1.done && (_a = tables_1.return)) _a.call(tables_1);
2488
2567
  }
2489
- finally { if (e_32) throw e_32.error; }
2568
+ finally { if (e_35) throw e_35.error; }
2490
2569
  }
2491
2570
  return map;
2492
2571
  };
@@ -2494,7 +2573,7 @@ var buildTableNameMap = function (tables) {
2494
2573
  // whose box intersects another table on the same sheet. Drop both before
2495
2574
  // emitting so the workbook opens without "We found a problem" recovery prompts.
2496
2575
  var filterExportableTables = function (tables) {
2497
- var e_33, _a;
2576
+ var e_36, _a;
2498
2577
  var _b;
2499
2578
  var isValidBox = function (range) {
2500
2579
  if (!range)
@@ -2537,12 +2616,12 @@ var filterExportableTables = function (tables) {
2537
2616
  _loop_4(table);
2538
2617
  }
2539
2618
  }
2540
- catch (e_33_1) { e_33 = { error: e_33_1 }; }
2619
+ catch (e_36_1) { e_36 = { error: e_36_1 }; }
2541
2620
  finally {
2542
2621
  try {
2543
2622
  if (tables_2_1 && !tables_2_1.done && (_a = tables_2.return)) _a.call(tables_2);
2544
2623
  }
2545
- finally { if (e_33) throw e_33.error; }
2624
+ finally { if (e_36) throw e_36.error; }
2546
2625
  }
2547
2626
  return result;
2548
2627
  };
@@ -2767,7 +2846,7 @@ var SHEET_PROTECTION_FLAG_ATTRS = [
2767
2846
  * Excel's schema default applies). Mirrors `rnc-export`'s `sheet_protection_xml`.
2768
2847
  */
2769
2848
  var buildSheetProtectionElementXml = function (protection) {
2770
- var e_34, _a;
2849
+ var e_37, _a;
2771
2850
  var attrs = [];
2772
2851
  if (protection.algorithmName) {
2773
2852
  attrs.push("algorithmName=\"".concat(escapeXmlAttr(protection.algorithmName), "\""));
@@ -2793,12 +2872,12 @@ var buildSheetProtectionElementXml = function (protection) {
2793
2872
  }
2794
2873
  }
2795
2874
  }
2796
- catch (e_34_1) { e_34 = { error: e_34_1 }; }
2875
+ catch (e_37_1) { e_37 = { error: e_37_1 }; }
2797
2876
  finally {
2798
2877
  try {
2799
2878
  if (SHEET_PROTECTION_FLAG_ATTRS_1_1 && !SHEET_PROTECTION_FLAG_ATTRS_1_1.done && (_a = SHEET_PROTECTION_FLAG_ATTRS_1.return)) _a.call(SHEET_PROTECTION_FLAG_ATTRS_1);
2800
2879
  }
2801
- finally { if (e_34) throw e_34.error; }
2880
+ finally { if (e_37) throw e_37.error; }
2802
2881
  }
2803
2882
  return attrs.length ? "<sheetProtection ".concat(attrs.join(" "), "/>") : "";
2804
2883
  };
@@ -2810,7 +2889,7 @@ var buildSheetProtectionElementXml = function (protection) {
2810
2889
  * is the range's id, synthesized as `Range{n}` when absent (schema requires it).
2811
2890
  */
2812
2891
  var buildSheetProtectionXml = function (sheet, protectedRanges) {
2813
- var e_35, _a;
2892
+ var e_38, _a;
2814
2893
  var protectionXml = sheet.sheetProtection
2815
2894
  ? buildSheetProtectionElementXml(sheet.sheetProtection)
2816
2895
  : "";
@@ -2851,12 +2930,12 @@ var buildSheetProtectionXml = function (sheet, protectedRanges) {
2851
2930
  rangeItems.push("<protectedRange sqref=\"".concat(escapeXmlAttr(sqref), "\" name=\"").concat(escapeXmlAttr(name_1), "\"").concat(securityDescriptor, "/>"));
2852
2931
  }
2853
2932
  }
2854
- catch (e_35_1) { e_35 = { error: e_35_1 }; }
2933
+ catch (e_38_1) { e_38 = { error: e_38_1 }; }
2855
2934
  finally {
2856
2935
  try {
2857
2936
  if (_d && !_d.done && (_a = _b.return)) _a.call(_b);
2858
2937
  }
2859
- finally { if (e_35) throw e_35.error; }
2938
+ finally { if (e_38) throw e_38.error; }
2860
2939
  }
2861
2940
  var rangesXml = rangeItems.length
2862
2941
  ? "<protectedRanges>".concat(rangeItems.join(""), "</protectedRanges>")
@@ -3116,6 +3195,133 @@ var groupTextBoxesBySheet = function (embeds) {
3116
3195
  });
3117
3196
  return result;
3118
3197
  };
3198
+ /** Form-control embeds (`spec.type === "formControl"`) by sheet, in host order. */
3199
+ var groupFormControlsBySheet = function (embeds) {
3200
+ var result = new Map();
3201
+ (embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed, order) {
3202
+ var _a, _b, _d, _e, _f, _g, _h;
3203
+ if (!((_a = embed.position) === null || _a === void 0 ? void 0 : _a.overlayPosition))
3204
+ return;
3205
+ if (((_b = embed.spec) === null || _b === void 0 ? void 0 : _b.type) !== "formControl")
3206
+ return;
3207
+ var overlay = embed.position.overlayPosition;
3208
+ var placement = {
3209
+ shape: embed,
3210
+ order: order,
3211
+ rowIndex: overlay.anchorCell.rowIndex,
3212
+ columnIndex: overlay.anchorCell.columnIndex,
3213
+ offsetX: (_d = overlay.offsetXPixels) !== null && _d !== void 0 ? _d : 0,
3214
+ offsetY: (_e = overlay.offsetYPixels) !== null && _e !== void 0 ? _e : 0,
3215
+ width: (_f = overlay.widthPixels) !== null && _f !== void 0 ? _f : 120,
3216
+ height: (_g = overlay.heightPixels) !== null && _g !== void 0 ? _g : 20,
3217
+ };
3218
+ var list = (_h = result.get(embed.position.sheetId)) !== null && _h !== void 0 ? _h : [];
3219
+ list.push(placement);
3220
+ result.set(embed.position.sheetId, list);
3221
+ });
3222
+ return result;
3223
+ };
3224
+ /**
3225
+ * Write a sheet's form controls: one ctrlProp part + sheet relationship per
3226
+ * control, the `<controls>` worksheet element, and the VML shapes Excel
3227
+ * draws them with (merged into the sheet's `vmlDrawing` alongside notes).
3228
+ */
3229
+ var buildSheetFormControls = function (_a) {
3230
+ var sheet = _a.sheet, controls = _a.controls, relationships = _a.relationships, ctrlProps = _a.ctrlProps, zIndexStart = _a.zIndexStart, reservedShapeIds = _a.reservedShapeIds;
3231
+ if (!controls.length)
3232
+ return { controlsXml: "", vmlShapes: [] };
3233
+ var controlElements = [];
3234
+ var vmlShapes = [];
3235
+ // Excel numbers notes and form-control shapes from one per-sheet counter
3236
+ // (1025 upward); a control that arrived with its own id keeps it unless it
3237
+ // collides with a note shape or another control.
3238
+ var usedShapeIds = new Set(reservedShapeIds);
3239
+ var nextShapeId = 1025;
3240
+ var allocateShapeId = function (wanted) {
3241
+ if (wanted && Number.isInteger(wanted) && !usedShapeIds.has(wanted)) {
3242
+ usedShapeIds.add(wanted);
3243
+ return wanted;
3244
+ }
3245
+ while (usedShapeIds.has(nextShapeId))
3246
+ nextShapeId += 1;
3247
+ usedShapeIds.add(nextShapeId);
3248
+ return nextShapeId++;
3249
+ };
3250
+ var sumSizes = function (count, getSize) {
3251
+ var total = 0;
3252
+ for (var index = 0; index < count; index++)
3253
+ total += getSize(index);
3254
+ return total;
3255
+ };
3256
+ controls.forEach(function (placement, position) {
3257
+ var _a, _b, _d, _e;
3258
+ var spec = placement.shape.spec;
3259
+ var fromRow = Math.max(0, placement.rowIndex - 1);
3260
+ var fromColumn = Math.max(0, placement.columnIndex - 1);
3261
+ var offsetX = Math.max(0, (_a = placement.offsetX) !== null && _a !== void 0 ? _a : 0);
3262
+ var offsetY = Math.max(0, (_b = placement.offsetY) !== null && _b !== void 0 ? _b : 0);
3263
+ var widthPx = Math.max(5, (_d = placement.width) !== null && _d !== void 0 ? _d : 120);
3264
+ var heightPx = Math.max(5, (_e = placement.height) !== null && _e !== void 0 ? _e : 20);
3265
+ var columnSize = function (index) { return getColumnWidthPx(sheet, index, true); };
3266
+ var rowSize = function (index) { return getRowHeightPx(sheet, index, true); };
3267
+ var toColumn = resolveAnchorEndpoint({
3268
+ startIndex: fromColumn,
3269
+ startOffset: offsetX,
3270
+ span: widthPx,
3271
+ getSize: columnSize,
3272
+ });
3273
+ var toRow = resolveAnchorEndpoint({
3274
+ startIndex: fromRow,
3275
+ startOffset: offsetY,
3276
+ span: heightPx,
3277
+ getSize: rowSize,
3278
+ });
3279
+ var partIndex = ctrlProps.parts.length + 1;
3280
+ var path = "xl/ctrlProps/ctrlProp".concat(partIndex, ".xml");
3281
+ ctrlProps.parts.push({ path: path, xml: buildCtrlPropXml(spec) });
3282
+ var relId = relationships.add(CTRL_PROP_REL_TYPE, "../ctrlProps/ctrlProp".concat(partIndex, ".xml"));
3283
+ var shapeId = allocateShapeId(spec.shapeId);
3284
+ controlElements.push(buildControlElementXml({
3285
+ spec: spec,
3286
+ relId: relId,
3287
+ shapeId: shapeId,
3288
+ from: {
3289
+ col: fromColumn,
3290
+ colOff: offsetX * EMUS_PER_PIXEL,
3291
+ row: fromRow,
3292
+ rowOff: offsetY * EMUS_PER_PIXEL,
3293
+ },
3294
+ to: {
3295
+ col: toColumn.index,
3296
+ colOff: toColumn.offset * EMUS_PER_PIXEL,
3297
+ row: toRow.index,
3298
+ rowOff: toRow.offset * EMUS_PER_PIXEL,
3299
+ },
3300
+ }));
3301
+ vmlShapes.push(buildFormControlVmlShape({
3302
+ spec: spec,
3303
+ shapeId: shapeId,
3304
+ zIndex: zIndexStart + position + 1,
3305
+ geometry: {
3306
+ leftPx: sumSizes(fromColumn, columnSize) + offsetX,
3307
+ topPx: sumSizes(fromRow, rowSize) + offsetY,
3308
+ widthPx: widthPx,
3309
+ heightPx: heightPx,
3310
+ anchor: [
3311
+ fromColumn,
3312
+ Math.round(offsetX),
3313
+ fromRow,
3314
+ Math.round(offsetY),
3315
+ toColumn.index,
3316
+ Math.round(toColumn.offset),
3317
+ toRow.index,
3318
+ Math.round(toRow.offset),
3319
+ ],
3320
+ },
3321
+ }));
3322
+ });
3323
+ return { controlsXml: buildControlsXml(controlElements), vmlShapes: vmlShapes };
3324
+ };
3119
3325
  var groupShapesBySheet = function (embeds) {
3120
3326
  var result = new Map();
3121
3327
  (embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed, order) {
@@ -3142,7 +3348,7 @@ var groupShapesBySheet = function (embeds) {
3142
3348
  return result;
3143
3349
  };
3144
3350
  var groupChartsBySheet = function (charts) {
3145
- var e_36, _a;
3351
+ var e_39, _a;
3146
3352
  var _b, _d, _e, _f, _g, _h;
3147
3353
  var result = new Map();
3148
3354
  try {
@@ -3165,17 +3371,17 @@ var groupChartsBySheet = function (charts) {
3165
3371
  result.set(chart.position.sheetId, list);
3166
3372
  }
3167
3373
  }
3168
- catch (e_36_1) { e_36 = { error: e_36_1 }; }
3374
+ catch (e_39_1) { e_39 = { error: e_39_1 }; }
3169
3375
  finally {
3170
3376
  try {
3171
3377
  if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
3172
3378
  }
3173
- finally { if (e_36) throw e_36.error; }
3379
+ finally { if (e_39) throw e_39.error; }
3174
3380
  }
3175
3381
  return result;
3176
3382
  };
3177
3383
  var groupSlicersBySheet = function (slicers) {
3178
- var e_37, _a;
3384
+ var e_40, _a;
3179
3385
  var _b, _d, _e, _f, _g, _h;
3180
3386
  var result = new Map();
3181
3387
  try {
@@ -3198,17 +3404,17 @@ var groupSlicersBySheet = function (slicers) {
3198
3404
  result.set(slicer.position.sheetId, list);
3199
3405
  }
3200
3406
  }
3201
- catch (e_37_1) { e_37 = { error: e_37_1 }; }
3407
+ catch (e_40_1) { e_40 = { error: e_40_1 }; }
3202
3408
  finally {
3203
3409
  try {
3204
3410
  if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
3205
3411
  }
3206
- finally { if (e_37) throw e_37.error; }
3412
+ finally { if (e_40) throw e_40.error; }
3207
3413
  }
3208
3414
  return result;
3209
3415
  };
3210
3416
  var buildConditionalFormattingXml = function (_a) {
3211
- var e_38, _b;
3417
+ var e_41, _b;
3212
3418
  var _d, _e, _f;
3213
3419
  var conditionalFormats = _a.conditionalFormats, sheetId = _a.sheetId, styleBuilder = _a.styleBuilder;
3214
3420
  if (!(conditionalFormats === null || conditionalFormats === void 0 ? void 0 : conditionalFormats.length)) {
@@ -3272,12 +3478,12 @@ var buildConditionalFormattingXml = function (_a) {
3272
3478
  parts.push("<conditionalFormatting sqref=\"".concat(sqrefParts.join(" "), "\">").concat(ruleXmlEntries.join(""), "</conditionalFormatting>"));
3273
3479
  }
3274
3480
  }
3275
- catch (e_38_1) { e_38 = { error: e_38_1 }; }
3481
+ catch (e_41_1) { e_41 = { error: e_41_1 }; }
3276
3482
  finally {
3277
3483
  try {
3278
3484
  if (orderedRules_1_1 && !orderedRules_1_1.done && (_b = orderedRules_1.return)) _b.call(orderedRules_1);
3279
3485
  }
3280
- finally { if (e_38) throw e_38.error; }
3486
+ finally { if (e_41) throw e_41.error; }
3281
3487
  }
3282
3488
  return parts.join("");
3283
3489
  };
@@ -3773,11 +3979,11 @@ var buildConditionalFormattingRuleXml = function (_a) {
3773
3979
  return rules.length ? rules : undefined;
3774
3980
  };
3775
3981
  var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
3776
- var anchors, relationships, media, imageIndex, chartIndex, pictureId, frameId, chartEntries, charts_1, charts_1_1, placement, chartXml, relId, slicers_1, slicers_1_1, placement, embedAnchors, orderOf, textBoxes_1, textBoxes_1_1, placement, shapes_1, shapes_1_1, placement, placements_1, placements_1_1, placement, dataUrl, buffer, mediaPath, relId, e_39_1, embedAnchors_1, embedAnchors_1_1, entry, drawingXml;
3777
- var e_40, _d, e_41, _e, e_42, _f, e_43, _g, e_39, _h, e_44, _j;
3778
- var placements = _b.placements, textBoxes = _b.textBoxes, _k = _b.shapes, shapes = _k === void 0 ? [] : _k, startImageIndex = _b.startImageIndex, startChartIndex = _b.startChartIndex, charts = _b.charts, slicers = _b.slicers, sheet = _b.sheet, sheetNameById = _b.sheetNameById;
3779
- return __generator(this, function (_l) {
3780
- switch (_l.label) {
3982
+ var anchors, relationships, media, imageIndex, chartIndex, chartExIndex, pictureId, frameId, chartEntries, chartExEntries, charts_1, charts_1_1, placement, chartExXml, relId_1, chartXml, relId, slicers_1, slicers_1_1, placement, embedAnchors, orderOf, textBoxes_1, textBoxes_1_1, placement, shapes_1, shapes_1_1, placement, placements_1, placements_1_1, placement, dataUrl, buffer, mediaPath, relId, e_42_1, embedAnchors_1, embedAnchors_1_1, entry, drawingXml;
3983
+ var e_43, _d, e_44, _e, e_45, _f, e_46, _g, e_42, _h, e_47, _j;
3984
+ var placements = _b.placements, textBoxes = _b.textBoxes, _k = _b.shapes, shapes = _k === void 0 ? [] : _k, startImageIndex = _b.startImageIndex, startChartIndex = _b.startChartIndex, _l = _b.startChartExIndex, startChartExIndex = _l === void 0 ? 1 : _l, charts = _b.charts, slicers = _b.slicers, sheet = _b.sheet, sheetNameById = _b.sheetNameById;
3985
+ return __generator(this, function (_m) {
3986
+ switch (_m.label) {
3781
3987
  case 0:
3782
3988
  if (!placements.length &&
3783
3989
  !textBoxes.length &&
@@ -3790,12 +3996,28 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
3790
3996
  media = [];
3791
3997
  imageIndex = startImageIndex;
3792
3998
  chartIndex = startChartIndex;
3999
+ chartExIndex = startChartExIndex;
3793
4000
  pictureId = 1;
3794
4001
  frameId = 1;
3795
4002
  chartEntries = [];
4003
+ chartExEntries = [];
3796
4004
  try {
3797
4005
  for (charts_1 = __values(charts), charts_1_1 = charts_1.next(); !charts_1_1.done; charts_1_1 = charts_1.next()) {
3798
4006
  placement = charts_1_1.value;
4007
+ if (isChartExType(placement.chart.spec.chartType)) {
4008
+ chartExXml = buildChartExXml(placement.chart, sheetNameById);
4009
+ if (!chartExXml)
4010
+ continue;
4011
+ relId_1 = relationships.add(CHART_EX_REL_TYPE, "../charts/chartEx".concat(chartExIndex, ".xml"));
4012
+ anchors.push(createChartAnchor({ sheet: sheet, placement: placement, relId: relId_1, frameId: frameId, chartEx: true }));
4013
+ chartExEntries.push({
4014
+ path: "xl/charts/chartEx".concat(chartExIndex, ".xml"),
4015
+ xml: chartExXml,
4016
+ });
4017
+ chartExIndex += 1;
4018
+ frameId += 1;
4019
+ continue;
4020
+ }
3799
4021
  chartXml = buildChartXml(placement.chart, sheetNameById);
3800
4022
  if (!chartXml)
3801
4023
  continue;
@@ -3814,12 +4036,12 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
3814
4036
  frameId += 1;
3815
4037
  }
3816
4038
  }
3817
- catch (e_40_1) { e_40 = { error: e_40_1 }; }
4039
+ catch (e_43_1) { e_43 = { error: e_43_1 }; }
3818
4040
  finally {
3819
4041
  try {
3820
4042
  if (charts_1_1 && !charts_1_1.done && (_d = charts_1.return)) _d.call(charts_1);
3821
4043
  }
3822
- finally { if (e_40) throw e_40.error; }
4044
+ finally { if (e_43) throw e_43.error; }
3823
4045
  }
3824
4046
  try {
3825
4047
  for (slicers_1 = __values(slicers), slicers_1_1 = slicers_1.next(); !slicers_1_1.done; slicers_1_1 = slicers_1.next()) {
@@ -3832,12 +4054,12 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
3832
4054
  frameId += 1;
3833
4055
  }
3834
4056
  }
3835
- catch (e_41_1) { e_41 = { error: e_41_1 }; }
4057
+ catch (e_44_1) { e_44 = { error: e_44_1 }; }
3836
4058
  finally {
3837
4059
  try {
3838
4060
  if (slicers_1_1 && !slicers_1_1.done && (_e = slicers_1.return)) _e.call(slicers_1);
3839
4061
  }
3840
- finally { if (e_41) throw e_41.error; }
4062
+ finally { if (e_44) throw e_44.error; }
3841
4063
  }
3842
4064
  embedAnchors = [];
3843
4065
  orderOf = function (order) {
@@ -3857,12 +4079,12 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
3857
4079
  frameId += 1;
3858
4080
  }
3859
4081
  }
3860
- catch (e_42_1) { e_42 = { error: e_42_1 }; }
4082
+ catch (e_45_1) { e_45 = { error: e_45_1 }; }
3861
4083
  finally {
3862
4084
  try {
3863
4085
  if (textBoxes_1_1 && !textBoxes_1_1.done && (_f = textBoxes_1.return)) _f.call(textBoxes_1);
3864
4086
  }
3865
- finally { if (e_42) throw e_42.error; }
4087
+ finally { if (e_45) throw e_45.error; }
3866
4088
  }
3867
4089
  try {
3868
4090
  for (shapes_1 = __values(shapes), shapes_1_1 = shapes_1.next(); !shapes_1_1.done; shapes_1_1 = shapes_1.next()) {
@@ -3878,24 +4100,24 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
3878
4100
  frameId += 1;
3879
4101
  }
3880
4102
  }
3881
- catch (e_43_1) { e_43 = { error: e_43_1 }; }
4103
+ catch (e_46_1) { e_46 = { error: e_46_1 }; }
3882
4104
  finally {
3883
4105
  try {
3884
4106
  if (shapes_1_1 && !shapes_1_1.done && (_g = shapes_1.return)) _g.call(shapes_1);
3885
4107
  }
3886
- finally { if (e_43) throw e_43.error; }
4108
+ finally { if (e_46) throw e_46.error; }
3887
4109
  }
3888
- _l.label = 1;
4110
+ _m.label = 1;
3889
4111
  case 1:
3890
- _l.trys.push([1, 6, 7, 8]);
4112
+ _m.trys.push([1, 6, 7, 8]);
3891
4113
  placements_1 = __values(placements), placements_1_1 = placements_1.next();
3892
- _l.label = 2;
4114
+ _m.label = 2;
3893
4115
  case 2:
3894
4116
  if (!!placements_1_1.done) return [3 /*break*/, 5];
3895
4117
  placement = placements_1_1.value;
3896
4118
  return [4 /*yield*/, resolveImageDataUrl(placement.imageUrl)];
3897
4119
  case 3:
3898
- dataUrl = _l.sent();
4120
+ dataUrl = _m.sent();
3899
4121
  if (!dataUrl)
3900
4122
  return [3 /*break*/, 4];
3901
4123
  buffer = dataUriToBuffer(dataUrl, placement.imageUrl);
@@ -3919,20 +4141,20 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
3919
4141
  });
3920
4142
  imageIndex += 1;
3921
4143
  pictureId += 1;
3922
- _l.label = 4;
4144
+ _m.label = 4;
3923
4145
  case 4:
3924
4146
  placements_1_1 = placements_1.next();
3925
4147
  return [3 /*break*/, 2];
3926
4148
  case 5: return [3 /*break*/, 8];
3927
4149
  case 6:
3928
- e_39_1 = _l.sent();
3929
- e_39 = { error: e_39_1 };
4150
+ e_42_1 = _m.sent();
4151
+ e_42 = { error: e_42_1 };
3930
4152
  return [3 /*break*/, 8];
3931
4153
  case 7:
3932
4154
  try {
3933
4155
  if (placements_1_1 && !placements_1_1.done && (_h = placements_1.return)) _h.call(placements_1);
3934
4156
  }
3935
- finally { if (e_39) throw e_39.error; }
4157
+ finally { if (e_42) throw e_42.error; }
3936
4158
  return [7 /*endfinally*/];
3937
4159
  case 8:
3938
4160
  embedAnchors.sort(function (a, b) { return a.order - b.order; });
@@ -3942,12 +4164,12 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
3942
4164
  anchors.push(entry.xml);
3943
4165
  }
3944
4166
  }
3945
- catch (e_44_1) { e_44 = { error: e_44_1 }; }
4167
+ catch (e_47_1) { e_47 = { error: e_47_1 }; }
3946
4168
  finally {
3947
4169
  try {
3948
4170
  if (embedAnchors_1_1 && !embedAnchors_1_1.done && (_j = embedAnchors_1.return)) _j.call(embedAnchors_1);
3949
4171
  }
3950
- finally { if (e_44) throw e_44.error; }
4172
+ finally { if (e_47) throw e_47.error; }
3951
4173
  }
3952
4174
  drawingXml = "".concat(XML_DECLARATION, "<xdr:wsDr xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"").concat(REL_NS, "\">").concat(anchors.join(""), "</xdr:wsDr>");
3953
4175
  return [2 /*return*/, {
@@ -3955,8 +4177,10 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
3955
4177
  relsXml: relationships.toXml(),
3956
4178
  media: media,
3957
4179
  charts: chartEntries,
4180
+ chartExs: chartExEntries,
3958
4181
  nextImageIndex: imageIndex,
3959
4182
  nextChartIndex: chartIndex,
4183
+ nextChartExIndex: chartExIndex,
3960
4184
  }];
3961
4185
  }
3962
4186
  });
@@ -4038,7 +4262,7 @@ var buildPictureAdjustmentsXml = function (adjustments) {
4038
4262
  };
4039
4263
  var createChartAnchor = function (_a) {
4040
4264
  var _b, _d, _e, _f;
4041
- var placement = _a.placement, relId = _a.relId, frameId = _a.frameId, sheet = _a.sheet;
4265
+ var placement = _a.placement, relId = _a.relId, frameId = _a.frameId, sheet = _a.sheet, _g = _a.chartEx, chartEx = _g === void 0 ? false : _g;
4042
4266
  var fromRow = Math.max(0, placement.rowIndex - 1);
4043
4267
  var fromColumn = Math.max(0, placement.columnIndex - 1);
4044
4268
  var offsetX = Math.max(0, (_b = placement.offsetX) !== null && _b !== void 0 ? _b : 0);
@@ -4059,6 +4283,14 @@ var createChartAnchor = function (_a) {
4059
4283
  });
4060
4284
  var fromXml = "<xdr:from><xdr:col>".concat(fromColumn, "</xdr:col><xdr:colOff>").concat(Math.round(offsetX * EMUS_PER_PIXEL), "</xdr:colOff><xdr:row>").concat(fromRow, "</xdr:row><xdr:rowOff>").concat(Math.round(offsetY * EMUS_PER_PIXEL), "</xdr:rowOff></xdr:from>");
4061
4285
  var toXml = "<xdr:to><xdr:col>".concat(toColumn.index, "</xdr:col><xdr:colOff>").concat(Math.round(toColumn.offset * EMUS_PER_PIXEL), "</xdr:colOff><xdr:row>").concat(toRow.index, "</xdr:row><xdr:rowOff>").concat(Math.round(toRow.offset * EMUS_PER_PIXEL), "</xdr:rowOff></xdr:to>");
4286
+ if (chartEx) {
4287
+ return "<xdr:twoCellAnchor>".concat(fromXml).concat(toXml).concat(buildChartExGraphicFrameXml({
4288
+ relId: relId,
4289
+ frameId: frameId,
4290
+ widthEmu: Math.round(widthPx * EMUS_PER_PIXEL),
4291
+ heightEmu: Math.round(heightPx * EMUS_PER_PIXEL),
4292
+ }), "<xdr:clientData/></xdr:twoCellAnchor>");
4293
+ }
4062
4294
  return "<xdr:twoCellAnchor>".concat(fromXml).concat(toXml, "<xdr:graphicFrame><xdr:nvGraphicFramePr><xdr:cNvPr id=\"").concat(frameId, "\" name=\"Chart ").concat(frameId, "\"/><xdr:cNvGraphicFramePr/></xdr:nvGraphicFramePr><xdr:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"").concat(Math.round(widthPx * EMUS_PER_PIXEL), "\" cy=\"").concat(Math.round(heightPx * EMUS_PER_PIXEL), "\"/></xdr:xfrm><a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"").concat(REL_NS, "\" r:id=\"").concat(relId, "\"/></a:graphicData></a:graphic></xdr:graphicFrame><xdr:clientData/></xdr:twoCellAnchor>");
4063
4295
  };
4064
4296
  var createSlicerAnchor = function (_a) {
@@ -4299,7 +4531,7 @@ var buildTextWithTabs = function (text, rPrXml) {
4299
4531
  .join("");
4300
4532
  };
4301
4533
  var buildTextBodyXml = function (spec) {
4302
- var e_45, _a;
4534
+ var e_48, _a;
4303
4535
  var richText = spec.richText || [];
4304
4536
  var plainText = spec.text || "";
4305
4537
  // Build vertical alignment and wrap attributes
@@ -4340,12 +4572,12 @@ var buildTextBodyXml = function (spec) {
4340
4572
  }
4341
4573
  }
4342
4574
  }
4343
- catch (e_45_1) { e_45 = { error: e_45_1 }; }
4575
+ catch (e_48_1) { e_48 = { error: e_48_1 }; }
4344
4576
  finally {
4345
4577
  try {
4346
4578
  if (richText_1_1 && !richText_1_1.done && (_a = richText_1.return)) _a.call(richText_1);
4347
4579
  }
4348
- finally { if (e_45) throw e_45.error; }
4580
+ finally { if (e_48) throw e_48.error; }
4349
4581
  }
4350
4582
  paragraphsXml = paragraphs
4351
4583
  .filter(function (runs) { return runs.length > 0; })
@@ -4789,7 +5021,7 @@ var buildWorkbookXml = function (sheets, sheetRelIds, sheetNames, namedRanges, i
4789
5021
  return "".concat(XML_DECLARATION, "<workbook xmlns=\"").concat(WORKSHEET_NS, "\" xmlns:r=\"").concat(REL_NS, "\">").concat(workbookPrXml).concat(calcPrXml, "<bookViews><workbookView activeTab=\"0\" firstSheet=\"0\"/></bookViews><sheets>").concat(sheetEntries, "</sheets>").concat(definedNamesXml).concat(externalReferencesXml).concat(pivotCachesXml).concat(slicerCachesXml, "</workbook>");
4790
5022
  };
4791
5023
  var buildDefinedNamesXml = function (namedRanges, sheetNameById, printScopes) {
4792
- var e_46, _a, e_47, _b;
5024
+ var e_49, _a, e_50, _b;
4793
5025
  var _d, _e, _f;
4794
5026
  if (printScopes === void 0) { printScopes = []; }
4795
5027
  var entries = [];
@@ -4819,12 +5051,12 @@ var buildDefinedNamesXml = function (namedRanges, sheetNameById, printScopes) {
4819
5051
  ], false));
4820
5052
  }
4821
5053
  }
4822
- catch (e_46_1) { e_46 = { error: e_46_1 }; }
5054
+ catch (e_49_1) { e_49 = { error: e_49_1 }; }
4823
5055
  finally {
4824
5056
  try {
4825
5057
  if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
4826
5058
  }
4827
- finally { if (e_46) throw e_46.error; }
5059
+ finally { if (e_49) throw e_49.error; }
4828
5060
  }
4829
5061
  printScopes.forEach(function (_a, index) {
4830
5062
  var _b;
@@ -4872,12 +5104,12 @@ var buildDefinedNamesXml = function (namedRanges, sheetNameById, printScopes) {
4872
5104
  entries.push("<definedName name=\"".concat(escapeXmlAttr(namedRange.name), "\"").concat(hiddenAttr, ">").concat(escapeXmlText(expression), "</definedName>"));
4873
5105
  }
4874
5106
  }
4875
- catch (e_47_1) { e_47 = { error: e_47_1 }; }
5107
+ catch (e_50_1) { e_50 = { error: e_50_1 }; }
4876
5108
  finally {
4877
5109
  try {
4878
5110
  if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
4879
5111
  }
4880
- finally { if (e_47) throw e_47.error; }
5112
+ finally { if (e_50) throw e_50.error; }
4881
5113
  }
4882
5114
  if (!entries.length)
4883
5115
  return "";
@@ -4967,7 +5199,7 @@ var buildWorkbookRelationships = function (sheetCount, slicerCacheCount, externa
4967
5199
  };
4968
5200
  };
4969
5201
  var buildContentTypesXml = function (_a) {
4970
- var sheetCount = _a.sheetCount, tableCount = _a.tableCount, drawingSheets = _a.drawingSheets, mediaExtensions = _a.mediaExtensions, chartCount = _a.chartCount, _b = _a.slicerCount, slicerCount = _b === void 0 ? 0 : _b, _d = _a.slicerCacheCount, slicerCacheCount = _d === void 0 ? 0 : _d, _e = _a.pivotTableCount, pivotTableCount = _e === void 0 ? 0 : _e, _f = _a.pivotCacheCount, pivotCacheCount = _f === void 0 ? 0 : _f, _g = _a.commentsSheets, commentsSheets = _g === void 0 ? [] : _g, _h = _a.threadedCommentsSheets, threadedCommentsSheets = _h === void 0 ? [] : _h, _j = _a.hasPersons, hasPersons = _j === void 0 ? false : _j, _k = _a.externalLinkCount, externalLinkCount = _k === void 0 ? 0 : _k;
5202
+ var sheetCount = _a.sheetCount, tableCount = _a.tableCount, drawingSheets = _a.drawingSheets, mediaExtensions = _a.mediaExtensions, chartCount = _a.chartCount, _b = _a.chartExCount, chartExCount = _b === void 0 ? 0 : _b, _d = _a.slicerCount, slicerCount = _d === void 0 ? 0 : _d, _e = _a.slicerCacheCount, slicerCacheCount = _e === void 0 ? 0 : _e, _f = _a.pivotTableCount, pivotTableCount = _f === void 0 ? 0 : _f, _g = _a.pivotCacheCount, pivotCacheCount = _g === void 0 ? 0 : _g, _h = _a.commentsSheets, commentsSheets = _h === void 0 ? [] : _h, _j = _a.threadedCommentsSheets, threadedCommentsSheets = _j === void 0 ? [] : _j, _k = _a.hasPersons, hasPersons = _k === void 0 ? false : _k, _l = _a.externalLinkCount, externalLinkCount = _l === void 0 ? 0 : _l, _m = _a.hasVmlDrawings, hasVmlDrawings = _m === void 0 ? false : _m, _o = _a.ctrlPropCount, ctrlPropCount = _o === void 0 ? 0 : _o;
4971
5203
  var sheetOverrides = Array.from({ length: sheetCount }, function (_, index) {
4972
5204
  return "<Override PartName=\"/xl/worksheets/sheet".concat(index + 1, ".xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\"/>");
4973
5205
  }).join("");
@@ -4982,6 +5214,9 @@ var buildContentTypesXml = function (_a) {
4982
5214
  var chartOverrides = Array.from({ length: chartCount }, function (_, index) {
4983
5215
  return "<Override PartName=\"/xl/charts/chart".concat(index + 1, ".xml\" ContentType=\"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\"/>");
4984
5216
  }).join("");
5217
+ var chartExOverrides = Array.from({ length: chartExCount }, function (_, index) {
5218
+ return "<Override PartName=\"/xl/charts/chartEx".concat(index + 1, ".xml\" ContentType=\"").concat(CHART_EX_CONTENT_TYPE, "\"/>");
5219
+ }).join("");
4985
5220
  var slicerOverrides = Array.from({ length: slicerCount }, function (_, index) {
4986
5221
  return "<Override PartName=\"/xl/slicers/slicer".concat(index + 1, ".xml\" ContentType=\"application/vnd.ms-excel.slicer+xml\"/>");
4987
5222
  }).join("");
@@ -5016,10 +5251,13 @@ var buildContentTypesXml = function (_a) {
5016
5251
  return "<Default Extension=\"".concat(extension, "\" ContentType=\"image/").concat(extension, "\"/>");
5017
5252
  })
5018
5253
  .join("");
5019
- var vmlDefault = commentsSheets.length
5254
+ var vmlDefault = hasVmlDrawings || commentsSheets.length
5020
5255
  ? "<Default Extension=\"vml\" ContentType=\"application/vnd.openxmlformats-officedocument.vmlDrawing\"/>"
5021
5256
  : "";
5022
- return "".concat(XML_DECLARATION, "<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\"><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/>").concat(vmlDefault).concat(mediaDefaults, "<Override PartName=\"/xl/workbook.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\"/>").concat(sheetOverrides).concat(tableOverrides).concat(drawingOverrides).concat(chartOverrides).concat(slicerOverrides).concat(slicerCacheOverrides).concat(pivotTableOverrides).concat(pivotCacheOverrides).concat(externalLinkOverrides).concat(commentsOverrides).concat(threadedCommentsOverrides).concat(personOverride, "<Override PartName=\"/xl/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/><Override PartName=\"/xl/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\"/><Override PartName=\"/xl/sharedStrings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/><Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/></Types>");
5257
+ var ctrlPropOverrides = Array.from({ length: ctrlPropCount }, function (_, index) {
5258
+ return "<Override PartName=\"/xl/ctrlProps/ctrlProp".concat(index + 1, ".xml\" ContentType=\"").concat(CTRL_PROP_CONTENT_TYPE, "\"/>");
5259
+ }).join("");
5260
+ return "".concat(XML_DECLARATION, "<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\"><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/>").concat(vmlDefault).concat(mediaDefaults, "<Override PartName=\"/xl/workbook.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\"/>").concat(sheetOverrides).concat(tableOverrides).concat(drawingOverrides).concat(chartOverrides).concat(chartExOverrides).concat(slicerOverrides).concat(slicerCacheOverrides).concat(pivotTableOverrides).concat(pivotCacheOverrides).concat(externalLinkOverrides).concat(ctrlPropOverrides).concat(commentsOverrides).concat(threadedCommentsOverrides).concat(personOverride, "<Override PartName=\"/xl/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/><Override PartName=\"/xl/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\"/><Override PartName=\"/xl/sharedStrings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/><Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/></Types>");
5023
5261
  };
5024
5262
  var buildRootRelationshipsXml = function () {
5025
5263
  return "".concat(XML_DECLARATION, "<Relationships xmlns=\"").concat(PACKAGE_REL_NS, "\"><Relationship Id=\"rId1\" Type=\"").concat(REL_NS, "/officeDocument\" Target=\"xl/workbook.xml\"/><Relationship Id=\"rId2\" Type=\"").concat(REL_NS, "/extended-properties\" Target=\"docProps/app.xml\"/><Relationship Id=\"rId3\" Type=\"").concat(REL_NS, "/core-properties\" Target=\"docProps/core.xml\"/></Relationships>");