@rowsncolumns/toolkit 24.4.4 → 24.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/autofilter-condition.d.ts +45 -1
- package/dist/cjs/autofilter-condition.d.ts.map +1 -1
- package/dist/cjs/autofilter-condition.js +135 -12
- package/dist/cjs/excel-parser/helpers.d.ts +15 -1
- package/dist/cjs/excel-parser/helpers.d.ts.map +1 -1
- package/dist/cjs/excel-parser/helpers.js +119 -5
- package/dist/cjs/excel-parser/interface.d.ts +3 -1
- package/dist/cjs/excel-parser/interface.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/index.js +186 -97
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts +15 -0
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/styles.js +80 -6
- package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsb/index.js +107 -103
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts +77 -1
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/charts.js +920 -122
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts +7 -1
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.js +24 -9
- package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts +24 -3
- package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/form-controls.js +25 -3
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +24 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.js +561 -394
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts +8 -2
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.js +312 -21
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts +6 -0
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.js +9 -0
- package/dist/cjs/excel-parser/plugins/xlsx/theme.d.ts +1 -1
- package/dist/cjs/excel-parser/types.d.ts +9 -1
- package/dist/cjs/excel-parser/types.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.d.ts +1 -0
- package/dist/cjs/excel-parser/workbook.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.js +5 -0
- package/dist/cjs/excel-parser/worker.js +2 -0
- package/dist/cjs/exporter/ods/ods-export.d.ts.map +1 -1
- package/dist/cjs/exporter/ods/ods-export.js +255 -80
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts +7 -1
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/chart-builder.js +902 -119
- package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts +16 -3
- package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/form-controls-builder.js +30 -8
- package/dist/cjs/exporter/xlsx/pivot-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/pivot-builder.js +206 -162
- package/dist/cjs/exporter/xlsx/style-builder.d.ts +8 -2
- package/dist/cjs/exporter/xlsx/style-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/style-builder.js +25 -0
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts +2 -2
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/xlsx-export.js +728 -452
- package/dist/esm/autofilter-condition.d.ts +45 -1
- package/dist/esm/autofilter-condition.d.ts.map +1 -1
- package/dist/esm/autofilter-condition.js +131 -11
- package/dist/esm/excel-parser/helpers.d.ts +15 -1
- package/dist/esm/excel-parser/helpers.d.ts.map +1 -1
- package/dist/esm/excel-parser/helpers.js +94 -4
- package/dist/esm/excel-parser/interface.d.ts +3 -1
- package/dist/esm/excel-parser/interface.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/index.js +105 -22
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts +15 -0
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/styles.js +79 -5
- package/dist/esm/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsb/index.js +15 -7
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts +77 -1
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/charts.js +708 -16
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts +7 -1
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/drawing.js +23 -0
- package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts +24 -3
- package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/form-controls.js +21 -3
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +24 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.js +192 -54
- package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts +8 -2
- package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/pivots.js +220 -4
- package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts +6 -0
- package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/relationships.js +9 -0
- package/dist/esm/excel-parser/plugins/xlsx/theme.d.ts +1 -1
- package/dist/esm/excel-parser/types.d.ts +9 -1
- package/dist/esm/excel-parser/types.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.d.ts +1 -0
- package/dist/esm/excel-parser/workbook.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.js +4 -0
- package/dist/esm/excel-parser/worker.js +2 -0
- package/dist/esm/exporter/ods/ods-export.d.ts.map +1 -1
- package/dist/esm/exporter/ods/ods-export.js +238 -72
- package/dist/esm/exporter/xlsx/chart-builder.d.ts +7 -1
- package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/chart-builder.js +674 -58
- package/dist/esm/exporter/xlsx/form-controls-builder.d.ts +16 -3
- package/dist/esm/exporter/xlsx/form-controls-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/form-controls-builder.js +29 -8
- package/dist/esm/exporter/xlsx/pivot-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/pivot-builder.js +187 -139
- package/dist/esm/exporter/xlsx/style-builder.d.ts +8 -2
- package/dist/esm/exporter/xlsx/style-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/style-builder.js +28 -0
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts +2 -2
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/xlsx-export.js +451 -197
- package/package.json +11 -4
|
@@ -2,8 +2,8 @@ import { __assign, __awaiter, __generator, __read, __spreadArray, __values } fro
|
|
|
2
2
|
import { cellRangeToAddress, cellToAddress, escapeCharacters, getCellEffectiveFormat, getCellEffectiveValue, getCellFormattedValue, getCellUserEnteredFormat, getCellUserEnteredValue, getExtendedValueBool, getExtendedValueError, getExtendedValueFormula, getExtendedValueNumber, getExtendedValueString, isNil, sortSheetsByIndex, } from "@rowsncolumns/utils";
|
|
3
3
|
import { zipSync } from "fflate";
|
|
4
4
|
import { omitInvalidDataValidationError } from "../invalid-data-validation";
|
|
5
|
-
import {
|
|
6
|
-
import { buildControlElementXml, buildControlsXml, buildCtrlPropXml, buildFormControlVmlShape, buildVmlDrawingXml, CTRL_PROP_CONTENT_TYPE, CTRL_PROP_REL_TYPE, FORM_CONTROL_VML_SHAPETYPE, } from "./form-controls-builder";
|
|
5
|
+
import { buildAutoFilterCriteriaXml } from "../../autofilter-condition";
|
|
6
|
+
import { buildControlElementXml, buildControlsXml, buildCtrlPropXml, buildFormControlVmlShape, controlAnchorFlags, buildVmlDrawingXml, CTRL_PROP_CONTENT_TYPE, CTRL_PROP_REL_TYPE, FORM_CONTROL_VML_SHAPETYPE, } from "./form-controls-builder";
|
|
7
7
|
import { buildChartExGraphicFrameXml, buildChartExXml, CHART_EX_CONTENT_TYPE, CHART_EX_REL_TYPE, isChartExType, } from "./chartex-builder";
|
|
8
8
|
import { applyPowerQueryParts } from "./power-query-builder";
|
|
9
9
|
import { encodeImplicitIntersection } from "../../helpers/implicit-intersection";
|
|
@@ -20,7 +20,7 @@ import { buildChartXml } from "./chart-builder";
|
|
|
20
20
|
import { buildPivotCacheDefinitionXml, buildPivotTableRelsXml, buildPivotTableXml, calculatedFieldReferences, } from "./pivot-builder";
|
|
21
21
|
import { buildSlicerCacheXml, buildSlicerXml } from "./slicer-builder";
|
|
22
22
|
import { buildSparklineGroupsXml } from "./sparkline-builder";
|
|
23
|
-
import { StyleBuilder } from "./style-builder";
|
|
23
|
+
import { StyleBuilder, tableStyleElementsFromBanding, } from "./style-builder";
|
|
24
24
|
var BLANK_LABEL = "(Blanks)";
|
|
25
25
|
var isStyleReference = function (value) {
|
|
26
26
|
return !!value && typeof value === "object" && "sid" in value;
|
|
@@ -31,12 +31,12 @@ var pixelToPoints = function (px) {
|
|
|
31
31
|
return Math.max(1, Number(((px * 72) / 96).toFixed(2)));
|
|
32
32
|
};
|
|
33
33
|
export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
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,
|
|
35
|
-
var e_2, _o, e_3, _p, e_4, _q,
|
|
36
|
-
var
|
|
37
|
-
var _conditionalFormats = _b.conditionalFormats, _dataValidations = _b.dataValidations, sheets = _b.sheets, sheetData = _b.sheetData, sourceSharedStrings = _b.sharedStrings,
|
|
38
|
-
return __generator(this, function (
|
|
39
|
-
switch (
|
|
34
|
+
var sortedSheets, sharedStrings, personRegistry, styleBuilder, customTableStyleRecords, customTableStyleNames, exportableTables, tableIdMap, preparedTables, chartCount, embedsBySheet, textBoxesBySheet, shapesBySheet, formControlsBySheet, ctrlProps, chartsBySheet, remappedSlicers, slicersBySheet, workbookSheetNames, sheetNameById, dataValidationsById, globalSlicerIndex, slicerCacheEntries, slicerEntries, globalPivotIndex, pivotCacheEntries, pivotCacheRelsEntries, pivotTableEntries, pivotTableRelsEntries, pivotSourceNameById, _loop_1, pivotTables_1, pivotTables_1_1, p, resolvePivotSourceName, pivotsByTargetSheet, pivotTables_2, pivotTables_2_1, p, sid, list, workbookPivotCacheRefs, worksheetCount, chartsheetCount, worksheetEntries, _d, workbookRelationshipsXml, sheetRelationshipIds, slicerCacheRelationshipIds, pivotCacheRelationshipIds, externalLinkRelationshipIds, workbookXml, sharedStringsXml, rootRelationshipsXml, appXml, coreXml, tablePartFiles, preparedTables_1, preparedTables_1_1, table, rows, tableXml, stylesXml, themeXml, files, worksheetEntries_1, worksheetEntries_1_1, entry, personsXml, 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_5, _s, e_1, _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, e_17, _5;
|
|
36
|
+
var _6, _7, _8, _9, _10, _11, _12, _13, _14;
|
|
37
|
+
var _conditionalFormats = _b.conditionalFormats, _dataValidations = _b.dataValidations, sheets = _b.sheets, sheetData = _b.sheetData, sourceSharedStrings = _b.sharedStrings, _15 = _b.tables, _tables = _15 === void 0 ? [] : _15, cellXfs = _b.cellXfs, theme = _b.theme, defaultFont = _b.defaultFont, _16 = _b.embeds, embeds = _16 === void 0 ? [] : _16, _17 = _b.charts, charts = _17 === void 0 ? [] : _17, _18 = _b.slicers, slicers = _18 === void 0 ? [] : _18, _19 = _b.pivotTables, pivotTables = _19 === void 0 ? [] : _19, _20 = _b.externalLinks, externalLinks = _20 === void 0 ? [] : _20, _21 = _b.namedRanges, namedRanges = _21 === void 0 ? [] : _21, _22 = _b.protectedRanges, protectedRanges = _22 === void 0 ? [] : _22, namedCellStyles = _b.namedCellStyles, customTableStyles = _b.customTableStyles, iterativeCalculationOptions = _b.iterativeCalculationOptions, ignoreFormulaPatterns = _b.ignoreFormulaPatterns, citations = _b.citations, comments = _b.comments, password = _b.password, locale = _b.locale, _23 = _b.use1904, use1904 = _23 === void 0 ? false : _23, properties = _b.properties, powerQuery = _b.powerQuery;
|
|
38
|
+
return __generator(this, function (_24) {
|
|
39
|
+
switch (_24.label) {
|
|
40
40
|
case 0:
|
|
41
41
|
sortedSheets = sortSheetsByIndex(sheets, true);
|
|
42
42
|
sharedStrings = new SharedStrings();
|
|
@@ -48,9 +48,15 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
48
48
|
if (namedCellStyles && namedCellStyles.length > 0) {
|
|
49
49
|
styleBuilder.setNamedCellStyles(namedCellStyles);
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
customTableStyleRecords = (customTableStyles !== null && customTableStyles !== void 0 ? customTableStyles : []).map(function (style) {
|
|
52
|
+
return "bandedRange" in style
|
|
53
|
+
? { name: style.name, elements: tableStyleElementsFromBanding(style.bandedRange) }
|
|
54
|
+
: style;
|
|
55
|
+
});
|
|
56
|
+
if (customTableStyleRecords.length > 0) {
|
|
57
|
+
styleBuilder.setCustomTableStyles(customTableStyleRecords);
|
|
53
58
|
}
|
|
59
|
+
customTableStyleNames = new Set(customTableStyleRecords.map(function (s) { return s.name; }));
|
|
54
60
|
exportableTables = filterExportableTables(_tables !== null && _tables !== void 0 ? _tables : []);
|
|
55
61
|
tableIdMap = new Map();
|
|
56
62
|
exportableTables.forEach(function (table, index) {
|
|
@@ -58,10 +64,11 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
58
64
|
tableIdMap.set(String(table.id), index + 1);
|
|
59
65
|
});
|
|
60
66
|
preparedTables = prepareTables(exportableTables);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
chartCount = (_6 = charts === null || charts === void 0 ? void 0 : charts.length) !== null && _6 !== void 0 ? _6 : 0;
|
|
68
|
+
embedsBySheet = groupEmbedsBySheet(embeds !== null && embeds !== void 0 ? embeds : [], chartCount);
|
|
69
|
+
textBoxesBySheet = groupTextBoxesBySheet(embeds !== null && embeds !== void 0 ? embeds : [], chartCount);
|
|
70
|
+
shapesBySheet = groupShapesBySheet(embeds !== null && embeds !== void 0 ? embeds : [], chartCount);
|
|
71
|
+
formControlsBySheet = groupFormControlsBySheet(embeds !== null && embeds !== void 0 ? embeds : [], chartCount);
|
|
65
72
|
ctrlProps = { parts: [] };
|
|
66
73
|
chartsBySheet = groupChartsBySheet(charts !== null && charts !== void 0 ? charts : []);
|
|
67
74
|
remappedSlicers = slicers.map(function (slicer) {
|
|
@@ -80,10 +87,10 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
80
87
|
var _a;
|
|
81
88
|
sheetNameById.set((_a = sheet.sheetId) !== null && _a !== void 0 ? _a : index + 1, workbookSheetNames[index]);
|
|
82
89
|
});
|
|
83
|
-
dataValidationsById = (
|
|
90
|
+
dataValidationsById = (_7 = _dataValidations === null || _dataValidations === void 0 ? void 0 : _dataValidations.reduce(function (acc, rule) {
|
|
84
91
|
acc[rule.id] = rule;
|
|
85
92
|
return acc;
|
|
86
|
-
}, {})) !== null &&
|
|
93
|
+
}, {})) !== null && _7 !== void 0 ? _7 : undefined;
|
|
87
94
|
globalSlicerIndex = 1;
|
|
88
95
|
slicerCacheEntries = [];
|
|
89
96
|
slicerEntries = [];
|
|
@@ -92,11 +99,38 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
92
99
|
pivotCacheRelsEntries = [];
|
|
93
100
|
pivotTableEntries = [];
|
|
94
101
|
pivotTableRelsEntries = [];
|
|
95
|
-
|
|
102
|
+
pivotSourceNameById = new Map();
|
|
103
|
+
_loop_1 = function (p) {
|
|
104
|
+
var targetSheet = sortedSheets.find(function (s) { var _a; return s.sheetId === ((_a = p.targetPosition) === null || _a === void 0 ? void 0 : _a.sheetId); });
|
|
105
|
+
if (!targetSheet || !p.source || !p.pivotRange)
|
|
106
|
+
return "continue";
|
|
107
|
+
var sheetTitle = (_8 = targetSheet.title) !== null && _8 !== void 0 ? _8 : "Sheet".concat(targetSheet.sheetId);
|
|
108
|
+
var quoted = /^[A-Za-z_][A-Za-z0-9_.]*$/.test(sheetTitle)
|
|
109
|
+
? sheetTitle
|
|
110
|
+
: "'".concat(sheetTitle.replace(/'/g, "''"), "'");
|
|
111
|
+
pivotSourceNameById.set(String(p.pivotId), "[Workbook]".concat(quoted, "!").concat((_9 = p.name) !== null && _9 !== void 0 ? _9 : "PivotTable".concat(p.pivotId)));
|
|
112
|
+
};
|
|
96
113
|
try {
|
|
97
114
|
for (pivotTables_1 = __values(pivotTables), pivotTables_1_1 = pivotTables_1.next(); !pivotTables_1_1.done; pivotTables_1_1 = pivotTables_1.next()) {
|
|
98
115
|
p = pivotTables_1_1.value;
|
|
99
|
-
|
|
116
|
+
_loop_1(p);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
120
|
+
finally {
|
|
121
|
+
try {
|
|
122
|
+
if (pivotTables_1_1 && !pivotTables_1_1.done && (_o = pivotTables_1.return)) _o.call(pivotTables_1);
|
|
123
|
+
}
|
|
124
|
+
finally { if (e_2) throw e_2.error; }
|
|
125
|
+
}
|
|
126
|
+
resolvePivotSourceName = function (pivotTableId) {
|
|
127
|
+
return pivotSourceNameById.get(String(pivotTableId));
|
|
128
|
+
};
|
|
129
|
+
pivotsByTargetSheet = new Map();
|
|
130
|
+
try {
|
|
131
|
+
for (pivotTables_2 = __values(pivotTables), pivotTables_2_1 = pivotTables_2.next(); !pivotTables_2_1.done; pivotTables_2_1 = pivotTables_2.next()) {
|
|
132
|
+
p = pivotTables_2_1.value;
|
|
133
|
+
sid = (_10 = p.targetPosition) === null || _10 === void 0 ? void 0 : _10.sheetId;
|
|
100
134
|
if (sid == null)
|
|
101
135
|
continue;
|
|
102
136
|
list = pivotsByTargetSheet.get(sid);
|
|
@@ -106,17 +140,22 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
106
140
|
pivotsByTargetSheet.set(sid, [p]);
|
|
107
141
|
}
|
|
108
142
|
}
|
|
109
|
-
catch (
|
|
143
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
110
144
|
finally {
|
|
111
145
|
try {
|
|
112
|
-
if (
|
|
146
|
+
if (pivotTables_2_1 && !pivotTables_2_1.done && (_p = pivotTables_2.return)) _p.call(pivotTables_2);
|
|
113
147
|
}
|
|
114
|
-
finally { if (
|
|
148
|
+
finally { if (e_3) throw e_3.error; }
|
|
115
149
|
}
|
|
116
150
|
workbookPivotCacheRefs = [];
|
|
151
|
+
worksheetCount = 0;
|
|
152
|
+
chartsheetCount = 0;
|
|
117
153
|
worksheetEntries = sortedSheets.map(function (sheet, index) {
|
|
118
|
-
var
|
|
119
|
-
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _s, _t, _u;
|
|
154
|
+
var e_18, _a, e_19, _b;
|
|
155
|
+
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _s, _t, _u, _v;
|
|
156
|
+
var isChartsheet = sheet.type === "chartsheet";
|
|
157
|
+
var partIndex = isChartsheet ? ++chartsheetCount : ++worksheetCount;
|
|
158
|
+
var partFolder = isChartsheet ? "chartsheets" : "worksheets";
|
|
120
159
|
var rows = getRowsForSheet(sheetData, sheet.sheetId);
|
|
121
160
|
var sheetRelationships = new RelationshipsBuilder();
|
|
122
161
|
var sheetTables = preparedTables.filter(function (table) { return table.sheetId === sheet.sheetId; });
|
|
@@ -168,29 +207,30 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
168
207
|
offsetY: placement.offsetY,
|
|
169
208
|
width: placement.width,
|
|
170
209
|
height: placement.height,
|
|
210
|
+
overlay: (_k = slicer.position) === null || _k === void 0 ? void 0 : _k.overlayPosition,
|
|
171
211
|
});
|
|
172
212
|
globalSlicerIndex += 1;
|
|
173
213
|
}
|
|
174
214
|
}
|
|
175
215
|
}
|
|
176
|
-
catch (
|
|
216
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
177
217
|
finally {
|
|
178
218
|
try {
|
|
179
219
|
if (sheetSlicers_1_1 && !sheetSlicers_1_1.done && (_a = sheetSlicers_1.return)) _a.call(sheetSlicers_1);
|
|
180
220
|
}
|
|
181
|
-
finally { if (
|
|
221
|
+
finally { if (e_18) throw e_18.error; }
|
|
182
222
|
}
|
|
183
223
|
// Phase D2 — emit pivot table XMLs + relationships for this
|
|
184
224
|
// sheet. PivotTable lives on the rendering sheet; its cache
|
|
185
225
|
// definition is workbook-scoped (added to <pivotCaches> after
|
|
186
226
|
// this loop).
|
|
187
|
-
var sheetPivots = (
|
|
188
|
-
var
|
|
189
|
-
var
|
|
227
|
+
var sheetPivots = (_l = pivotsByTargetSheet.get(sheet.sheetId)) !== null && _l !== void 0 ? _l : [];
|
|
228
|
+
var _loop_2 = function (pivot) {
|
|
229
|
+
var e_20, _w, e_21, _x, e_22, _y, e_23, _z, e_24, _0, e_25, _1;
|
|
190
230
|
var cacheIndex = globalPivotIndex;
|
|
191
231
|
var tableIndex = globalPivotIndex;
|
|
192
232
|
var sourceSheet = sortedSheets.find(function (s) { var _a; return s.sheetId === ((_a = pivot.source) === null || _a === void 0 ? void 0 : _a.sheetId); });
|
|
193
|
-
var sourceSheetName = (
|
|
233
|
+
var sourceSheetName = (_o = (_m = sourceSheet === null || sourceSheet === void 0 ? void 0 : sourceSheet.title) !== null && _m !== void 0 ? _m : sheet.title) !== null && _o !== void 0 ? _o : "Sheet".concat(sheet.sheetId);
|
|
194
234
|
// Field universe: union of every field referenced by the
|
|
195
235
|
// pivot. PivotCacheDefinition requires one <cacheField>
|
|
196
236
|
// entry per field, and pivotTable.fld indices reference them.
|
|
@@ -202,88 +242,88 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
202
242
|
fieldIndex.set(name, fieldNameList.length);
|
|
203
243
|
fieldNameList.push(name);
|
|
204
244
|
};
|
|
205
|
-
var calculatedNames = new Set(((
|
|
245
|
+
var calculatedNames = new Set(((_p = pivot.calculatedFields) !== null && _p !== void 0 ? _p : []).map(function (c) { return c.name; }));
|
|
206
246
|
try {
|
|
207
|
-
for (var
|
|
208
|
-
var r =
|
|
247
|
+
for (var _2 = (e_20 = void 0, __values((_q = pivot.rows) !== null && _q !== void 0 ? _q : [])), _3 = _2.next(); !_3.done; _3 = _2.next()) {
|
|
248
|
+
var r = _3.value;
|
|
209
249
|
registerField(r.field);
|
|
210
250
|
}
|
|
211
251
|
}
|
|
212
|
-
catch (
|
|
252
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
213
253
|
finally {
|
|
214
254
|
try {
|
|
215
|
-
if (
|
|
255
|
+
if (_3 && !_3.done && (_w = _2.return)) _w.call(_2);
|
|
216
256
|
}
|
|
217
|
-
finally { if (
|
|
257
|
+
finally { if (e_20) throw e_20.error; }
|
|
218
258
|
}
|
|
219
259
|
try {
|
|
220
|
-
for (var
|
|
221
|
-
var c =
|
|
260
|
+
for (var _4 = (e_21 = void 0, __values((_s = pivot.columns) !== null && _s !== void 0 ? _s : [])), _5 = _4.next(); !_5.done; _5 = _4.next()) {
|
|
261
|
+
var c = _5.value;
|
|
222
262
|
registerField(c.field);
|
|
223
263
|
}
|
|
224
264
|
}
|
|
225
|
-
catch (
|
|
265
|
+
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
226
266
|
finally {
|
|
227
267
|
try {
|
|
228
|
-
if (
|
|
268
|
+
if (_5 && !_5.done && (_x = _4.return)) _x.call(_4);
|
|
229
269
|
}
|
|
230
|
-
finally { if (
|
|
270
|
+
finally { if (e_21) throw e_21.error; }
|
|
231
271
|
}
|
|
232
272
|
try {
|
|
233
|
-
for (var
|
|
234
|
-
var v =
|
|
273
|
+
for (var _6 = (e_22 = void 0, __values((_t = pivot.values) !== null && _t !== void 0 ? _t : [])), _7 = _6.next(); !_7.done; _7 = _6.next()) {
|
|
274
|
+
var v = _7.value;
|
|
235
275
|
if (!calculatedNames.has(v.field))
|
|
236
276
|
registerField(v.field);
|
|
237
277
|
}
|
|
238
278
|
}
|
|
239
|
-
catch (
|
|
279
|
+
catch (e_22_1) { e_22 = { error: e_22_1 }; }
|
|
240
280
|
finally {
|
|
241
281
|
try {
|
|
242
|
-
if (
|
|
282
|
+
if (_7 && !_7.done && (_y = _6.return)) _y.call(_6);
|
|
243
283
|
}
|
|
244
|
-
finally { if (
|
|
284
|
+
finally { if (e_22) throw e_22.error; }
|
|
245
285
|
}
|
|
246
286
|
try {
|
|
247
287
|
// Source fields a calculated field reads must exist in the cache
|
|
248
288
|
// for Excel to evaluate the formula; the calculated fields
|
|
249
289
|
// themselves come last, as Excel orders them.
|
|
250
|
-
for (var
|
|
251
|
-
var c =
|
|
290
|
+
for (var _8 = (e_23 = void 0, __values((_u = pivot.calculatedFields) !== null && _u !== void 0 ? _u : [])), _9 = _8.next(); !_9.done; _9 = _8.next()) {
|
|
291
|
+
var c = _9.value;
|
|
252
292
|
try {
|
|
253
|
-
for (var
|
|
254
|
-
var ref =
|
|
293
|
+
for (var _10 = (e_24 = void 0, __values(calculatedFieldReferences(c.formula))), _11 = _10.next(); !_11.done; _11 = _10.next()) {
|
|
294
|
+
var ref = _11.value;
|
|
255
295
|
if (!calculatedNames.has(ref))
|
|
256
296
|
registerField(ref);
|
|
257
297
|
}
|
|
258
298
|
}
|
|
259
|
-
catch (
|
|
299
|
+
catch (e_24_1) { e_24 = { error: e_24_1 }; }
|
|
260
300
|
finally {
|
|
261
301
|
try {
|
|
262
|
-
if (
|
|
302
|
+
if (_11 && !_11.done && (_0 = _10.return)) _0.call(_10);
|
|
263
303
|
}
|
|
264
|
-
finally { if (
|
|
304
|
+
finally { if (e_24) throw e_24.error; }
|
|
265
305
|
}
|
|
266
306
|
}
|
|
267
307
|
}
|
|
268
|
-
catch (
|
|
308
|
+
catch (e_23_1) { e_23 = { error: e_23_1 }; }
|
|
269
309
|
finally {
|
|
270
310
|
try {
|
|
271
|
-
if (
|
|
311
|
+
if (_9 && !_9.done && (_z = _8.return)) _z.call(_8);
|
|
272
312
|
}
|
|
273
|
-
finally { if (
|
|
313
|
+
finally { if (e_23) throw e_23.error; }
|
|
274
314
|
}
|
|
275
315
|
try {
|
|
276
|
-
for (var
|
|
277
|
-
var c =
|
|
316
|
+
for (var _12 = (e_25 = void 0, __values((_v = pivot.calculatedFields) !== null && _v !== void 0 ? _v : [])), _13 = _12.next(); !_13.done; _13 = _12.next()) {
|
|
317
|
+
var c = _13.value;
|
|
278
318
|
registerField(c.name);
|
|
279
319
|
}
|
|
280
320
|
}
|
|
281
|
-
catch (
|
|
321
|
+
catch (e_25_1) { e_25 = { error: e_25_1 }; }
|
|
282
322
|
finally {
|
|
283
323
|
try {
|
|
284
|
-
if (
|
|
324
|
+
if (_13 && !_13.done && (_1 = _12.return)) _1.call(_12);
|
|
285
325
|
}
|
|
286
|
-
finally { if (
|
|
326
|
+
finally { if (e_25) throw e_25.error; }
|
|
287
327
|
}
|
|
288
328
|
var cacheXml = buildPivotCacheDefinitionXml(pivot, sourceSheetName, fieldNameList);
|
|
289
329
|
var tableXml = buildPivotTableXml(pivot, cacheIndex, fieldIndex);
|
|
@@ -311,45 +351,52 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
311
351
|
try {
|
|
312
352
|
for (var sheetPivots_1 = __values(sheetPivots), sheetPivots_1_1 = sheetPivots_1.next(); !sheetPivots_1_1.done; sheetPivots_1_1 = sheetPivots_1.next()) {
|
|
313
353
|
var pivot = sheetPivots_1_1.value;
|
|
314
|
-
|
|
354
|
+
_loop_2(pivot);
|
|
315
355
|
}
|
|
316
356
|
}
|
|
317
|
-
catch (
|
|
357
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
318
358
|
finally {
|
|
319
359
|
try {
|
|
320
360
|
if (sheetPivots_1_1 && !sheetPivots_1_1.done && (_b = sheetPivots_1.return)) _b.call(sheetPivots_1);
|
|
321
361
|
}
|
|
322
|
-
finally { if (
|
|
362
|
+
finally { if (e_19) throw e_19.error; }
|
|
323
363
|
}
|
|
324
|
-
var result =
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
364
|
+
var result = isChartsheet
|
|
365
|
+
? buildChartsheetXml({
|
|
366
|
+
sheet: sheet,
|
|
367
|
+
relationships: sheetRelationships,
|
|
368
|
+
drawingContext: drawingContext,
|
|
369
|
+
})
|
|
370
|
+
: buildWorksheetXml({
|
|
371
|
+
sheet: sheet,
|
|
372
|
+
rows: rows,
|
|
373
|
+
sharedStrings: sharedStrings,
|
|
374
|
+
sourceSharedStrings: sourceSharedStrings,
|
|
375
|
+
cellXfs: cellXfs,
|
|
376
|
+
styleBuilder: styleBuilder,
|
|
377
|
+
tables: sheetTables,
|
|
378
|
+
relationships: sheetRelationships,
|
|
379
|
+
drawingContext: drawingContext,
|
|
380
|
+
conditionalFormats: sheetConditionalFormats,
|
|
381
|
+
dataValidationsById: dataValidationsById,
|
|
382
|
+
dataValidations: _dataValidations,
|
|
383
|
+
ignoreFormulaPatterns: ignoreFormulaPatterns,
|
|
384
|
+
citations: sheetCitations,
|
|
385
|
+
comments: comments,
|
|
386
|
+
personRegistry: personRegistry,
|
|
387
|
+
slicerRelIds: worksheetSlicerRelIds,
|
|
388
|
+
sheetData: sheetData,
|
|
389
|
+
sheets: sortedSheets,
|
|
390
|
+
locale: locale,
|
|
391
|
+
protectedRanges: protectedRanges,
|
|
392
|
+
formControls: sheetFormControls,
|
|
393
|
+
ctrlProps: ctrlProps,
|
|
394
|
+
});
|
|
349
395
|
return {
|
|
350
396
|
index: index,
|
|
351
|
-
|
|
352
|
-
|
|
397
|
+
isChartsheet: isChartsheet,
|
|
398
|
+
path: "xl/".concat(partFolder, "/sheet").concat(partIndex, ".xml"),
|
|
399
|
+
relationshipsPath: "xl/".concat(partFolder, "/_rels/sheet").concat(partIndex, ".xml.rels"),
|
|
353
400
|
content: result.xml,
|
|
354
401
|
relationshipsXml: result.relationshipsXml,
|
|
355
402
|
drawingPath: "xl/drawings/drawing".concat(index + 1, ".xml"),
|
|
@@ -366,12 +413,33 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
366
413
|
threadedCommentsXml: result.threadedCommentsXml,
|
|
367
414
|
};
|
|
368
415
|
});
|
|
369
|
-
_d = buildWorkbookRelationships(worksheetEntries.
|
|
416
|
+
_d = buildWorkbookRelationships(worksheetEntries.map(function (entry) { return ({
|
|
417
|
+
chartsheet: entry.isChartsheet,
|
|
418
|
+
target: entry.path.replace(/^xl\//, ""),
|
|
419
|
+
}); }), slicerCacheEntries.length, externalLinks.length, pivotCacheEntries.length, !personRegistry.isEmpty()), workbookRelationshipsXml = _d.xml, sheetRelationshipIds = _d.sheetRelationshipIds, slicerCacheRelationshipIds = _d.slicerCacheRelationshipIds, pivotCacheRelationshipIds = _d.pivotCacheRelationshipIds, externalLinkRelationshipIds = _d.externalLinkRelationshipIds;
|
|
370
420
|
workbookXml = buildWorkbookXml(sortedSheets, sheetRelationshipIds, workbookSheetNames, namedRanges, iterativeCalculationOptions, slicerCacheRelationshipIds, use1904, externalLinkRelationshipIds, pivotCacheRelationshipIds);
|
|
371
421
|
sharedStringsXml = buildSharedStringsXml(sharedStrings);
|
|
372
422
|
rootRelationshipsXml = buildRootRelationshipsXml();
|
|
373
|
-
appXml = buildAppXml(workbookSheetNames, properties);
|
|
423
|
+
appXml = buildAppXml(workbookSheetNames, sortedSheets.map(function (sheet) { return sheet.type === "chartsheet"; }), properties);
|
|
374
424
|
coreXml = buildCoreXml(properties);
|
|
425
|
+
tablePartFiles = {};
|
|
426
|
+
try {
|
|
427
|
+
for (preparedTables_1 = __values(preparedTables), preparedTables_1_1 = preparedTables_1.next(); !preparedTables_1_1.done; preparedTables_1_1 = preparedTables_1.next()) {
|
|
428
|
+
table = preparedTables_1_1.value;
|
|
429
|
+
rows = getRowsForSheet(sheetData, table.sheetId);
|
|
430
|
+
tableXml = buildTableXml(table, rows, sourceSharedStrings, styleBuilder, customTableStyleNames);
|
|
431
|
+
if (tableXml) {
|
|
432
|
+
tablePartFiles[table.path] = encodeXml(tableXml);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
437
|
+
finally {
|
|
438
|
+
try {
|
|
439
|
+
if (preparedTables_1_1 && !preparedTables_1_1.done && (_q = preparedTables_1.return)) _q.call(preparedTables_1);
|
|
440
|
+
}
|
|
441
|
+
finally { if (e_4) throw e_4.error; }
|
|
442
|
+
}
|
|
375
443
|
stylesXml = styleBuilder.toXml();
|
|
376
444
|
themeXml = theme ? generateThemeXml(theme) : theme1Xml;
|
|
377
445
|
files = {
|
|
@@ -403,34 +471,18 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
403
471
|
}
|
|
404
472
|
}
|
|
405
473
|
}
|
|
406
|
-
catch (
|
|
474
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
407
475
|
finally {
|
|
408
476
|
try {
|
|
409
|
-
if (worksheetEntries_1_1 && !worksheetEntries_1_1.done && (
|
|
477
|
+
if (worksheetEntries_1_1 && !worksheetEntries_1_1.done && (_s = worksheetEntries_1.return)) _s.call(worksheetEntries_1);
|
|
410
478
|
}
|
|
411
|
-
finally { if (
|
|
479
|
+
finally { if (e_5) throw e_5.error; }
|
|
412
480
|
}
|
|
413
481
|
personsXml = personRegistry.toXml();
|
|
414
482
|
if (personsXml) {
|
|
415
483
|
files["xl/persons/person.xml"] = encodeXml(personsXml);
|
|
416
484
|
}
|
|
417
|
-
|
|
418
|
-
for (preparedTables_1 = __values(preparedTables), preparedTables_1_1 = preparedTables_1.next(); !preparedTables_1_1.done; preparedTables_1_1 = preparedTables_1.next()) {
|
|
419
|
-
table = preparedTables_1_1.value;
|
|
420
|
-
rows = getRowsForSheet(sheetData, table.sheetId);
|
|
421
|
-
tableXml = buildTableXml(table, rows, sourceSharedStrings, styleBuilder);
|
|
422
|
-
if (tableXml) {
|
|
423
|
-
files[table.path] = encodeXml(tableXml);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
428
|
-
finally {
|
|
429
|
-
try {
|
|
430
|
-
if (preparedTables_1_1 && !preparedTables_1_1.done && (_q = preparedTables_1.return)) _q.call(preparedTables_1);
|
|
431
|
-
}
|
|
432
|
-
finally { if (e_4) throw e_4.error; }
|
|
433
|
-
}
|
|
485
|
+
Object.assign(files, tablePartFiles);
|
|
434
486
|
globalImageIndex = 1;
|
|
435
487
|
globalChartIndex = 1;
|
|
436
488
|
drawingSheets = [];
|
|
@@ -438,19 +490,19 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
438
490
|
chartEntries = [];
|
|
439
491
|
chartExEntries = [];
|
|
440
492
|
globalChartExIndex = 1;
|
|
441
|
-
|
|
493
|
+
_24.label = 1;
|
|
442
494
|
case 1:
|
|
443
|
-
|
|
495
|
+
_24.trys.push([1, 6, 7, 8]);
|
|
444
496
|
worksheetEntries_2 = __values(worksheetEntries), worksheetEntries_2_1 = worksheetEntries_2.next();
|
|
445
|
-
|
|
497
|
+
_24.label = 2;
|
|
446
498
|
case 2:
|
|
447
499
|
if (!!worksheetEntries_2_1.done) return [3 /*break*/, 5];
|
|
448
500
|
entry = worksheetEntries_2_1.value;
|
|
449
501
|
placements = __spreadArray(__spreadArray([], __read(entry.cellImages), false), __read(entry.embedImages), false);
|
|
450
|
-
textBoxesForSheet = (
|
|
451
|
-
shapesForSheet = (
|
|
452
|
-
chartsForSheet = (
|
|
453
|
-
slicersForSheet = (
|
|
502
|
+
textBoxesForSheet = (_11 = entry.textBoxes) !== null && _11 !== void 0 ? _11 : [];
|
|
503
|
+
shapesForSheet = (_12 = entry.shapes) !== null && _12 !== void 0 ? _12 : [];
|
|
504
|
+
chartsForSheet = (_13 = entry.charts) !== null && _13 !== void 0 ? _13 : [];
|
|
505
|
+
slicersForSheet = (_14 = entry.slicers) !== null && _14 !== void 0 ? _14 : [];
|
|
454
506
|
if (!placements.length &&
|
|
455
507
|
!textBoxesForSheet.length &&
|
|
456
508
|
!shapesForSheet.length &&
|
|
@@ -468,9 +520,10 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
468
520
|
charts: chartsForSheet,
|
|
469
521
|
slicers: slicersForSheet,
|
|
470
522
|
sheetNameById: sheetNameById,
|
|
523
|
+
resolvePivotSourceName: resolvePivotSourceName,
|
|
471
524
|
})];
|
|
472
525
|
case 3:
|
|
473
|
-
drawingParts =
|
|
526
|
+
drawingParts = _24.sent();
|
|
474
527
|
if (!drawingParts)
|
|
475
528
|
return [3 /*break*/, 4];
|
|
476
529
|
files[entry.drawingPath] = encodeXml(drawingParts.xml);
|
|
@@ -478,61 +531,61 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
478
531
|
files[entry.drawingRelsPath] = encodeXml(drawingParts.relsXml);
|
|
479
532
|
}
|
|
480
533
|
try {
|
|
481
|
-
for (_e = (
|
|
534
|
+
for (_e = (e_6 = void 0, __values(drawingParts.media)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
482
535
|
media = _f.value;
|
|
483
536
|
files[media.path] = media.data;
|
|
484
537
|
imageExtensions.add(media.extension);
|
|
485
538
|
}
|
|
486
539
|
}
|
|
487
|
-
catch (
|
|
540
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
488
541
|
finally {
|
|
489
542
|
try {
|
|
490
|
-
if (_f && !_f.done && (
|
|
543
|
+
if (_f && !_f.done && (_u = _e.return)) _u.call(_e);
|
|
491
544
|
}
|
|
492
|
-
finally { if (
|
|
545
|
+
finally { if (e_6) throw e_6.error; }
|
|
493
546
|
}
|
|
494
547
|
try {
|
|
495
|
-
for (_g = (
|
|
548
|
+
for (_g = (e_7 = void 0, __values(drawingParts.charts)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
496
549
|
chartEntry = _h.value;
|
|
497
550
|
chartEntries.push(chartEntry);
|
|
498
551
|
}
|
|
499
552
|
}
|
|
500
|
-
catch (
|
|
553
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
501
554
|
finally {
|
|
502
555
|
try {
|
|
503
|
-
if (_h && !_h.done && (
|
|
556
|
+
if (_h && !_h.done && (_v = _g.return)) _v.call(_g);
|
|
504
557
|
}
|
|
505
|
-
finally { if (
|
|
558
|
+
finally { if (e_7) throw e_7.error; }
|
|
506
559
|
}
|
|
507
560
|
try {
|
|
508
|
-
for (_j = (
|
|
561
|
+
for (_j = (e_8 = void 0, __values(drawingParts.chartExs)), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
509
562
|
chartExEntry = _k.value;
|
|
510
563
|
chartExEntries.push(chartExEntry);
|
|
511
564
|
}
|
|
512
565
|
}
|
|
513
|
-
catch (
|
|
566
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
514
567
|
finally {
|
|
515
568
|
try {
|
|
516
|
-
if (_k && !_k.done && (
|
|
569
|
+
if (_k && !_k.done && (_w = _j.return)) _w.call(_j);
|
|
517
570
|
}
|
|
518
|
-
finally { if (
|
|
571
|
+
finally { if (e_8) throw e_8.error; }
|
|
519
572
|
}
|
|
520
573
|
globalImageIndex = drawingParts.nextImageIndex;
|
|
521
574
|
globalChartIndex = drawingParts.nextChartIndex;
|
|
522
575
|
globalChartExIndex = drawingParts.nextChartExIndex;
|
|
523
576
|
drawingSheets.push(entry.index + 1);
|
|
524
|
-
|
|
577
|
+
_24.label = 4;
|
|
525
578
|
case 4:
|
|
526
579
|
worksheetEntries_2_1 = worksheetEntries_2.next();
|
|
527
580
|
return [3 /*break*/, 2];
|
|
528
581
|
case 5: return [3 /*break*/, 8];
|
|
529
582
|
case 6:
|
|
530
|
-
e_1_1 =
|
|
583
|
+
e_1_1 = _24.sent();
|
|
531
584
|
e_1 = { error: e_1_1 };
|
|
532
585
|
return [3 /*break*/, 8];
|
|
533
586
|
case 7:
|
|
534
587
|
try {
|
|
535
|
-
if (worksheetEntries_2_1 && !worksheetEntries_2_1.done && (
|
|
588
|
+
if (worksheetEntries_2_1 && !worksheetEntries_2_1.done && (_t = worksheetEntries_2.return)) _t.call(worksheetEntries_2);
|
|
536
589
|
}
|
|
537
590
|
finally { if (e_1) throw e_1.error; }
|
|
538
591
|
return [7 /*endfinally*/];
|
|
@@ -543,12 +596,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
543
596
|
files[chartEntry.path] = encodeXml(chartEntry.xml);
|
|
544
597
|
}
|
|
545
598
|
}
|
|
546
|
-
catch (
|
|
599
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
547
600
|
finally {
|
|
548
601
|
try {
|
|
549
|
-
if (chartEntries_1_1 && !chartEntries_1_1.done && (
|
|
602
|
+
if (chartEntries_1_1 && !chartEntries_1_1.done && (_x = chartEntries_1.return)) _x.call(chartEntries_1);
|
|
550
603
|
}
|
|
551
|
-
finally { if (
|
|
604
|
+
finally { if (e_9) throw e_9.error; }
|
|
552
605
|
}
|
|
553
606
|
try {
|
|
554
607
|
for (chartExEntries_1 = __values(chartExEntries), chartExEntries_1_1 = chartExEntries_1.next(); !chartExEntries_1_1.done; chartExEntries_1_1 = chartExEntries_1.next()) {
|
|
@@ -556,12 +609,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
556
609
|
files[chartExEntry.path] = encodeXml(chartExEntry.xml);
|
|
557
610
|
}
|
|
558
611
|
}
|
|
559
|
-
catch (
|
|
612
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
560
613
|
finally {
|
|
561
614
|
try {
|
|
562
|
-
if (chartExEntries_1_1 && !chartExEntries_1_1.done && (
|
|
615
|
+
if (chartExEntries_1_1 && !chartExEntries_1_1.done && (_y = chartExEntries_1.return)) _y.call(chartExEntries_1);
|
|
563
616
|
}
|
|
564
|
-
finally { if (
|
|
617
|
+
finally { if (e_10) throw e_10.error; }
|
|
565
618
|
}
|
|
566
619
|
try {
|
|
567
620
|
for (slicerCacheEntries_1 = __values(slicerCacheEntries), slicerCacheEntries_1_1 = slicerCacheEntries_1.next(); !slicerCacheEntries_1_1.done; slicerCacheEntries_1_1 = slicerCacheEntries_1.next()) {
|
|
@@ -569,12 +622,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
569
622
|
files[slicerCacheEntry.path] = encodeXml(slicerCacheEntry.xml);
|
|
570
623
|
}
|
|
571
624
|
}
|
|
572
|
-
catch (
|
|
625
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
573
626
|
finally {
|
|
574
627
|
try {
|
|
575
|
-
if (slicerCacheEntries_1_1 && !slicerCacheEntries_1_1.done && (
|
|
628
|
+
if (slicerCacheEntries_1_1 && !slicerCacheEntries_1_1.done && (_z = slicerCacheEntries_1.return)) _z.call(slicerCacheEntries_1);
|
|
576
629
|
}
|
|
577
|
-
finally { if (
|
|
630
|
+
finally { if (e_11) throw e_11.error; }
|
|
578
631
|
}
|
|
579
632
|
try {
|
|
580
633
|
for (slicerEntries_1 = __values(slicerEntries), slicerEntries_1_1 = slicerEntries_1.next(); !slicerEntries_1_1.done; slicerEntries_1_1 = slicerEntries_1.next()) {
|
|
@@ -582,12 +635,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
582
635
|
files[slicerEntry.path] = encodeXml(slicerEntry.xml);
|
|
583
636
|
}
|
|
584
637
|
}
|
|
585
|
-
catch (
|
|
638
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
586
639
|
finally {
|
|
587
640
|
try {
|
|
588
|
-
if (slicerEntries_1_1 && !slicerEntries_1_1.done && (
|
|
641
|
+
if (slicerEntries_1_1 && !slicerEntries_1_1.done && (_0 = slicerEntries_1.return)) _0.call(slicerEntries_1);
|
|
589
642
|
}
|
|
590
|
-
finally { if (
|
|
643
|
+
finally { if (e_12) throw e_12.error; }
|
|
591
644
|
}
|
|
592
645
|
try {
|
|
593
646
|
// Phase D2 — emit pivot files.
|
|
@@ -596,12 +649,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
596
649
|
files[cacheEntry.path] = encodeXml(cacheEntry.xml);
|
|
597
650
|
}
|
|
598
651
|
}
|
|
599
|
-
catch (
|
|
652
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
600
653
|
finally {
|
|
601
654
|
try {
|
|
602
|
-
if (pivotCacheEntries_1_1 && !pivotCacheEntries_1_1.done && (
|
|
655
|
+
if (pivotCacheEntries_1_1 && !pivotCacheEntries_1_1.done && (_1 = pivotCacheEntries_1.return)) _1.call(pivotCacheEntries_1);
|
|
603
656
|
}
|
|
604
|
-
finally { if (
|
|
657
|
+
finally { if (e_13) throw e_13.error; }
|
|
605
658
|
}
|
|
606
659
|
try {
|
|
607
660
|
for (pivotCacheRelsEntries_1 = __values(pivotCacheRelsEntries), pivotCacheRelsEntries_1_1 = pivotCacheRelsEntries_1.next(); !pivotCacheRelsEntries_1_1.done; pivotCacheRelsEntries_1_1 = pivotCacheRelsEntries_1.next()) {
|
|
@@ -609,12 +662,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
609
662
|
files[cacheRels.path] = encodeXml(cacheRels.xml);
|
|
610
663
|
}
|
|
611
664
|
}
|
|
612
|
-
catch (
|
|
665
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
613
666
|
finally {
|
|
614
667
|
try {
|
|
615
|
-
if (pivotCacheRelsEntries_1_1 && !pivotCacheRelsEntries_1_1.done && (
|
|
668
|
+
if (pivotCacheRelsEntries_1_1 && !pivotCacheRelsEntries_1_1.done && (_2 = pivotCacheRelsEntries_1.return)) _2.call(pivotCacheRelsEntries_1);
|
|
616
669
|
}
|
|
617
|
-
finally { if (
|
|
670
|
+
finally { if (e_14) throw e_14.error; }
|
|
618
671
|
}
|
|
619
672
|
try {
|
|
620
673
|
for (pivotTableEntries_1 = __values(pivotTableEntries), pivotTableEntries_1_1 = pivotTableEntries_1.next(); !pivotTableEntries_1_1.done; pivotTableEntries_1_1 = pivotTableEntries_1.next()) {
|
|
@@ -622,12 +675,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
622
675
|
files[tableEntry.path] = encodeXml(tableEntry.xml);
|
|
623
676
|
}
|
|
624
677
|
}
|
|
625
|
-
catch (
|
|
678
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
626
679
|
finally {
|
|
627
680
|
try {
|
|
628
|
-
if (pivotTableEntries_1_1 && !pivotTableEntries_1_1.done && (
|
|
681
|
+
if (pivotTableEntries_1_1 && !pivotTableEntries_1_1.done && (_3 = pivotTableEntries_1.return)) _3.call(pivotTableEntries_1);
|
|
629
682
|
}
|
|
630
|
-
finally { if (
|
|
683
|
+
finally { if (e_15) throw e_15.error; }
|
|
631
684
|
}
|
|
632
685
|
try {
|
|
633
686
|
for (pivotTableRelsEntries_1 = __values(pivotTableRelsEntries), pivotTableRelsEntries_1_1 = pivotTableRelsEntries_1.next(); !pivotTableRelsEntries_1_1.done; pivotTableRelsEntries_1_1 = pivotTableRelsEntries_1.next()) {
|
|
@@ -635,12 +688,12 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
635
688
|
files[tableRels.path] = encodeXml(tableRels.xml);
|
|
636
689
|
}
|
|
637
690
|
}
|
|
638
|
-
catch (
|
|
691
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
639
692
|
finally {
|
|
640
693
|
try {
|
|
641
|
-
if (pivotTableRelsEntries_1_1 && !pivotTableRelsEntries_1_1.done && (
|
|
694
|
+
if (pivotTableRelsEntries_1_1 && !pivotTableRelsEntries_1_1.done && (_4 = pivotTableRelsEntries_1.return)) _4.call(pivotTableRelsEntries_1);
|
|
642
695
|
}
|
|
643
|
-
finally { if (
|
|
696
|
+
finally { if (e_16) throw e_16.error; }
|
|
644
697
|
}
|
|
645
698
|
// Add external link files (for formulas referencing other workbooks)
|
|
646
699
|
for (i = 0; i < externalLinks.length; i++) {
|
|
@@ -663,18 +716,19 @@ export var createExcelFile = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
663
716
|
files[part.path] = encodeXml(part.xml);
|
|
664
717
|
}
|
|
665
718
|
}
|
|
666
|
-
catch (
|
|
719
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
667
720
|
finally {
|
|
668
721
|
try {
|
|
669
|
-
if (_m && !_m.done && (
|
|
722
|
+
if (_m && !_m.done && (_5 = _l.return)) _5.call(_l);
|
|
670
723
|
}
|
|
671
|
-
finally { if (
|
|
724
|
+
finally { if (e_17) throw e_17.error; }
|
|
672
725
|
}
|
|
673
726
|
threadedCommentsSheets = worksheetEntries
|
|
674
727
|
.filter(function (entry) { return entry.threadedCommentsXml; })
|
|
675
728
|
.map(function (entry) { var _a; return (_a = entry.sheet.sheetId) !== null && _a !== void 0 ? _a : entry.index + 1; });
|
|
676
729
|
contentTypesXml = buildContentTypesXml({
|
|
677
|
-
|
|
730
|
+
worksheetCount: worksheetCount,
|
|
731
|
+
chartsheetCount: chartsheetCount,
|
|
678
732
|
tableCount: preparedTables.length,
|
|
679
733
|
drawingSheets: drawingSheets,
|
|
680
734
|
mediaExtensions: Array.from(imageExtensions),
|
|
@@ -804,7 +858,7 @@ export var normalizeSqrefMembers = function (refs) {
|
|
|
804
858
|
};
|
|
805
859
|
var out = [];
|
|
806
860
|
var seen = new Set();
|
|
807
|
-
var
|
|
861
|
+
var _loop_3 = function (i) {
|
|
808
862
|
var _a = parsed[i], ref = _a.ref, rect = _a.rect;
|
|
809
863
|
if (seen.has(ref))
|
|
810
864
|
return "continue";
|
|
@@ -823,7 +877,7 @@ export var normalizeSqrefMembers = function (refs) {
|
|
|
823
877
|
out.push(ref);
|
|
824
878
|
};
|
|
825
879
|
for (var i = 0; i < parsed.length; i++) {
|
|
826
|
-
|
|
880
|
+
_loop_3(i);
|
|
827
881
|
}
|
|
828
882
|
return out;
|
|
829
883
|
};
|
|
@@ -971,7 +1025,7 @@ var getRowsForSheet = function (sheetData, sheetId) {
|
|
|
971
1025
|
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 : []);
|
|
972
1026
|
};
|
|
973
1027
|
var buildWorksheetXml = function (_a) {
|
|
974
|
-
var
|
|
1028
|
+
var e_26, _b, e_27, _d, e_28, _e, e_29, _f, e_30, _g, e_31, _h;
|
|
975
1029
|
var _j, _k;
|
|
976
1030
|
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;
|
|
977
1031
|
var tableNameMap = buildTableNameMap(tables);
|
|
@@ -1008,12 +1062,12 @@ var buildWorksheetXml = function (_a) {
|
|
|
1008
1062
|
}
|
|
1009
1063
|
}
|
|
1010
1064
|
}
|
|
1011
|
-
catch (
|
|
1065
|
+
catch (e_26_1) { e_26 = { error: e_26_1 }; }
|
|
1012
1066
|
finally {
|
|
1013
1067
|
try {
|
|
1014
1068
|
if (citations_1_1 && !citations_1_1.done && (_b = citations_1.return)) _b.call(citations_1);
|
|
1015
1069
|
}
|
|
1016
|
-
finally { if (
|
|
1070
|
+
finally { if (e_26) throw e_26.error; }
|
|
1017
1071
|
}
|
|
1018
1072
|
}
|
|
1019
1073
|
if (dataValidations) {
|
|
@@ -1023,7 +1077,7 @@ var buildWorksheetXml = function (_a) {
|
|
|
1023
1077
|
if (!rule.ranges)
|
|
1024
1078
|
continue;
|
|
1025
1079
|
try {
|
|
1026
|
-
for (var _o = (
|
|
1080
|
+
for (var _o = (e_28 = void 0, __values(rule.ranges)), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
1027
1081
|
var range = _p.value;
|
|
1028
1082
|
if (range.sheetId !== sheet.sheetId)
|
|
1029
1083
|
continue;
|
|
@@ -1037,21 +1091,21 @@ var buildWorksheetXml = function (_a) {
|
|
|
1037
1091
|
}
|
|
1038
1092
|
}
|
|
1039
1093
|
}
|
|
1040
|
-
catch (
|
|
1094
|
+
catch (e_28_1) { e_28 = { error: e_28_1 }; }
|
|
1041
1095
|
finally {
|
|
1042
1096
|
try {
|
|
1043
1097
|
if (_p && !_p.done && (_e = _o.return)) _e.call(_o);
|
|
1044
1098
|
}
|
|
1045
|
-
finally { if (
|
|
1099
|
+
finally { if (e_28) throw e_28.error; }
|
|
1046
1100
|
}
|
|
1047
1101
|
}
|
|
1048
1102
|
}
|
|
1049
|
-
catch (
|
|
1103
|
+
catch (e_27_1) { e_27 = { error: e_27_1 }; }
|
|
1050
1104
|
finally {
|
|
1051
1105
|
try {
|
|
1052
1106
|
if (dataValidations_1_1 && !dataValidations_1_1.done && (_d = dataValidations_1.return)) _d.call(dataValidations_1);
|
|
1053
1107
|
}
|
|
1054
|
-
finally { if (
|
|
1108
|
+
finally { if (e_27) throw e_27.error; }
|
|
1055
1109
|
}
|
|
1056
1110
|
}
|
|
1057
1111
|
// Pre-scan for valid shared-formula leaders in this sheet. The cell-emit
|
|
@@ -1071,7 +1125,7 @@ var buildWorksheetXml = function (_a) {
|
|
|
1071
1125
|
if (!Array.isArray(rowValues))
|
|
1072
1126
|
continue;
|
|
1073
1127
|
try {
|
|
1074
|
-
for (var rowValues_1 = (
|
|
1128
|
+
for (var rowValues_1 = (e_29 = void 0, __values(rowValues)), rowValues_1_1 = rowValues_1.next(); !rowValues_1_1.done; rowValues_1_1 = rowValues_1.next()) {
|
|
1075
1129
|
var cell = rowValues_1_1.value;
|
|
1076
1130
|
var sf = cell === null || cell === void 0 ? void 0 : cell.sf;
|
|
1077
1131
|
if (sf && sf.ref && Number.isFinite(sf.si)) {
|
|
@@ -1079,12 +1133,12 @@ var buildWorksheetXml = function (_a) {
|
|
|
1079
1133
|
}
|
|
1080
1134
|
}
|
|
1081
1135
|
}
|
|
1082
|
-
catch (
|
|
1136
|
+
catch (e_29_1) { e_29 = { error: e_29_1 }; }
|
|
1083
1137
|
finally {
|
|
1084
1138
|
try {
|
|
1085
1139
|
if (rowValues_1_1 && !rowValues_1_1.done && (_f = rowValues_1.return)) _f.call(rowValues_1);
|
|
1086
1140
|
}
|
|
1087
|
-
finally { if (
|
|
1141
|
+
finally { if (e_29) throw e_29.error; }
|
|
1088
1142
|
}
|
|
1089
1143
|
}
|
|
1090
1144
|
for (var rowIndex = 1; rowIndex < maxRows; rowIndex++) {
|
|
@@ -1175,12 +1229,12 @@ var buildWorksheetXml = function (_a) {
|
|
|
1175
1229
|
commentsCollector.add(entry.address, entry.text, entry.author);
|
|
1176
1230
|
}
|
|
1177
1231
|
}
|
|
1178
|
-
catch (
|
|
1232
|
+
catch (e_30_1) { e_30 = { error: e_30_1 }; }
|
|
1179
1233
|
finally {
|
|
1180
1234
|
try {
|
|
1181
1235
|
if (_s && !_s.done && (_g = _q.return)) _g.call(_q);
|
|
1182
1236
|
}
|
|
1183
|
-
finally { if (
|
|
1237
|
+
finally { if (e_30) throw e_30.error; }
|
|
1184
1238
|
}
|
|
1185
1239
|
relationships.add(THREADED_COMMENT_REL_TYPE, "../threadedComments/threadedComment".concat(sheet.sheetId, ".xml"));
|
|
1186
1240
|
}
|
|
@@ -1220,19 +1274,19 @@ var buildWorksheetXml = function (_a) {
|
|
|
1220
1274
|
if (row === null || row === void 0 ? void 0 : row.values) {
|
|
1221
1275
|
var rowValues = {};
|
|
1222
1276
|
try {
|
|
1223
|
-
for (var _t = (
|
|
1277
|
+
for (var _t = (e_31 = void 0, __values(Object.entries(row.values))), _u = _t.next(); !_u.done; _u = _t.next()) {
|
|
1224
1278
|
var _v = __read(_u.value, 2), colIndex = _v[0], cell = _v[1];
|
|
1225
1279
|
if (cell) {
|
|
1226
1280
|
rowValues[parseInt(colIndex, 10)] = cell;
|
|
1227
1281
|
}
|
|
1228
1282
|
}
|
|
1229
1283
|
}
|
|
1230
|
-
catch (
|
|
1284
|
+
catch (e_31_1) { e_31 = { error: e_31_1 }; }
|
|
1231
1285
|
finally {
|
|
1232
1286
|
try {
|
|
1233
1287
|
if (_u && !_u.done && (_h = _t.return)) _h.call(_t);
|
|
1234
1288
|
}
|
|
1235
|
-
finally { if (
|
|
1289
|
+
finally { if (e_31) throw e_31.error; }
|
|
1236
1290
|
}
|
|
1237
1291
|
if (Object.keys(rowValues).length > 0) {
|
|
1238
1292
|
rowDataMap[rowIndex] = rowValues;
|
|
@@ -1265,6 +1319,29 @@ var buildWorksheetXml = function (_a) {
|
|
|
1265
1319
|
threadedCommentsXml: threadedCommentsXml,
|
|
1266
1320
|
};
|
|
1267
1321
|
};
|
|
1322
|
+
/**
|
|
1323
|
+
* `CT_Chartsheet` — a sheet tab whose whole body is one chart and that has no
|
|
1324
|
+
* cells (#668 C-17). Children in schema order: `sheetPr` (tab colour only),
|
|
1325
|
+
* `sheetViews`, `pageMargins`, `drawing`. The chart itself rides the sheet's
|
|
1326
|
+
* drawing part as an `absoluteAnchor`, like every other chart.
|
|
1327
|
+
*/
|
|
1328
|
+
var buildChartsheetXml = function (_a) {
|
|
1329
|
+
var _b;
|
|
1330
|
+
var sheet = _a.sheet, relationships = _a.relationships, drawingContext = _a.drawingContext;
|
|
1331
|
+
var tabColor = serializeColorXml((_b = sheet.tabColor) !== null && _b !== void 0 ? _b : undefined);
|
|
1332
|
+
var sheetPrXml = tabColor ? "<sheetPr><tabColor ".concat(tabColor, "/></sheetPr>") : "";
|
|
1333
|
+
var drawingXml = drawingContext.hasDrawing()
|
|
1334
|
+
? "<drawing r:id=\"".concat(drawingContext.relId, "\"/>")
|
|
1335
|
+
: "";
|
|
1336
|
+
return {
|
|
1337
|
+
xml: "".concat(XML_DECLARATION, "<chartsheet xmlns=\"").concat(WORKSHEET_NS, "\" xmlns:r=\"").concat(REL_NS, "\">").concat(sheetPrXml, "<sheetViews><sheetView workbookViewId=\"0\" zoomToFit=\"1\"/></sheetViews>").concat(buildPageMarginsXml(sheet.printSettings)).concat(drawingXml, "</chartsheet>"),
|
|
1338
|
+
relationshipsXml: relationships.toXml(),
|
|
1339
|
+
images: [],
|
|
1340
|
+
commentsXml: undefined,
|
|
1341
|
+
vmlDrawingXml: undefined,
|
|
1342
|
+
threadedCommentsXml: undefined,
|
|
1343
|
+
};
|
|
1344
|
+
};
|
|
1268
1345
|
/**
|
|
1269
1346
|
* Build combined extLst XML for worksheet (sparklines + slicers)
|
|
1270
1347
|
*/
|
|
@@ -1316,7 +1393,7 @@ var sanitizeIndex = function (value) {
|
|
|
1316
1393
|
return Math.max(1, Math.floor(value));
|
|
1317
1394
|
};
|
|
1318
1395
|
var normalizeMergeRanges = function (ranges) {
|
|
1319
|
-
var
|
|
1396
|
+
var e_32, _a;
|
|
1320
1397
|
if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length))
|
|
1321
1398
|
return [];
|
|
1322
1399
|
var sanitized = ranges
|
|
@@ -1338,7 +1415,7 @@ var normalizeMergeRanges = function (ranges) {
|
|
|
1338
1415
|
});
|
|
1339
1416
|
var valid = [];
|
|
1340
1417
|
var active = [];
|
|
1341
|
-
var
|
|
1418
|
+
var _loop_4 = function (merge) {
|
|
1342
1419
|
if (active.length) {
|
|
1343
1420
|
active = active.filter(function (entry) { return entry.endRowIndex >= merge.startRowIndex; });
|
|
1344
1421
|
}
|
|
@@ -1355,15 +1432,15 @@ var normalizeMergeRanges = function (ranges) {
|
|
|
1355
1432
|
try {
|
|
1356
1433
|
for (var sorted_1 = __values(sorted), sorted_1_1 = sorted_1.next(); !sorted_1_1.done; sorted_1_1 = sorted_1.next()) {
|
|
1357
1434
|
var merge = sorted_1_1.value;
|
|
1358
|
-
|
|
1435
|
+
_loop_4(merge);
|
|
1359
1436
|
}
|
|
1360
1437
|
}
|
|
1361
|
-
catch (
|
|
1438
|
+
catch (e_32_1) { e_32 = { error: e_32_1 }; }
|
|
1362
1439
|
finally {
|
|
1363
1440
|
try {
|
|
1364
1441
|
if (sorted_1_1 && !sorted_1_1.done && (_a = sorted_1.return)) _a.call(sorted_1);
|
|
1365
1442
|
}
|
|
1366
|
-
finally { if (
|
|
1443
|
+
finally { if (e_32) throw e_32.error; }
|
|
1367
1444
|
}
|
|
1368
1445
|
return valid;
|
|
1369
1446
|
};
|
|
@@ -1730,7 +1807,7 @@ var buildWorksheetRow = function (_a) {
|
|
|
1730
1807
|
};
|
|
1731
1808
|
};
|
|
1732
1809
|
var buildCellXml = function (_a) {
|
|
1733
|
-
var
|
|
1810
|
+
var e_33, _b;
|
|
1734
1811
|
var _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1735
1812
|
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;
|
|
1736
1813
|
var normalizedCell = cell;
|
|
@@ -1827,12 +1904,12 @@ var buildCellXml = function (_a) {
|
|
|
1827
1904
|
sheetIdByName_1.set(s.title, s.sheetId);
|
|
1828
1905
|
}
|
|
1829
1906
|
}
|
|
1830
|
-
catch (
|
|
1907
|
+
catch (e_33_1) { e_33 = { error: e_33_1 }; }
|
|
1831
1908
|
finally {
|
|
1832
1909
|
try {
|
|
1833
1910
|
if (sheets_1_1 && !sheets_1_1.done && (_b = sheets_1.return)) _b.call(sheets_1);
|
|
1834
1911
|
}
|
|
1835
|
-
finally { if (
|
|
1912
|
+
finally { if (e_33) throw e_33.error; }
|
|
1836
1913
|
}
|
|
1837
1914
|
// A real CellXfsRegistry so `SheetCell.assign` inside the derive
|
|
1838
1915
|
// helper can resolve precedent cells whose `uf` is a `{ sid }` style
|
|
@@ -2069,7 +2146,7 @@ function isValidExcelDateSerial(value) {
|
|
|
2069
2146
|
return value >= MIN_EXCEL_DATE_SERIAL && value <= MAX_EXCEL_DATE_SERIAL;
|
|
2070
2147
|
}
|
|
2071
2148
|
function rewriteTableNamesInFormula(formula, tableNameMap) {
|
|
2072
|
-
var
|
|
2149
|
+
var e_34, _a;
|
|
2073
2150
|
if (!(tableNameMap === null || tableNameMap === void 0 ? void 0 : tableNameMap.size))
|
|
2074
2151
|
return formula;
|
|
2075
2152
|
var normalized = formula;
|
|
@@ -2084,12 +2161,12 @@ function rewriteTableNamesInFormula(formula, tableNameMap) {
|
|
|
2084
2161
|
normalized = normalized.replace(new RegExp("".concat(escaped, "(?=\\[)"), "g"), exportedName);
|
|
2085
2162
|
}
|
|
2086
2163
|
}
|
|
2087
|
-
catch (
|
|
2164
|
+
catch (e_34_1) { e_34 = { error: e_34_1 }; }
|
|
2088
2165
|
finally {
|
|
2089
2166
|
try {
|
|
2090
2167
|
if (tableNameMap_1_1 && !tableNameMap_1_1.done && (_a = tableNameMap_1.return)) _a.call(tableNameMap_1);
|
|
2091
2168
|
}
|
|
2092
|
-
finally { if (
|
|
2169
|
+
finally { if (e_34) throw e_34.error; }
|
|
2093
2170
|
}
|
|
2094
2171
|
return normalized;
|
|
2095
2172
|
}
|
|
@@ -2489,7 +2566,7 @@ var buildRichRunProperties = function (format) {
|
|
|
2489
2566
|
* style flag, but that's a cell-style concern, not a sharedString one.
|
|
2490
2567
|
*/
|
|
2491
2568
|
var buildRichTextRuns = function (text, runs) {
|
|
2492
|
-
var
|
|
2569
|
+
var e_35, _a;
|
|
2493
2570
|
var sorted = __spreadArray([], __read(runs), false).sort(function (a, b) { return a.startIndex - b.startIndex; });
|
|
2494
2571
|
var out = [];
|
|
2495
2572
|
var cursor = 0;
|
|
@@ -2522,12 +2599,12 @@ var buildRichTextRuns = function (text, runs) {
|
|
|
2522
2599
|
cursor = end;
|
|
2523
2600
|
}
|
|
2524
2601
|
}
|
|
2525
|
-
catch (
|
|
2602
|
+
catch (e_35_1) { e_35 = { error: e_35_1 }; }
|
|
2526
2603
|
finally {
|
|
2527
2604
|
try {
|
|
2528
2605
|
if (sorted_2_1 && !sorted_2_1.done && (_a = sorted_2.return)) _a.call(sorted_2);
|
|
2529
2606
|
}
|
|
2530
|
-
finally { if (
|
|
2607
|
+
finally { if (e_35) throw e_35.error; }
|
|
2531
2608
|
}
|
|
2532
2609
|
if (cursor < text.length) {
|
|
2533
2610
|
emit(text.slice(cursor), "");
|
|
@@ -2548,7 +2625,7 @@ var buildSharedStringsXml = function (sharedStrings) {
|
|
|
2548
2625
|
return "".concat(XML_DECLARATION, "<sst xmlns=\"").concat(WORKSHEET_NS, "\" count=\"").concat(sharedStrings.totalCount, "\" uniqueCount=\"").concat(sharedStrings.entries.length, "\">").concat(entries, "</sst>");
|
|
2549
2626
|
};
|
|
2550
2627
|
var buildTableNameMap = function (tables) {
|
|
2551
|
-
var
|
|
2628
|
+
var e_36, _a;
|
|
2552
2629
|
var _b;
|
|
2553
2630
|
var map = new Map();
|
|
2554
2631
|
try {
|
|
@@ -2560,12 +2637,12 @@ var buildTableNameMap = function (tables) {
|
|
|
2560
2637
|
map.set(tableTitle, table.name);
|
|
2561
2638
|
}
|
|
2562
2639
|
}
|
|
2563
|
-
catch (
|
|
2640
|
+
catch (e_36_1) { e_36 = { error: e_36_1 }; }
|
|
2564
2641
|
finally {
|
|
2565
2642
|
try {
|
|
2566
2643
|
if (tables_1_1 && !tables_1_1.done && (_a = tables_1.return)) _a.call(tables_1);
|
|
2567
2644
|
}
|
|
2568
|
-
finally { if (
|
|
2645
|
+
finally { if (e_36) throw e_36.error; }
|
|
2569
2646
|
}
|
|
2570
2647
|
return map;
|
|
2571
2648
|
};
|
|
@@ -2573,7 +2650,7 @@ var buildTableNameMap = function (tables) {
|
|
|
2573
2650
|
// whose box intersects another table on the same sheet. Drop both before
|
|
2574
2651
|
// emitting so the workbook opens without "We found a problem" recovery prompts.
|
|
2575
2652
|
var filterExportableTables = function (tables) {
|
|
2576
|
-
var
|
|
2653
|
+
var e_37, _a;
|
|
2577
2654
|
var _b;
|
|
2578
2655
|
var isValidBox = function (range) {
|
|
2579
2656
|
if (!range)
|
|
@@ -2600,7 +2677,7 @@ var filterExportableTables = function (tables) {
|
|
|
2600
2677
|
};
|
|
2601
2678
|
var keptBySheet = new Map();
|
|
2602
2679
|
var result = [];
|
|
2603
|
-
var
|
|
2680
|
+
var _loop_5 = function (table) {
|
|
2604
2681
|
if (!isValidBox(table.range))
|
|
2605
2682
|
return "continue";
|
|
2606
2683
|
var sheetKept = (_b = keptBySheet.get(table.sheetId)) !== null && _b !== void 0 ? _b : [];
|
|
@@ -2613,15 +2690,15 @@ var filterExportableTables = function (tables) {
|
|
|
2613
2690
|
try {
|
|
2614
2691
|
for (var tables_2 = __values(tables), tables_2_1 = tables_2.next(); !tables_2_1.done; tables_2_1 = tables_2.next()) {
|
|
2615
2692
|
var table = tables_2_1.value;
|
|
2616
|
-
|
|
2693
|
+
_loop_5(table);
|
|
2617
2694
|
}
|
|
2618
2695
|
}
|
|
2619
|
-
catch (
|
|
2696
|
+
catch (e_37_1) { e_37 = { error: e_37_1 }; }
|
|
2620
2697
|
finally {
|
|
2621
2698
|
try {
|
|
2622
2699
|
if (tables_2_1 && !tables_2_1.done && (_a = tables_2.return)) _a.call(tables_2);
|
|
2623
2700
|
}
|
|
2624
|
-
finally { if (
|
|
2701
|
+
finally { if (e_37) throw e_37.error; }
|
|
2625
2702
|
}
|
|
2626
2703
|
return result;
|
|
2627
2704
|
};
|
|
@@ -2697,8 +2774,8 @@ var resolveTableColumnTotals = function (column, totalsCell) {
|
|
|
2697
2774
|
var label = getExtendedValueString(getCellUserEnteredValue(totalsCell));
|
|
2698
2775
|
return label && label.trim() !== "" ? { totalsRowLabel: label } : undefined;
|
|
2699
2776
|
};
|
|
2700
|
-
var buildTableXml = function (table, rows, sourceSharedStrings, styleBuilder) {
|
|
2701
|
-
var _a, _b, _d;
|
|
2777
|
+
var buildTableXml = function (table, rows, sourceSharedStrings, styleBuilder, customTableStyleNames) {
|
|
2778
|
+
var _a, _b, _d, _e;
|
|
2702
2779
|
var rangeRef = table.ref;
|
|
2703
2780
|
var columnCount = Math.max((_b = (_a = table.columns) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0, ((_d = table.range.endColumnIndex) !== null && _d !== void 0 ? _d : table.range.startColumnIndex) -
|
|
2704
2781
|
table.range.startColumnIndex +
|
|
@@ -2774,18 +2851,76 @@ var buildTableXml = function (table, rows, sourceSharedStrings, styleBuilder) {
|
|
|
2774
2851
|
})
|
|
2775
2852
|
.join(""), "</tableColumns>");
|
|
2776
2853
|
var isBuiltInStyle = table.theme && /^TableStyle(Light|Medium|Dark)\d+$/.test(table.theme);
|
|
2777
|
-
|
|
2854
|
+
// A custom style written to `<tableStyles>` keeps its name here (#668 T-103).
|
|
2855
|
+
var isCustomStyle = !!table.theme && ((_e = customTableStyleNames === null || customTableStyleNames === void 0 ? void 0 : customTableStyleNames.has(table.theme)) !== null && _e !== void 0 ? _e : false);
|
|
2856
|
+
var tableStyleName = isBuiltInStyle || isCustomStyle ? table.theme : "TableStyleMedium2";
|
|
2778
2857
|
var tableStyleInfo = "<tableStyleInfo name=\"".concat(tableStyleName, "\" showFirstColumn=\"").concat(table.showFirstColumn ? 1 : 0, "\" showLastColumn=\"").concat(table.showLastColumn ? 1 : 0, "\" showRowStripes=\"").concat(table.showRowStripes ? 1 : 0, "\" showColumnStripes=\"").concat(table.showColumnStripes ? 1 : 0, "\"/>");
|
|
2858
|
+
// Excel's per-column "filter button" toggle: `<filterColumn hiddenButton="1">`
|
|
2859
|
+
// (the table-level toggle is the presence of `<autoFilter>` itself).
|
|
2860
|
+
var hiddenButtonColumns = new Set(columnNames
|
|
2861
|
+
.map(function (_, idx) { return idx; })
|
|
2862
|
+
.filter(function (idx) { var _a, _b; return ((_b = (_a = table.columns) === null || _a === void 0 ? void 0 : _a[idx]) === null || _b === void 0 ? void 0 : _b.filterButton) === false; }));
|
|
2779
2863
|
var autoFilter = headerRowCount > 0 && table.filterButton !== false
|
|
2780
2864
|
? (function () {
|
|
2781
2865
|
var _a, _b, _d;
|
|
2782
|
-
var filterColumns = buildFilterColumnsXml((_a = table.filterSpecs) !== null && _a !== void 0 ? _a : [], table.range, rows, (_b = table.headerRow) !== null && _b !== void 0 ? _b : true, (_d = table.totalRow) !== null && _d !== void 0 ? _d : false, styleBuilder);
|
|
2866
|
+
var filterColumns = buildFilterColumnsXml((_a = table.filterSpecs) !== null && _a !== void 0 ? _a : [], table.range, rows, (_b = table.headerRow) !== null && _b !== void 0 ? _b : true, (_d = table.totalRow) !== null && _d !== void 0 ? _d : false, styleBuilder, hiddenButtonColumns);
|
|
2783
2867
|
return filterColumns
|
|
2784
2868
|
? "<autoFilter ref=\"".concat(rangeRef, "\">").concat(filterColumns, "</autoFilter>")
|
|
2785
2869
|
: "<autoFilter ref=\"".concat(rangeRef, "\"/>");
|
|
2786
2870
|
})()
|
|
2787
2871
|
: "";
|
|
2788
|
-
|
|
2872
|
+
var sortState = buildTableSortStateXml(table, headerRowCount, totalsRowCount, styleBuilder);
|
|
2873
|
+
return "".concat(XML_DECLARATION, "<table xmlns=\"").concat(WORKSHEET_NS, "\" id=\"").concat(table.id, "\" name=\"").concat(escapeXmlAttr(table.name), "\" displayName=\"").concat(escapeXmlAttr(table.displayName), "\" ref=\"").concat(rangeRef, "\" totalsRowCount=\"").concat(totalsRowCount, "\" headerRowCount=\"").concat(headerRowCount, "\">").concat(autoFilter).concat(sortState).concat(tableColumns).concat(tableStyleInfo, "</table>");
|
|
2874
|
+
};
|
|
2875
|
+
/**
|
|
2876
|
+
* A table's persisted sort levels as `<sortState ref="<body>">` with one
|
|
2877
|
+
* `<sortCondition>` per level (`CT_SortCondition`: `ref` is the level's
|
|
2878
|
+
* column over the body rows, `descending`, `sortBy` + `dxfId` for a colour
|
|
2879
|
+
* level, `sortBy="icon"` + `iconSet`/`iconId`, and Excel's comma-joined
|
|
2880
|
+
* `customList`). Sits between `<autoFilter>` and `<tableColumns>` per
|
|
2881
|
+
* `CT_Table`. The inverse of the parser's `createSortSpecsFromSortState`.
|
|
2882
|
+
*/
|
|
2883
|
+
var buildTableSortStateXml = function (table, headerRowCount, totalsRowCount, styleBuilder) {
|
|
2884
|
+
var _a;
|
|
2885
|
+
var sortSpecs = (_a = table.sortSpecs) !== null && _a !== void 0 ? _a : [];
|
|
2886
|
+
var bodyStartRow = table.range.startRowIndex + headerRowCount;
|
|
2887
|
+
var bodyEndRow = table.range.endRowIndex - totalsRowCount;
|
|
2888
|
+
if (!sortSpecs.length || bodyEndRow < bodyStartRow)
|
|
2889
|
+
return "";
|
|
2890
|
+
var bodyRef = function (startColumnIndex, endColumnIndex) {
|
|
2891
|
+
return cellRangeToAddress(undefined, {
|
|
2892
|
+
startRowIndex: bodyStartRow,
|
|
2893
|
+
endRowIndex: bodyEndRow,
|
|
2894
|
+
startColumnIndex: startColumnIndex,
|
|
2895
|
+
endColumnIndex: endColumnIndex,
|
|
2896
|
+
});
|
|
2897
|
+
};
|
|
2898
|
+
var conditions = sortSpecs.map(function (spec) {
|
|
2899
|
+
var _a, _b, _d;
|
|
2900
|
+
var columnIndex = table.range.startColumnIndex + spec.dimensionIndex;
|
|
2901
|
+
var attrs = ["ref=\"".concat(bodyRef(columnIndex, columnIndex), "\"")];
|
|
2902
|
+
if (spec.sortOrder === "DESCENDING")
|
|
2903
|
+
attrs.push("descending=\"1\"");
|
|
2904
|
+
var sortBy = (_a = spec.sortBy) !== null && _a !== void 0 ? _a : "value";
|
|
2905
|
+
if (sortBy === "cellColor" || sortBy === "fontColor") {
|
|
2906
|
+
attrs.push("sortBy=\"".concat(sortBy, "\""));
|
|
2907
|
+
var dxfId = spec.sortColor && styleBuilder
|
|
2908
|
+
? styleBuilder.registerDifferentialFormat(sortBy === "cellColor"
|
|
2909
|
+
? { backgroundColor: spec.sortColor }
|
|
2910
|
+
: { textFormat: { color: spec.sortColor } })
|
|
2911
|
+
: undefined;
|
|
2912
|
+
if (typeof dxfId === "number")
|
|
2913
|
+
attrs.push("dxfId=\"".concat(dxfId, "\""));
|
|
2914
|
+
}
|
|
2915
|
+
else if (sortBy === "icon" && spec.sortIcon) {
|
|
2916
|
+
attrs.push("sortBy=\"icon\"", "iconSet=\"".concat(escapeXmlAttr(spec.sortIcon.iconSet), "\""), "iconId=\"".concat((_b = spec.sortIcon.iconId) !== null && _b !== void 0 ? _b : 0, "\""));
|
|
2917
|
+
}
|
|
2918
|
+
if ((_d = spec.customList) === null || _d === void 0 ? void 0 : _d.length) {
|
|
2919
|
+
attrs.push("customList=\"".concat(escapeXmlAttr(spec.customList.join(",")), "\""));
|
|
2920
|
+
}
|
|
2921
|
+
return "<sortCondition ".concat(attrs.join(" "), "/>");
|
|
2922
|
+
});
|
|
2923
|
+
return "<sortState ref=\"".concat(bodyRef(table.range.startColumnIndex, table.range.endColumnIndex), "\">").concat(conditions.join(""), "</sortState>");
|
|
2789
2924
|
};
|
|
2790
2925
|
var getFilterVisibleValues = function (spec, range, rows, headerRow, totalRow) {
|
|
2791
2926
|
var _a, _b, _d;
|
|
@@ -2846,7 +2981,7 @@ var SHEET_PROTECTION_FLAG_ATTRS = [
|
|
|
2846
2981
|
* Excel's schema default applies). Mirrors `rnc-export`'s `sheet_protection_xml`.
|
|
2847
2982
|
*/
|
|
2848
2983
|
var buildSheetProtectionElementXml = function (protection) {
|
|
2849
|
-
var
|
|
2984
|
+
var e_38, _a;
|
|
2850
2985
|
var attrs = [];
|
|
2851
2986
|
if (protection.algorithmName) {
|
|
2852
2987
|
attrs.push("algorithmName=\"".concat(escapeXmlAttr(protection.algorithmName), "\""));
|
|
@@ -2872,12 +3007,12 @@ var buildSheetProtectionElementXml = function (protection) {
|
|
|
2872
3007
|
}
|
|
2873
3008
|
}
|
|
2874
3009
|
}
|
|
2875
|
-
catch (
|
|
3010
|
+
catch (e_38_1) { e_38 = { error: e_38_1 }; }
|
|
2876
3011
|
finally {
|
|
2877
3012
|
try {
|
|
2878
3013
|
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);
|
|
2879
3014
|
}
|
|
2880
|
-
finally { if (
|
|
3015
|
+
finally { if (e_38) throw e_38.error; }
|
|
2881
3016
|
}
|
|
2882
3017
|
return attrs.length ? "<sheetProtection ".concat(attrs.join(" "), "/>") : "";
|
|
2883
3018
|
};
|
|
@@ -2889,7 +3024,7 @@ var buildSheetProtectionElementXml = function (protection) {
|
|
|
2889
3024
|
* is the range's id, synthesized as `Range{n}` when absent (schema requires it).
|
|
2890
3025
|
*/
|
|
2891
3026
|
var buildSheetProtectionXml = function (sheet, protectedRanges) {
|
|
2892
|
-
var
|
|
3027
|
+
var e_39, _a;
|
|
2893
3028
|
var protectionXml = sheet.sheetProtection
|
|
2894
3029
|
? buildSheetProtectionElementXml(sheet.sheetProtection)
|
|
2895
3030
|
: "";
|
|
@@ -2930,12 +3065,12 @@ var buildSheetProtectionXml = function (sheet, protectedRanges) {
|
|
|
2930
3065
|
rangeItems.push("<protectedRange sqref=\"".concat(escapeXmlAttr(sqref), "\" name=\"").concat(escapeXmlAttr(name_1), "\"").concat(securityDescriptor, "/>"));
|
|
2931
3066
|
}
|
|
2932
3067
|
}
|
|
2933
|
-
catch (
|
|
3068
|
+
catch (e_39_1) { e_39 = { error: e_39_1 }; }
|
|
2934
3069
|
finally {
|
|
2935
3070
|
try {
|
|
2936
3071
|
if (_d && !_d.done && (_a = _b.return)) _a.call(_b);
|
|
2937
3072
|
}
|
|
2938
|
-
finally { if (
|
|
3073
|
+
finally { if (e_39) throw e_39.error; }
|
|
2939
3074
|
}
|
|
2940
3075
|
var rangesXml = rangeItems.length
|
|
2941
3076
|
? "<protectedRanges>".concat(rangeItems.join(""), "</protectedRanges>")
|
|
@@ -2984,8 +3119,14 @@ var xmlNumAttr = function (name, value) {
|
|
|
2984
3119
|
* mandatory in practice (Excel always writes it), so the default margins go
|
|
2985
3120
|
* out when the sheet has none of its own.
|
|
2986
3121
|
*/
|
|
2987
|
-
var
|
|
3122
|
+
var buildPageMarginsXml = function (print) {
|
|
2988
3123
|
var _a, _b, _d, _e, _f, _g;
|
|
3124
|
+
var margins = print === null || print === void 0 ? void 0 : print.pageMargins;
|
|
3125
|
+
return margins && Object.values(margins).some(function (v) { return typeof v === "number"; })
|
|
3126
|
+
? "<pageMargins left=\"".concat((_a = margins.left) !== null && _a !== void 0 ? _a : 0.7, "\" right=\"").concat((_b = margins.right) !== null && _b !== void 0 ? _b : 0.7, "\" top=\"").concat((_d = margins.top) !== null && _d !== void 0 ? _d : 0.75, "\" bottom=\"").concat((_e = margins.bottom) !== null && _e !== void 0 ? _e : 0.75, "\" header=\"").concat((_f = margins.header) !== null && _f !== void 0 ? _f : 0.3, "\" footer=\"").concat((_g = margins.footer) !== null && _g !== void 0 ? _g : 0.3, "\"/>")
|
|
3127
|
+
: DEFAULT_PAGE_MARGINS;
|
|
3128
|
+
};
|
|
3129
|
+
var buildPrintSettingsXml = function (print) {
|
|
2989
3130
|
var parts = [];
|
|
2990
3131
|
var options = print === null || print === void 0 ? void 0 : print.printOptions;
|
|
2991
3132
|
var optionAttrs = xmlBoolAttr("horizontalCentered", options === null || options === void 0 ? void 0 : options.horizontalCentered) +
|
|
@@ -2994,11 +3135,7 @@ var buildPrintSettingsXml = function (print) {
|
|
|
2994
3135
|
xmlBoolAttr("gridLines", options === null || options === void 0 ? void 0 : options.gridLines);
|
|
2995
3136
|
if (optionAttrs)
|
|
2996
3137
|
parts.push("<printOptions".concat(optionAttrs, "/>"));
|
|
2997
|
-
|
|
2998
|
-
parts.push(margins &&
|
|
2999
|
-
Object.values(margins).some(function (v) { return typeof v === "number"; })
|
|
3000
|
-
? "<pageMargins left=\"".concat((_a = margins.left) !== null && _a !== void 0 ? _a : 0.7, "\" right=\"").concat((_b = margins.right) !== null && _b !== void 0 ? _b : 0.7, "\" top=\"").concat((_d = margins.top) !== null && _d !== void 0 ? _d : 0.75, "\" bottom=\"").concat((_e = margins.bottom) !== null && _e !== void 0 ? _e : 0.75, "\" header=\"").concat((_f = margins.header) !== null && _f !== void 0 ? _f : 0.3, "\" footer=\"").concat((_g = margins.footer) !== null && _g !== void 0 ? _g : 0.3, "\"/>")
|
|
3001
|
-
: DEFAULT_PAGE_MARGINS);
|
|
3138
|
+
parts.push(buildPageMarginsXml(print));
|
|
3002
3139
|
var setup = print === null || print === void 0 ? void 0 : print.pageSetup;
|
|
3003
3140
|
if (setup) {
|
|
3004
3141
|
// Excel keeps `firstPageNumber` as a dormant value until the user picks
|
|
@@ -3063,20 +3200,49 @@ var buildPrintSettingsXml = function (print) {
|
|
|
3063
3200
|
}
|
|
3064
3201
|
return parts.join("");
|
|
3065
3202
|
};
|
|
3066
|
-
var buildFilterColumnsXml = function (filterSpecs, range, rows, headerRow, totalRow, styleBuilder
|
|
3203
|
+
var buildFilterColumnsXml = function (filterSpecs, range, rows, headerRow, totalRow, styleBuilder,
|
|
3204
|
+
/** Table-relative column ids whose header hides its filter button. */
|
|
3205
|
+
hiddenButtonColumns) {
|
|
3206
|
+
var e_40, _a;
|
|
3067
3207
|
if (headerRow === void 0) { headerRow = true; }
|
|
3068
3208
|
if (totalRow === void 0) { totalRow = false; }
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3209
|
+
var entries = new Map();
|
|
3210
|
+
try {
|
|
3211
|
+
for (var _b = __values(filterSpecs !== null && filterSpecs !== void 0 ? filterSpecs : []), _d = _b.next(); !_d.done; _d = _b.next()) {
|
|
3212
|
+
var spec = _d.value;
|
|
3213
|
+
var xml = buildFilterColumnXml(spec, range, rows, headerRow, totalRow, styleBuilder);
|
|
3214
|
+
if (xml)
|
|
3215
|
+
entries.set(spec.columnIndex, xml);
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
catch (e_40_1) { e_40 = { error: e_40_1 }; }
|
|
3219
|
+
finally {
|
|
3220
|
+
try {
|
|
3221
|
+
if (_d && !_d.done && (_a = _b.return)) _a.call(_b);
|
|
3222
|
+
}
|
|
3223
|
+
finally { if (e_40) throw e_40.error; }
|
|
3224
|
+
}
|
|
3225
|
+
// `hiddenButton="1"` rides the column's criteria element when it has one,
|
|
3226
|
+
// else a bare `<filterColumn/>` carries it.
|
|
3227
|
+
hiddenButtonColumns === null || hiddenButtonColumns === void 0 ? void 0 : hiddenButtonColumns.forEach(function (colId) {
|
|
3228
|
+
var existing = entries.get(colId);
|
|
3229
|
+
entries.set(colId, existing
|
|
3230
|
+
? existing.replace("<filterColumn colId=\"".concat(colId, "\">"), "<filterColumn colId=\"".concat(colId, "\" hiddenButton=\"1\">"))
|
|
3231
|
+
: "<filterColumn colId=\"".concat(colId, "\" hiddenButton=\"1\"/>"));
|
|
3232
|
+
});
|
|
3233
|
+
return __spreadArray([], __read(entries.entries()), false).sort(function (_a, _b) {
|
|
3234
|
+
var _d = __read(_a, 1), a = _d[0];
|
|
3235
|
+
var _e = __read(_b, 1), b = _e[0];
|
|
3236
|
+
return a - b;
|
|
3237
|
+
})
|
|
3238
|
+
.map(function (_a) {
|
|
3239
|
+
var _b = __read(_a, 2), xml = _b[1];
|
|
3240
|
+
return xml;
|
|
3074
3241
|
})
|
|
3075
|
-
.
|
|
3076
|
-
return entries.join("");
|
|
3242
|
+
.join("");
|
|
3077
3243
|
};
|
|
3078
3244
|
var buildFilterColumnXml = function (spec, range, rows, headerRow, totalRow, styleBuilder) {
|
|
3079
|
-
var _a, _b, _d, _e, _f
|
|
3245
|
+
var _a, _b, _d, _e, _f;
|
|
3080
3246
|
if (headerRow === void 0) { headerRow = true; }
|
|
3081
3247
|
if (totalRow === void 0) { totalRow = false; }
|
|
3082
3248
|
var parts = [];
|
|
@@ -3105,13 +3271,15 @@ var buildFilterColumnXml = function (spec, range, rows, headerRow, totalRow, sty
|
|
|
3105
3271
|
// above-average …) takes precedence over a value-list and is emitted as
|
|
3106
3272
|
// <customFilters> or <dynamicFilter>. Falls back to the value list when the
|
|
3107
3273
|
// condition has no AutoFilter representation.
|
|
3108
|
-
var conditionXml =
|
|
3274
|
+
var conditionXml = spec.filterCriteria
|
|
3275
|
+
? buildAutoFilterCriteriaXml(spec.filterCriteria)
|
|
3276
|
+
: null;
|
|
3109
3277
|
if (conditionXml) {
|
|
3110
3278
|
parts.push(conditionXml);
|
|
3111
3279
|
}
|
|
3112
3280
|
else {
|
|
3113
3281
|
// <filters><filter val=…/></filters>
|
|
3114
|
-
var values = (
|
|
3282
|
+
var values = (_f = (_e = spec.filterCriteria) === null || _e === void 0 ? void 0 : _e.visibleValues) !== null && _f !== void 0 ? _f : getFilterVisibleValues(spec, range, rows, headerRow, totalRow);
|
|
3115
3283
|
if (values === null || values === void 0 ? void 0 : values.length) {
|
|
3116
3284
|
var filters = values
|
|
3117
3285
|
.map(function (value) { return "<filter val=\"".concat(escapeXmlAttr(value), "\"/>"); })
|
|
@@ -3134,10 +3302,10 @@ var gridRangeToRef = function (range) {
|
|
|
3134
3302
|
return undefined;
|
|
3135
3303
|
}
|
|
3136
3304
|
};
|
|
3137
|
-
var groupEmbedsBySheet = function (embeds) {
|
|
3305
|
+
var groupEmbedsBySheet = function (embeds, chartCount) {
|
|
3138
3306
|
var result = new Map();
|
|
3139
|
-
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed,
|
|
3140
|
-
var _a, _b, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
3307
|
+
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed, index) {
|
|
3308
|
+
var _a, _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
3141
3309
|
if (!((_a = embed.position) === null || _a === void 0 ? void 0 : _a.overlayPosition))
|
|
3142
3310
|
return;
|
|
3143
3311
|
if (((_b = embed.spec) === null || _b === void 0 ? void 0 : _b.type) !== "image")
|
|
@@ -3156,24 +3324,25 @@ var groupEmbedsBySheet = function (embeds) {
|
|
|
3156
3324
|
adjustments: Object.values(adjustments).some(function (v) { return v !== undefined; })
|
|
3157
3325
|
? adjustments
|
|
3158
3326
|
: undefined,
|
|
3159
|
-
order:
|
|
3327
|
+
order: (_h = embed.position.zOrder) !== null && _h !== void 0 ? _h : chartCount + index,
|
|
3160
3328
|
rowIndex: overlay.anchorCell.rowIndex,
|
|
3161
3329
|
columnIndex: overlay.anchorCell.columnIndex,
|
|
3162
|
-
offsetX: (
|
|
3163
|
-
offsetY: (
|
|
3164
|
-
width: (
|
|
3165
|
-
height: (
|
|
3330
|
+
offsetX: (_j = overlay.offsetXPixels) !== null && _j !== void 0 ? _j : 0,
|
|
3331
|
+
offsetY: (_k = overlay.offsetYPixels) !== null && _k !== void 0 ? _k : 0,
|
|
3332
|
+
width: (_l = overlay.widthPixels) !== null && _l !== void 0 ? _l : 120,
|
|
3333
|
+
height: (_m = overlay.heightPixels) !== null && _m !== void 0 ? _m : 120,
|
|
3334
|
+
overlay: overlay,
|
|
3166
3335
|
};
|
|
3167
|
-
var list = (
|
|
3336
|
+
var list = (_o = result.get(embed.position.sheetId)) !== null && _o !== void 0 ? _o : [];
|
|
3168
3337
|
list.push(placement);
|
|
3169
3338
|
result.set(embed.position.sheetId, list);
|
|
3170
3339
|
});
|
|
3171
3340
|
return result;
|
|
3172
3341
|
};
|
|
3173
|
-
var groupTextBoxesBySheet = function (embeds) {
|
|
3342
|
+
var groupTextBoxesBySheet = function (embeds, chartCount) {
|
|
3174
3343
|
var result = new Map();
|
|
3175
|
-
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed,
|
|
3176
|
-
var _a, _b, _d, _e, _f, _g, _h;
|
|
3344
|
+
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed, index) {
|
|
3345
|
+
var _a, _b, _d, _e, _f, _g, _h, _j;
|
|
3177
3346
|
if (!((_a = embed.position) === null || _a === void 0 ? void 0 : _a.overlayPosition))
|
|
3178
3347
|
return;
|
|
3179
3348
|
if (((_b = embed.spec) === null || _b === void 0 ? void 0 : _b.type) !== "textbox")
|
|
@@ -3181,25 +3350,25 @@ var groupTextBoxesBySheet = function (embeds) {
|
|
|
3181
3350
|
var overlay = embed.position.overlayPosition;
|
|
3182
3351
|
var placement = {
|
|
3183
3352
|
textBox: embed,
|
|
3184
|
-
order:
|
|
3353
|
+
order: (_d = embed.position.zOrder) !== null && _d !== void 0 ? _d : chartCount + index,
|
|
3185
3354
|
rowIndex: overlay.anchorCell.rowIndex,
|
|
3186
3355
|
columnIndex: overlay.anchorCell.columnIndex,
|
|
3187
|
-
offsetX: (
|
|
3188
|
-
offsetY: (
|
|
3189
|
-
width: (
|
|
3190
|
-
height: (
|
|
3356
|
+
offsetX: (_e = overlay.offsetXPixels) !== null && _e !== void 0 ? _e : 0,
|
|
3357
|
+
offsetY: (_f = overlay.offsetYPixels) !== null && _f !== void 0 ? _f : 0,
|
|
3358
|
+
width: (_g = overlay.widthPixels) !== null && _g !== void 0 ? _g : 120,
|
|
3359
|
+
height: (_h = overlay.heightPixels) !== null && _h !== void 0 ? _h : 60,
|
|
3191
3360
|
};
|
|
3192
|
-
var list = (
|
|
3361
|
+
var list = (_j = result.get(embed.position.sheetId)) !== null && _j !== void 0 ? _j : [];
|
|
3193
3362
|
list.push(placement);
|
|
3194
3363
|
result.set(embed.position.sheetId, list);
|
|
3195
3364
|
});
|
|
3196
3365
|
return result;
|
|
3197
3366
|
};
|
|
3198
3367
|
/** Form-control embeds (`spec.type === "formControl"`) by sheet, in host order. */
|
|
3199
|
-
var groupFormControlsBySheet = function (embeds) {
|
|
3368
|
+
var groupFormControlsBySheet = function (embeds, chartCount) {
|
|
3200
3369
|
var result = new Map();
|
|
3201
|
-
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed,
|
|
3202
|
-
var _a, _b, _d, _e, _f, _g, _h;
|
|
3370
|
+
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed, index) {
|
|
3371
|
+
var _a, _b, _d, _e, _f, _g, _h, _j;
|
|
3203
3372
|
if (!((_a = embed.position) === null || _a === void 0 ? void 0 : _a.overlayPosition))
|
|
3204
3373
|
return;
|
|
3205
3374
|
if (((_b = embed.spec) === null || _b === void 0 ? void 0 : _b.type) !== "formControl")
|
|
@@ -3207,15 +3376,15 @@ var groupFormControlsBySheet = function (embeds) {
|
|
|
3207
3376
|
var overlay = embed.position.overlayPosition;
|
|
3208
3377
|
var placement = {
|
|
3209
3378
|
shape: embed,
|
|
3210
|
-
order:
|
|
3379
|
+
order: (_d = embed.position.zOrder) !== null && _d !== void 0 ? _d : chartCount + index,
|
|
3211
3380
|
rowIndex: overlay.anchorCell.rowIndex,
|
|
3212
3381
|
columnIndex: overlay.anchorCell.columnIndex,
|
|
3213
|
-
offsetX: (
|
|
3214
|
-
offsetY: (
|
|
3215
|
-
width: (
|
|
3216
|
-
height: (
|
|
3382
|
+
offsetX: (_e = overlay.offsetXPixels) !== null && _e !== void 0 ? _e : 0,
|
|
3383
|
+
offsetY: (_f = overlay.offsetYPixels) !== null && _f !== void 0 ? _f : 0,
|
|
3384
|
+
width: (_g = overlay.widthPixels) !== null && _g !== void 0 ? _g : 120,
|
|
3385
|
+
height: (_h = overlay.heightPixels) !== null && _h !== void 0 ? _h : 20,
|
|
3217
3386
|
};
|
|
3218
|
-
var list = (
|
|
3387
|
+
var list = (_j = result.get(embed.position.sheetId)) !== null && _j !== void 0 ? _j : [];
|
|
3219
3388
|
list.push(placement);
|
|
3220
3389
|
result.set(embed.position.sheetId, list);
|
|
3221
3390
|
});
|
|
@@ -3254,7 +3423,7 @@ var buildSheetFormControls = function (_a) {
|
|
|
3254
3423
|
return total;
|
|
3255
3424
|
};
|
|
3256
3425
|
controls.forEach(function (placement, position) {
|
|
3257
|
-
var _a, _b, _d, _e;
|
|
3426
|
+
var _a, _b, _d, _e, _f, _g, _h;
|
|
3258
3427
|
var spec = placement.shape.spec;
|
|
3259
3428
|
var fromRow = Math.max(0, placement.rowIndex - 1);
|
|
3260
3429
|
var fromColumn = Math.max(0, placement.columnIndex - 1);
|
|
@@ -3264,18 +3433,33 @@ var buildSheetFormControls = function (_a) {
|
|
|
3264
3433
|
var heightPx = Math.max(5, (_e = placement.height) !== null && _e !== void 0 ? _e : 20);
|
|
3265
3434
|
var columnSize = function (index) { return getColumnWidthPx(sheet, index, true); };
|
|
3266
3435
|
var rowSize = function (index) { return getRowHeightPx(sheet, index, true); };
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3436
|
+
// A "Move and size" control keeps its persisted second anchor (#668 C-46)
|
|
3437
|
+
var overlay = (_f = placement.shape.position) === null || _f === void 0 ? void 0 : _f.overlayPosition;
|
|
3438
|
+
var persistedTo = controlAnchorFlags(spec, overlay).sizeWithCells && (overlay === null || overlay === void 0 ? void 0 : overlay.toCell)
|
|
3439
|
+
? overlay.toCell
|
|
3440
|
+
: undefined;
|
|
3441
|
+
var toColumn = persistedTo
|
|
3442
|
+
? {
|
|
3443
|
+
index: Math.max(0, persistedTo.columnIndex - 1),
|
|
3444
|
+
offset: Math.max(0, (_g = overlay === null || overlay === void 0 ? void 0 : overlay.toOffsetXPixels) !== null && _g !== void 0 ? _g : 0),
|
|
3445
|
+
}
|
|
3446
|
+
: resolveAnchorEndpoint({
|
|
3447
|
+
startIndex: fromColumn,
|
|
3448
|
+
startOffset: offsetX,
|
|
3449
|
+
span: widthPx,
|
|
3450
|
+
getSize: columnSize,
|
|
3451
|
+
});
|
|
3452
|
+
var toRow = persistedTo
|
|
3453
|
+
? {
|
|
3454
|
+
index: Math.max(0, persistedTo.rowIndex - 1),
|
|
3455
|
+
offset: Math.max(0, (_h = overlay === null || overlay === void 0 ? void 0 : overlay.toOffsetYPixels) !== null && _h !== void 0 ? _h : 0),
|
|
3456
|
+
}
|
|
3457
|
+
: resolveAnchorEndpoint({
|
|
3458
|
+
startIndex: fromRow,
|
|
3459
|
+
startOffset: offsetY,
|
|
3460
|
+
span: heightPx,
|
|
3461
|
+
getSize: rowSize,
|
|
3462
|
+
});
|
|
3279
3463
|
var partIndex = ctrlProps.parts.length + 1;
|
|
3280
3464
|
var path = "xl/ctrlProps/ctrlProp".concat(partIndex, ".xml");
|
|
3281
3465
|
ctrlProps.parts.push({ path: path, xml: buildCtrlPropXml(spec) });
|
|
@@ -3297,11 +3481,13 @@ var buildSheetFormControls = function (_a) {
|
|
|
3297
3481
|
row: toRow.index,
|
|
3298
3482
|
rowOff: toRow.offset * EMUS_PER_PIXEL,
|
|
3299
3483
|
},
|
|
3484
|
+
overlay: overlay,
|
|
3300
3485
|
}));
|
|
3301
3486
|
vmlShapes.push(buildFormControlVmlShape({
|
|
3302
3487
|
spec: spec,
|
|
3303
3488
|
shapeId: shapeId,
|
|
3304
3489
|
zIndex: zIndexStart + position + 1,
|
|
3490
|
+
overlay: overlay,
|
|
3305
3491
|
geometry: {
|
|
3306
3492
|
leftPx: sumSizes(fromColumn, columnSize) + offsetX,
|
|
3307
3493
|
topPx: sumSizes(fromRow, rowSize) + offsetY,
|
|
@@ -3322,10 +3508,10 @@ var buildSheetFormControls = function (_a) {
|
|
|
3322
3508
|
});
|
|
3323
3509
|
return { controlsXml: buildControlsXml(controlElements), vmlShapes: vmlShapes };
|
|
3324
3510
|
};
|
|
3325
|
-
var groupShapesBySheet = function (embeds) {
|
|
3511
|
+
var groupShapesBySheet = function (embeds, chartCount) {
|
|
3326
3512
|
var result = new Map();
|
|
3327
|
-
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed,
|
|
3328
|
-
var _a, _b, _d, _e, _f, _g, _h;
|
|
3513
|
+
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed, index) {
|
|
3514
|
+
var _a, _b, _d, _e, _f, _g, _h, _j;
|
|
3329
3515
|
if (!((_a = embed.position) === null || _a === void 0 ? void 0 : _a.overlayPosition))
|
|
3330
3516
|
return;
|
|
3331
3517
|
if (((_b = embed.spec) === null || _b === void 0 ? void 0 : _b.type) !== "shape")
|
|
@@ -3333,55 +3519,45 @@ var groupShapesBySheet = function (embeds) {
|
|
|
3333
3519
|
var overlay = embed.position.overlayPosition;
|
|
3334
3520
|
var placement = {
|
|
3335
3521
|
shape: embed,
|
|
3336
|
-
order:
|
|
3522
|
+
order: (_d = embed.position.zOrder) !== null && _d !== void 0 ? _d : chartCount + index,
|
|
3337
3523
|
rowIndex: overlay.anchorCell.rowIndex,
|
|
3338
3524
|
columnIndex: overlay.anchorCell.columnIndex,
|
|
3339
|
-
offsetX: (
|
|
3340
|
-
offsetY: (
|
|
3341
|
-
width: (
|
|
3342
|
-
height: (
|
|
3525
|
+
offsetX: (_e = overlay.offsetXPixels) !== null && _e !== void 0 ? _e : 0,
|
|
3526
|
+
offsetY: (_f = overlay.offsetYPixels) !== null && _f !== void 0 ? _f : 0,
|
|
3527
|
+
width: (_g = overlay.widthPixels) !== null && _g !== void 0 ? _g : 120,
|
|
3528
|
+
height: (_h = overlay.heightPixels) !== null && _h !== void 0 ? _h : 60,
|
|
3343
3529
|
};
|
|
3344
|
-
var list = (
|
|
3530
|
+
var list = (_j = result.get(embed.position.sheetId)) !== null && _j !== void 0 ? _j : [];
|
|
3345
3531
|
list.push(placement);
|
|
3346
3532
|
result.set(embed.position.sheetId, list);
|
|
3347
3533
|
});
|
|
3348
3534
|
return result;
|
|
3349
3535
|
};
|
|
3350
3536
|
var groupChartsBySheet = function (charts) {
|
|
3351
|
-
var e_39, _a;
|
|
3352
|
-
var _b, _d, _e, _f, _g, _h;
|
|
3353
3537
|
var result = new Map();
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
}
|
|
3374
|
-
catch (e_39_1) { e_39 = { error: e_39_1 }; }
|
|
3375
|
-
finally {
|
|
3376
|
-
try {
|
|
3377
|
-
if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
|
|
3378
|
-
}
|
|
3379
|
-
finally { if (e_39) throw e_39.error; }
|
|
3380
|
-
}
|
|
3538
|
+
(charts !== null && charts !== void 0 ? charts : []).forEach(function (chart, index) {
|
|
3539
|
+
var _a, _b, _d, _e, _f, _g, _h;
|
|
3540
|
+
var overlay = (_a = chart.position) === null || _a === void 0 ? void 0 : _a.overlayPosition;
|
|
3541
|
+
if (!overlay)
|
|
3542
|
+
return;
|
|
3543
|
+
var placement = {
|
|
3544
|
+
chart: chart,
|
|
3545
|
+
order: (_b = chart.position.zOrder) !== null && _b !== void 0 ? _b : index,
|
|
3546
|
+
rowIndex: overlay.anchorCell.rowIndex,
|
|
3547
|
+
columnIndex: overlay.anchorCell.columnIndex,
|
|
3548
|
+
offsetX: (_d = overlay.offsetXPixels) !== null && _d !== void 0 ? _d : 0,
|
|
3549
|
+
offsetY: (_e = overlay.offsetYPixels) !== null && _e !== void 0 ? _e : 0,
|
|
3550
|
+
width: (_f = overlay.widthPixels) !== null && _f !== void 0 ? _f : 300,
|
|
3551
|
+
height: (_g = overlay.heightPixels) !== null && _g !== void 0 ? _g : 200,
|
|
3552
|
+
};
|
|
3553
|
+
var list = (_h = result.get(chart.position.sheetId)) !== null && _h !== void 0 ? _h : [];
|
|
3554
|
+
list.push(placement);
|
|
3555
|
+
result.set(chart.position.sheetId, list);
|
|
3556
|
+
});
|
|
3381
3557
|
return result;
|
|
3382
3558
|
};
|
|
3383
3559
|
var groupSlicersBySheet = function (slicers) {
|
|
3384
|
-
var
|
|
3560
|
+
var e_41, _a;
|
|
3385
3561
|
var _b, _d, _e, _f, _g, _h;
|
|
3386
3562
|
var result = new Map();
|
|
3387
3563
|
try {
|
|
@@ -3404,17 +3580,17 @@ var groupSlicersBySheet = function (slicers) {
|
|
|
3404
3580
|
result.set(slicer.position.sheetId, list);
|
|
3405
3581
|
}
|
|
3406
3582
|
}
|
|
3407
|
-
catch (
|
|
3583
|
+
catch (e_41_1) { e_41 = { error: e_41_1 }; }
|
|
3408
3584
|
finally {
|
|
3409
3585
|
try {
|
|
3410
3586
|
if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
|
|
3411
3587
|
}
|
|
3412
|
-
finally { if (
|
|
3588
|
+
finally { if (e_41) throw e_41.error; }
|
|
3413
3589
|
}
|
|
3414
3590
|
return result;
|
|
3415
3591
|
};
|
|
3416
3592
|
var buildConditionalFormattingXml = function (_a) {
|
|
3417
|
-
var
|
|
3593
|
+
var e_42, _b;
|
|
3418
3594
|
var _d, _e, _f;
|
|
3419
3595
|
var conditionalFormats = _a.conditionalFormats, sheetId = _a.sheetId, styleBuilder = _a.styleBuilder;
|
|
3420
3596
|
if (!(conditionalFormats === null || conditionalFormats === void 0 ? void 0 : conditionalFormats.length)) {
|
|
@@ -3478,12 +3654,12 @@ var buildConditionalFormattingXml = function (_a) {
|
|
|
3478
3654
|
parts.push("<conditionalFormatting sqref=\"".concat(sqrefParts.join(" "), "\">").concat(ruleXmlEntries.join(""), "</conditionalFormatting>"));
|
|
3479
3655
|
}
|
|
3480
3656
|
}
|
|
3481
|
-
catch (
|
|
3657
|
+
catch (e_42_1) { e_42 = { error: e_42_1 }; }
|
|
3482
3658
|
finally {
|
|
3483
3659
|
try {
|
|
3484
3660
|
if (orderedRules_1_1 && !orderedRules_1_1.done && (_b = orderedRules_1.return)) _b.call(orderedRules_1);
|
|
3485
3661
|
}
|
|
3486
|
-
finally { if (
|
|
3662
|
+
finally { if (e_42) throw e_42.error; }
|
|
3487
3663
|
}
|
|
3488
3664
|
return parts.join("");
|
|
3489
3665
|
};
|
|
@@ -3979,9 +4155,9 @@ var buildConditionalFormattingRuleXml = function (_a) {
|
|
|
3979
4155
|
return rules.length ? rules : undefined;
|
|
3980
4156
|
};
|
|
3981
4157
|
var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
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,
|
|
3983
|
-
var
|
|
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;
|
|
4158
|
+
var anchors, relationships, media, imageIndex, chartIndex, chartExIndex, pictureId, frameId, chartEntries, chartExEntries, orderedAnchors, orderOf, charts_1, charts_1_1, placement, chartExXml, relId_1, chartXml, relId, slicers_1, slicers_1_1, placement, textBoxes_1, textBoxes_1_1, placement, shapes_1, shapes_1_1, placement, placements_1, placements_1_1, placement, dataUrl, buffer, mediaPath, relId, e_43_1, orderedAnchors_1, orderedAnchors_1_1, entry, drawingXml;
|
|
4159
|
+
var e_44, _d, e_45, _e, e_46, _f, e_47, _g, e_43, _h, e_48, _j;
|
|
4160
|
+
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, resolvePivotSourceName = _b.resolvePivotSourceName;
|
|
3985
4161
|
return __generator(this, function (_m) {
|
|
3986
4162
|
switch (_m.label) {
|
|
3987
4163
|
case 0:
|
|
@@ -4001,6 +4177,10 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4001
4177
|
frameId = 1;
|
|
4002
4178
|
chartEntries = [];
|
|
4003
4179
|
chartExEntries = [];
|
|
4180
|
+
orderedAnchors = [];
|
|
4181
|
+
orderOf = function (order) {
|
|
4182
|
+
return order !== null && order !== void 0 ? order : Number.MAX_SAFE_INTEGER;
|
|
4183
|
+
};
|
|
4004
4184
|
try {
|
|
4005
4185
|
for (charts_1 = __values(charts), charts_1_1 = charts_1.next(); !charts_1_1.done; charts_1_1 = charts_1.next()) {
|
|
4006
4186
|
placement = charts_1_1.value;
|
|
@@ -4009,7 +4189,16 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4009
4189
|
if (!chartExXml)
|
|
4010
4190
|
continue;
|
|
4011
4191
|
relId_1 = relationships.add(CHART_EX_REL_TYPE, "../charts/chartEx".concat(chartExIndex, ".xml"));
|
|
4012
|
-
|
|
4192
|
+
orderedAnchors.push({
|
|
4193
|
+
order: placement.order,
|
|
4194
|
+
xml: createChartAnchor({
|
|
4195
|
+
sheet: sheet,
|
|
4196
|
+
placement: placement,
|
|
4197
|
+
relId: relId_1,
|
|
4198
|
+
frameId: frameId,
|
|
4199
|
+
chartEx: true,
|
|
4200
|
+
}),
|
|
4201
|
+
});
|
|
4013
4202
|
chartExEntries.push({
|
|
4014
4203
|
path: "xl/charts/chartEx".concat(chartExIndex, ".xml"),
|
|
4015
4204
|
xml: chartExXml,
|
|
@@ -4018,16 +4207,19 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4018
4207
|
frameId += 1;
|
|
4019
4208
|
continue;
|
|
4020
4209
|
}
|
|
4021
|
-
chartXml = buildChartXml(placement.chart, sheetNameById);
|
|
4210
|
+
chartXml = buildChartXml(placement.chart, sheetNameById, resolvePivotSourceName);
|
|
4022
4211
|
if (!chartXml)
|
|
4023
4212
|
continue;
|
|
4024
4213
|
relId = relationships.add(CHART_REL_TYPE, "../charts/chart".concat(chartIndex, ".xml"));
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4214
|
+
orderedAnchors.push({
|
|
4215
|
+
order: placement.order,
|
|
4216
|
+
xml: createChartAnchor({
|
|
4217
|
+
sheet: sheet,
|
|
4218
|
+
placement: placement,
|
|
4219
|
+
relId: relId,
|
|
4220
|
+
frameId: frameId,
|
|
4221
|
+
}),
|
|
4222
|
+
});
|
|
4031
4223
|
chartEntries.push({
|
|
4032
4224
|
path: "xl/charts/chart".concat(chartIndex, ".xml"),
|
|
4033
4225
|
xml: chartXml,
|
|
@@ -4036,12 +4228,12 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4036
4228
|
frameId += 1;
|
|
4037
4229
|
}
|
|
4038
4230
|
}
|
|
4039
|
-
catch (
|
|
4231
|
+
catch (e_44_1) { e_44 = { error: e_44_1 }; }
|
|
4040
4232
|
finally {
|
|
4041
4233
|
try {
|
|
4042
4234
|
if (charts_1_1 && !charts_1_1.done && (_d = charts_1.return)) _d.call(charts_1);
|
|
4043
4235
|
}
|
|
4044
|
-
finally { if (
|
|
4236
|
+
finally { if (e_44) throw e_44.error; }
|
|
4045
4237
|
}
|
|
4046
4238
|
try {
|
|
4047
4239
|
for (slicers_1 = __values(slicers), slicers_1_1 = slicers_1.next(); !slicers_1_1.done; slicers_1_1 = slicers_1.next()) {
|
|
@@ -4054,21 +4246,17 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4054
4246
|
frameId += 1;
|
|
4055
4247
|
}
|
|
4056
4248
|
}
|
|
4057
|
-
catch (
|
|
4249
|
+
catch (e_45_1) { e_45 = { error: e_45_1 }; }
|
|
4058
4250
|
finally {
|
|
4059
4251
|
try {
|
|
4060
4252
|
if (slicers_1_1 && !slicers_1_1.done && (_e = slicers_1.return)) _e.call(slicers_1);
|
|
4061
4253
|
}
|
|
4062
|
-
finally { if (
|
|
4254
|
+
finally { if (e_45) throw e_45.error; }
|
|
4063
4255
|
}
|
|
4064
|
-
embedAnchors = [];
|
|
4065
|
-
orderOf = function (order) {
|
|
4066
|
-
return order !== null && order !== void 0 ? order : Number.MAX_SAFE_INTEGER;
|
|
4067
|
-
};
|
|
4068
4256
|
try {
|
|
4069
4257
|
for (textBoxes_1 = __values(textBoxes), textBoxes_1_1 = textBoxes_1.next(); !textBoxes_1_1.done; textBoxes_1_1 = textBoxes_1.next()) {
|
|
4070
4258
|
placement = textBoxes_1_1.value;
|
|
4071
|
-
|
|
4259
|
+
orderedAnchors.push({
|
|
4072
4260
|
order: orderOf(placement.order),
|
|
4073
4261
|
xml: createTextBoxAnchor({
|
|
4074
4262
|
sheet: sheet,
|
|
@@ -4079,17 +4267,17 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4079
4267
|
frameId += 1;
|
|
4080
4268
|
}
|
|
4081
4269
|
}
|
|
4082
|
-
catch (
|
|
4270
|
+
catch (e_46_1) { e_46 = { error: e_46_1 }; }
|
|
4083
4271
|
finally {
|
|
4084
4272
|
try {
|
|
4085
4273
|
if (textBoxes_1_1 && !textBoxes_1_1.done && (_f = textBoxes_1.return)) _f.call(textBoxes_1);
|
|
4086
4274
|
}
|
|
4087
|
-
finally { if (
|
|
4275
|
+
finally { if (e_46) throw e_46.error; }
|
|
4088
4276
|
}
|
|
4089
4277
|
try {
|
|
4090
4278
|
for (shapes_1 = __values(shapes), shapes_1_1 = shapes_1.next(); !shapes_1_1.done; shapes_1_1 = shapes_1.next()) {
|
|
4091
4279
|
placement = shapes_1_1.value;
|
|
4092
|
-
|
|
4280
|
+
orderedAnchors.push({
|
|
4093
4281
|
order: orderOf(placement.order),
|
|
4094
4282
|
xml: createShapeAnchor({
|
|
4095
4283
|
sheet: sheet,
|
|
@@ -4100,12 +4288,12 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4100
4288
|
frameId += 1;
|
|
4101
4289
|
}
|
|
4102
4290
|
}
|
|
4103
|
-
catch (
|
|
4291
|
+
catch (e_47_1) { e_47 = { error: e_47_1 }; }
|
|
4104
4292
|
finally {
|
|
4105
4293
|
try {
|
|
4106
4294
|
if (shapes_1_1 && !shapes_1_1.done && (_g = shapes_1.return)) _g.call(shapes_1);
|
|
4107
4295
|
}
|
|
4108
|
-
finally { if (
|
|
4296
|
+
finally { if (e_47) throw e_47.error; }
|
|
4109
4297
|
}
|
|
4110
4298
|
_m.label = 1;
|
|
4111
4299
|
case 1:
|
|
@@ -4130,7 +4318,7 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4130
4318
|
extension: buffer.extension,
|
|
4131
4319
|
});
|
|
4132
4320
|
relId = relationships.add(IMAGE_REL_TYPE, "../media/image".concat(imageIndex, ".").concat(buffer.extension));
|
|
4133
|
-
|
|
4321
|
+
orderedAnchors.push({
|
|
4134
4322
|
order: orderOf(placement.order),
|
|
4135
4323
|
xml: createTwoCellAnchor({
|
|
4136
4324
|
sheet: sheet,
|
|
@@ -4147,29 +4335,29 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4147
4335
|
return [3 /*break*/, 2];
|
|
4148
4336
|
case 5: return [3 /*break*/, 8];
|
|
4149
4337
|
case 6:
|
|
4150
|
-
|
|
4151
|
-
|
|
4338
|
+
e_43_1 = _m.sent();
|
|
4339
|
+
e_43 = { error: e_43_1 };
|
|
4152
4340
|
return [3 /*break*/, 8];
|
|
4153
4341
|
case 7:
|
|
4154
4342
|
try {
|
|
4155
4343
|
if (placements_1_1 && !placements_1_1.done && (_h = placements_1.return)) _h.call(placements_1);
|
|
4156
4344
|
}
|
|
4157
|
-
finally { if (
|
|
4345
|
+
finally { if (e_43) throw e_43.error; }
|
|
4158
4346
|
return [7 /*endfinally*/];
|
|
4159
4347
|
case 8:
|
|
4160
|
-
|
|
4348
|
+
orderedAnchors.sort(function (a, b) { return a.order - b.order; });
|
|
4161
4349
|
try {
|
|
4162
|
-
for (
|
|
4163
|
-
entry =
|
|
4350
|
+
for (orderedAnchors_1 = __values(orderedAnchors), orderedAnchors_1_1 = orderedAnchors_1.next(); !orderedAnchors_1_1.done; orderedAnchors_1_1 = orderedAnchors_1.next()) {
|
|
4351
|
+
entry = orderedAnchors_1_1.value;
|
|
4164
4352
|
anchors.push(entry.xml);
|
|
4165
4353
|
}
|
|
4166
4354
|
}
|
|
4167
|
-
catch (
|
|
4355
|
+
catch (e_48_1) { e_48 = { error: e_48_1 }; }
|
|
4168
4356
|
finally {
|
|
4169
4357
|
try {
|
|
4170
|
-
if (
|
|
4358
|
+
if (orderedAnchors_1_1 && !orderedAnchors_1_1.done && (_j = orderedAnchors_1.return)) _j.call(orderedAnchors_1);
|
|
4171
4359
|
}
|
|
4172
|
-
finally { if (
|
|
4360
|
+
finally { if (e_48) throw e_48.error; }
|
|
4173
4361
|
}
|
|
4174
4362
|
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>");
|
|
4175
4363
|
return [2 /*return*/, {
|
|
@@ -4196,25 +4384,21 @@ var createTwoCellAnchor = function (_a) {
|
|
|
4196
4384
|
var defaultHeight = placement.kind === "cell" ? getRowHeightPx(sheet, fromRow) : 120;
|
|
4197
4385
|
var widthPx = Math.max(5, (_e = placement.width) !== null && _e !== void 0 ? _e : defaultWidth);
|
|
4198
4386
|
var heightPx = Math.max(5, (_f = placement.height) !== null && _f !== void 0 ? _f : defaultHeight);
|
|
4199
|
-
var toColumn = resolveAnchorEndpoint({
|
|
4200
|
-
startIndex: fromColumn,
|
|
4201
|
-
startOffset: offsetX,
|
|
4202
|
-
span: widthPx,
|
|
4203
|
-
getSize: function (index) { return getColumnWidthPx(sheet, index, true); },
|
|
4204
|
-
});
|
|
4205
|
-
var toRow = resolveAnchorEndpoint({
|
|
4206
|
-
startIndex: fromRow,
|
|
4207
|
-
startOffset: offsetY,
|
|
4208
|
-
span: heightPx,
|
|
4209
|
-
getSize: function (index) { return getRowHeightPx(sheet, index, true); },
|
|
4210
|
-
});
|
|
4211
|
-
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>");
|
|
4212
|
-
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>");
|
|
4213
4387
|
var _g = buildPictureAdjustmentsXml(placement.adjustments), blipChildren = _g.blipChildren, srcRectXml = _g.srcRectXml;
|
|
4214
4388
|
var blipXml = blipChildren
|
|
4215
4389
|
? "<a:blip r:embed=\"".concat(relId, "\">").concat(blipChildren, "</a:blip>")
|
|
4216
4390
|
: "<a:blip r:embed=\"".concat(relId, "\"/>");
|
|
4217
|
-
return
|
|
4391
|
+
return buildDrawingAnchorXml({
|
|
4392
|
+
sheet: sheet,
|
|
4393
|
+
overlay: placement.overlay,
|
|
4394
|
+
fromRow: fromRow,
|
|
4395
|
+
fromColumn: fromColumn,
|
|
4396
|
+
offsetX: offsetX,
|
|
4397
|
+
offsetY: offsetY,
|
|
4398
|
+
widthPx: widthPx,
|
|
4399
|
+
heightPx: heightPx,
|
|
4400
|
+
body: "<xdr:pic><xdr:nvPicPr><xdr:cNvPr id=\"".concat(pictureId, "\" name=\"Picture ").concat(pictureId, "\"/><xdr:cNvPicPr/></xdr:nvPicPr><xdr:blipFill>").concat(blipXml).concat(srcRectXml, "<a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr><a: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), "\"/></a:xfrm><a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic>"),
|
|
4401
|
+
});
|
|
4218
4402
|
};
|
|
4219
4403
|
/** Fraction (0…1) → DrawingML per-mille percent (100000 = 100%). */
|
|
4220
4404
|
var fractionToPct = function (value) {
|
|
@@ -4261,40 +4445,40 @@ var buildPictureAdjustmentsXml = function (adjustments) {
|
|
|
4261
4445
|
return { blipChildren: blipChildren, srcRectXml: srcRectXml };
|
|
4262
4446
|
};
|
|
4263
4447
|
var createChartAnchor = function (_a) {
|
|
4264
|
-
var _b, _d, _e, _f;
|
|
4265
|
-
var placement = _a.placement, relId = _a.relId, frameId = _a.frameId, sheet = _a.sheet,
|
|
4448
|
+
var _b, _d, _e, _f, _g;
|
|
4449
|
+
var placement = _a.placement, relId = _a.relId, frameId = _a.frameId, sheet = _a.sheet, _h = _a.chartEx, chartEx = _h === void 0 ? false : _h;
|
|
4266
4450
|
var fromRow = Math.max(0, placement.rowIndex - 1);
|
|
4267
4451
|
var fromColumn = Math.max(0, placement.columnIndex - 1);
|
|
4268
4452
|
var offsetX = Math.max(0, (_b = placement.offsetX) !== null && _b !== void 0 ? _b : 0);
|
|
4269
4453
|
var offsetY = Math.max(0, (_d = placement.offsetY) !== null && _d !== void 0 ? _d : 0);
|
|
4270
4454
|
var widthPx = Math.max(5, (_e = placement.width) !== null && _e !== void 0 ? _e : 300);
|
|
4271
4455
|
var heightPx = Math.max(5, (_f = placement.height) !== null && _f !== void 0 ? _f : 200);
|
|
4272
|
-
var
|
|
4273
|
-
|
|
4274
|
-
startOffset: offsetX,
|
|
4275
|
-
span: widthPx,
|
|
4276
|
-
getSize: function (index) { return getColumnWidthPx(sheet, index, true); },
|
|
4277
|
-
});
|
|
4278
|
-
var toRow = resolveAnchorEndpoint({
|
|
4279
|
-
startIndex: fromRow,
|
|
4280
|
-
startOffset: offsetY,
|
|
4281
|
-
span: heightPx,
|
|
4282
|
-
getSize: function (index) { return getRowHeightPx(sheet, index, true); },
|
|
4283
|
-
});
|
|
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>");
|
|
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({
|
|
4456
|
+
var body = chartEx
|
|
4457
|
+
? buildChartExGraphicFrameXml({
|
|
4288
4458
|
relId: relId,
|
|
4289
4459
|
frameId: frameId,
|
|
4290
4460
|
widthEmu: Math.round(widthPx * EMUS_PER_PIXEL),
|
|
4291
4461
|
heightEmu: Math.round(heightPx * EMUS_PER_PIXEL),
|
|
4292
|
-
})
|
|
4293
|
-
|
|
4294
|
-
|
|
4462
|
+
})
|
|
4463
|
+
: "<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>");
|
|
4464
|
+
var overlay = (_g = placement.chart.position) === null || _g === void 0 ? void 0 : _g.overlayPosition;
|
|
4465
|
+
return buildDrawingAnchorXml({
|
|
4466
|
+
sheet: sheet,
|
|
4467
|
+
// A chartsheet has no cells to anchor to: Excel only reads an
|
|
4468
|
+
// `absoluteAnchor` there, whatever placement the chart carries.
|
|
4469
|
+
overlay: sheet.type === "chartsheet" && overlay
|
|
4470
|
+
? __assign(__assign({}, overlay), { placement: "absolute" }) : overlay,
|
|
4471
|
+
fromRow: fromRow,
|
|
4472
|
+
fromColumn: fromColumn,
|
|
4473
|
+
offsetX: offsetX,
|
|
4474
|
+
offsetY: offsetY,
|
|
4475
|
+
widthPx: widthPx,
|
|
4476
|
+
heightPx: heightPx,
|
|
4477
|
+
body: body,
|
|
4478
|
+
});
|
|
4295
4479
|
};
|
|
4296
4480
|
var createSlicerAnchor = function (_a) {
|
|
4297
|
-
var _b, _d, _e, _f;
|
|
4481
|
+
var _b, _d, _e, _f, _g, _h, _j;
|
|
4298
4482
|
var placement = _a.placement, frameId = _a.frameId, sheet = _a.sheet;
|
|
4299
4483
|
var fromRow = Math.max(0, placement.rowIndex - 1);
|
|
4300
4484
|
var fromColumn = Math.max(0, placement.columnIndex - 1);
|
|
@@ -4302,24 +4486,45 @@ var createSlicerAnchor = function (_a) {
|
|
|
4302
4486
|
var offsetY = Math.max(0, (_d = placement.offsetY) !== null && _d !== void 0 ? _d : 0);
|
|
4303
4487
|
var widthPx = Math.max(50, (_e = placement.width) !== null && _e !== void 0 ? _e : 200);
|
|
4304
4488
|
var heightPx = Math.max(50, (_f = placement.height) !== null && _f !== void 0 ? _f : 200);
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
var
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4489
|
+
// Excel keeps a slicer in a `twoCellAnchor` whatever its placement and
|
|
4490
|
+
// spells the other two modes as `editAs` (#668 C-46); a "Move and size"
|
|
4491
|
+
// slicer keeps its persisted second anchor.
|
|
4492
|
+
var overlay = placement.overlay;
|
|
4493
|
+
var mode = (_g = overlay === null || overlay === void 0 ? void 0 : overlay.placement) !== null && _g !== void 0 ? _g : "moveAndSize";
|
|
4494
|
+
var persistedTo = mode === "moveAndSize" ? overlay === null || overlay === void 0 ? void 0 : overlay.toCell : undefined;
|
|
4495
|
+
var editAs = mode === "moveOnly"
|
|
4496
|
+
? ' editAs="oneCell"'
|
|
4497
|
+
: mode === "absolute"
|
|
4498
|
+
? ' editAs="absolute"'
|
|
4499
|
+
: "";
|
|
4500
|
+
var toColumn = persistedTo
|
|
4501
|
+
? {
|
|
4502
|
+
index: Math.max(0, persistedTo.columnIndex - 1),
|
|
4503
|
+
offset: Math.max(0, (_h = overlay === null || overlay === void 0 ? void 0 : overlay.toOffsetXPixels) !== null && _h !== void 0 ? _h : 0),
|
|
4504
|
+
}
|
|
4505
|
+
: resolveAnchorEndpoint({
|
|
4506
|
+
startIndex: fromColumn,
|
|
4507
|
+
startOffset: offsetX,
|
|
4508
|
+
span: widthPx,
|
|
4509
|
+
getSize: function (index) { return getColumnWidthPx(sheet, index, true); },
|
|
4510
|
+
});
|
|
4511
|
+
var toRow = persistedTo
|
|
4512
|
+
? {
|
|
4513
|
+
index: Math.max(0, persistedTo.rowIndex - 1),
|
|
4514
|
+
offset: Math.max(0, (_j = overlay === null || overlay === void 0 ? void 0 : overlay.toOffsetYPixels) !== null && _j !== void 0 ? _j : 0),
|
|
4515
|
+
}
|
|
4516
|
+
: resolveAnchorEndpoint({
|
|
4517
|
+
startIndex: fromRow,
|
|
4518
|
+
startOffset: offsetY,
|
|
4519
|
+
span: heightPx,
|
|
4520
|
+
getSize: function (index) { return getRowHeightPx(sheet, index, true); },
|
|
4521
|
+
});
|
|
4317
4522
|
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>");
|
|
4318
4523
|
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>");
|
|
4319
|
-
return "<xdr:twoCellAnchor
|
|
4524
|
+
return "<xdr:twoCellAnchor".concat(editAs, ">").concat(fromXml).concat(toXml, "<mc:AlternateContent xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"><mc:Choice xmlns:sle15=\"http://schemas.microsoft.com/office/drawing/2012/slicer\" Requires=\"sle15\"><xdr:graphicFrame macro=\"\"><xdr:nvGraphicFramePr><xdr:cNvPr id=\"").concat(frameId, "\" name=\"").concat(escapeXmlAttr(placement.title), "\"/><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.microsoft.com/office/drawing/2010/slicer\"><sle:slicer xmlns:sle=\"http://schemas.microsoft.com/office/drawing/2010/slicer\" name=\"").concat(escapeXmlAttr(placement.title), "\"/></a:graphicData></a:graphic></xdr:graphicFrame></mc:Choice></mc:AlternateContent><xdr:clientData/></xdr:twoCellAnchor>");
|
|
4320
4525
|
};
|
|
4321
4526
|
var createTextBoxAnchor = function (_a) {
|
|
4322
|
-
var _b, _d, _e, _f;
|
|
4527
|
+
var _b, _d, _e, _f, _g;
|
|
4323
4528
|
var placement = _a.placement, frameId = _a.frameId, sheet = _a.sheet;
|
|
4324
4529
|
var fromRow = Math.max(0, placement.rowIndex - 1);
|
|
4325
4530
|
var fromColumn = Math.max(0, placement.columnIndex - 1);
|
|
@@ -4327,24 +4532,20 @@ var createTextBoxAnchor = function (_a) {
|
|
|
4327
4532
|
var offsetY = Math.max(0, (_d = placement.offsetY) !== null && _d !== void 0 ? _d : 0);
|
|
4328
4533
|
var widthPx = Math.max(50, (_e = placement.width) !== null && _e !== void 0 ? _e : 200);
|
|
4329
4534
|
var heightPx = Math.max(50, (_f = placement.height) !== null && _f !== void 0 ? _f : 60);
|
|
4330
|
-
var toColumn = resolveAnchorEndpoint({
|
|
4331
|
-
startIndex: fromColumn,
|
|
4332
|
-
startOffset: offsetX,
|
|
4333
|
-
span: widthPx,
|
|
4334
|
-
getSize: function (index) { return getColumnWidthPx(sheet, index, true); },
|
|
4335
|
-
});
|
|
4336
|
-
var toRow = resolveAnchorEndpoint({
|
|
4337
|
-
startIndex: fromRow,
|
|
4338
|
-
startOffset: offsetY,
|
|
4339
|
-
span: heightPx,
|
|
4340
|
-
getSize: function (index) { return getRowHeightPx(sheet, index, true); },
|
|
4341
|
-
});
|
|
4342
|
-
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>");
|
|
4343
|
-
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>");
|
|
4344
4535
|
var spec = placement.textBox.spec;
|
|
4345
4536
|
var textBodyXml = buildTextBodyXml(spec);
|
|
4346
4537
|
var shapePropertiesXml = buildShapePropertiesXml(spec, widthPx, heightPx);
|
|
4347
|
-
return
|
|
4538
|
+
return buildDrawingAnchorXml({
|
|
4539
|
+
sheet: sheet,
|
|
4540
|
+
overlay: (_g = placement.textBox.position) === null || _g === void 0 ? void 0 : _g.overlayPosition,
|
|
4541
|
+
fromRow: fromRow,
|
|
4542
|
+
fromColumn: fromColumn,
|
|
4543
|
+
offsetX: offsetX,
|
|
4544
|
+
offsetY: offsetY,
|
|
4545
|
+
widthPx: widthPx,
|
|
4546
|
+
heightPx: heightPx,
|
|
4547
|
+
body: "<xdr:sp><xdr:nvSpPr><xdr:cNvPr id=\"".concat(frameId, "\" name=\"TextBox ").concat(frameId, "\"/><xdr:cNvSpPr txBox=\"1\"/></xdr:nvSpPr>").concat(shapePropertiesXml).concat(textBodyXml, "</xdr:sp>"),
|
|
4548
|
+
});
|
|
4348
4549
|
};
|
|
4349
4550
|
/** ColorIndex slots → canonical DrawingML scheme names (inverse of the importer's map). */
|
|
4350
4551
|
var THEME_INDEX_TO_SCHEME = [
|
|
@@ -4462,7 +4663,7 @@ var buildShapeStyleRefXml = function (tag, ref) {
|
|
|
4462
4663
|
};
|
|
4463
4664
|
/** Export an `EmbedShapeSpec` embed as an `<xdr:sp>` two-cell anchor. */
|
|
4464
4665
|
var createShapeAnchor = function (_a) {
|
|
4465
|
-
var _b, _d, _e, _f, _g, _h, _j, _k;
|
|
4666
|
+
var _b, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
4466
4667
|
var placement = _a.placement, frameId = _a.frameId, sheet = _a.sheet;
|
|
4467
4668
|
var spec = placement.shape.spec;
|
|
4468
4669
|
var fromRow = Math.max(0, placement.rowIndex - 1);
|
|
@@ -4471,20 +4672,6 @@ var createShapeAnchor = function (_a) {
|
|
|
4471
4672
|
var offsetY = Math.max(0, (_d = placement.offsetY) !== null && _d !== void 0 ? _d : 0);
|
|
4472
4673
|
var widthPx = Math.max(10, (_e = placement.width) !== null && _e !== void 0 ? _e : 120);
|
|
4473
4674
|
var heightPx = Math.max(10, (_f = placement.height) !== null && _f !== void 0 ? _f : 60);
|
|
4474
|
-
var toColumn = resolveAnchorEndpoint({
|
|
4475
|
-
startIndex: fromColumn,
|
|
4476
|
-
startOffset: offsetX,
|
|
4477
|
-
span: widthPx,
|
|
4478
|
-
getSize: function (index) { return getColumnWidthPx(sheet, index, true); },
|
|
4479
|
-
});
|
|
4480
|
-
var toRow = resolveAnchorEndpoint({
|
|
4481
|
-
startIndex: fromRow,
|
|
4482
|
-
startOffset: offsetY,
|
|
4483
|
-
span: heightPx,
|
|
4484
|
-
getSize: function (index) { return getRowHeightPx(sheet, index, true); },
|
|
4485
|
-
});
|
|
4486
|
-
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>");
|
|
4487
|
-
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>");
|
|
4488
4675
|
var xfrmAttrs = [
|
|
4489
4676
|
placement.shape.rotation
|
|
4490
4677
|
? " rot=\"".concat(Math.round(placement.shape.rotation * 60000), "\"")
|
|
@@ -4514,7 +4701,17 @@ var createShapeAnchor = function (_a) {
|
|
|
4514
4701
|
? buildTextBodyXml(spec.textBody)
|
|
4515
4702
|
: "<xdr:txBody><a:bodyPr vertOverflow=\"clip\" horzOverflow=\"clip\" rtlCol=\"0\" anchor=\"t\"/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></xdr:txBody>";
|
|
4516
4703
|
var name = escapeXmlAttr((_k = spec.name) !== null && _k !== void 0 ? _k : "Shape ".concat(frameId));
|
|
4517
|
-
return
|
|
4704
|
+
return buildDrawingAnchorXml({
|
|
4705
|
+
sheet: sheet,
|
|
4706
|
+
overlay: (_l = placement.shape.position) === null || _l === void 0 ? void 0 : _l.overlayPosition,
|
|
4707
|
+
fromRow: fromRow,
|
|
4708
|
+
fromColumn: fromColumn,
|
|
4709
|
+
offsetX: offsetX,
|
|
4710
|
+
offsetY: offsetY,
|
|
4711
|
+
widthPx: widthPx,
|
|
4712
|
+
heightPx: heightPx,
|
|
4713
|
+
body: "<xdr:sp><xdr:nvSpPr><xdr:cNvPr id=\"".concat(frameId, "\" name=\"").concat(name, "\"/><xdr:cNvSpPr/></xdr:nvSpPr>").concat(spPr).concat(styleXml).concat(textBodyXml, "</xdr:sp>"),
|
|
4714
|
+
});
|
|
4518
4715
|
};
|
|
4519
4716
|
var buildTextWithTabs = function (text, rPrXml) {
|
|
4520
4717
|
var parts = text.split("\t");
|
|
@@ -4531,7 +4728,7 @@ var buildTextWithTabs = function (text, rPrXml) {
|
|
|
4531
4728
|
.join("");
|
|
4532
4729
|
};
|
|
4533
4730
|
var buildTextBodyXml = function (spec) {
|
|
4534
|
-
var
|
|
4731
|
+
var e_49, _a;
|
|
4535
4732
|
var richText = spec.richText || [];
|
|
4536
4733
|
var plainText = spec.text || "";
|
|
4537
4734
|
// Build vertical alignment and wrap attributes
|
|
@@ -4572,12 +4769,12 @@ var buildTextBodyXml = function (spec) {
|
|
|
4572
4769
|
}
|
|
4573
4770
|
}
|
|
4574
4771
|
}
|
|
4575
|
-
catch (
|
|
4772
|
+
catch (e_49_1) { e_49 = { error: e_49_1 }; }
|
|
4576
4773
|
finally {
|
|
4577
4774
|
try {
|
|
4578
4775
|
if (richText_1_1 && !richText_1_1.done && (_a = richText_1.return)) _a.call(richText_1);
|
|
4579
4776
|
}
|
|
4580
|
-
finally { if (
|
|
4777
|
+
finally { if (e_49) throw e_49.error; }
|
|
4581
4778
|
}
|
|
4582
4779
|
paragraphsXml = paragraphs
|
|
4583
4780
|
.filter(function (runs) { return runs.length > 0; })
|
|
@@ -4775,6 +4972,62 @@ var buildShapePropertiesXml = function (spec, widthPx, heightPx) {
|
|
|
4775
4972
|
}
|
|
4776
4973
|
return "<xdr:spPr><a: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), "\"/></a:xfrm><a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>").concat(fillXml).concat(outlineXml, "</xdr:spPr>");
|
|
4777
4974
|
};
|
|
4975
|
+
/**
|
|
4976
|
+
* Wrap a drawing object's body in the anchor its placement mode calls for
|
|
4977
|
+
* (#668 C-06). "Move and size with cells" (Excel's default) is a
|
|
4978
|
+
* `twoCellAnchor` whose `to` is the object's persisted second anchor — or,
|
|
4979
|
+
* for an object that has none yet, the cell its pixel extent reaches over
|
|
4980
|
+
* this sheet's row / column sizes. "Move but don't size" is a
|
|
4981
|
+
* `oneCellAnchor` (`from` + `ext`); "Don't move or size" is an
|
|
4982
|
+
* `absoluteAnchor` (`pos` + `ext`). The importers read all three back into
|
|
4983
|
+
* the same placement.
|
|
4984
|
+
*/
|
|
4985
|
+
var buildDrawingAnchorXml = function (_a) {
|
|
4986
|
+
var _b, _d, _e;
|
|
4987
|
+
var sheet = _a.sheet, overlay = _a.overlay, fromRow = _a.fromRow, fromColumn = _a.fromColumn, offsetX = _a.offsetX, offsetY = _a.offsetY, widthPx = _a.widthPx, heightPx = _a.heightPx, body = _a.body;
|
|
4988
|
+
var emu = function (px) { return Math.round(px * EMUS_PER_PIXEL); };
|
|
4989
|
+
var fromXml = "<xdr:from><xdr:col>".concat(fromColumn, "</xdr:col><xdr:colOff>").concat(emu(offsetX), "</xdr:colOff><xdr:row>").concat(fromRow, "</xdr:row><xdr:rowOff>").concat(emu(offsetY), "</xdr:rowOff></xdr:from>");
|
|
4990
|
+
var extXml = "<xdr:ext cx=\"".concat(emu(widthPx), "\" cy=\"").concat(emu(heightPx), "\"/>");
|
|
4991
|
+
var placement = (_b = overlay === null || overlay === void 0 ? void 0 : overlay.placement) !== null && _b !== void 0 ? _b : "moveAndSize";
|
|
4992
|
+
if (placement === "moveOnly") {
|
|
4993
|
+
return "<xdr:oneCellAnchor>".concat(fromXml).concat(extXml).concat(body, "<xdr:clientData/></xdr:oneCellAnchor>");
|
|
4994
|
+
}
|
|
4995
|
+
if (placement === "absolute") {
|
|
4996
|
+
var x = offsetX;
|
|
4997
|
+
for (var index = 0; index < fromColumn; index++) {
|
|
4998
|
+
x += getColumnWidthPx(sheet, index, true);
|
|
4999
|
+
}
|
|
5000
|
+
var y = offsetY;
|
|
5001
|
+
for (var index = 0; index < fromRow; index++) {
|
|
5002
|
+
y += getRowHeightPx(sheet, index, true);
|
|
5003
|
+
}
|
|
5004
|
+
return "<xdr:absoluteAnchor><xdr:pos x=\"".concat(emu(x), "\" y=\"").concat(emu(y), "\"/>").concat(extXml).concat(body, "<xdr:clientData/></xdr:absoluteAnchor>");
|
|
5005
|
+
}
|
|
5006
|
+
var toColumn = (overlay === null || overlay === void 0 ? void 0 : overlay.toCell)
|
|
5007
|
+
? {
|
|
5008
|
+
index: Math.max(0, overlay.toCell.columnIndex - 1),
|
|
5009
|
+
offset: Math.max(0, (_d = overlay.toOffsetXPixels) !== null && _d !== void 0 ? _d : 0),
|
|
5010
|
+
}
|
|
5011
|
+
: resolveAnchorEndpoint({
|
|
5012
|
+
startIndex: fromColumn,
|
|
5013
|
+
startOffset: offsetX,
|
|
5014
|
+
span: widthPx,
|
|
5015
|
+
getSize: function (index) { return getColumnWidthPx(sheet, index, true); },
|
|
5016
|
+
});
|
|
5017
|
+
var toRow = (overlay === null || overlay === void 0 ? void 0 : overlay.toCell)
|
|
5018
|
+
? {
|
|
5019
|
+
index: Math.max(0, overlay.toCell.rowIndex - 1),
|
|
5020
|
+
offset: Math.max(0, (_e = overlay.toOffsetYPixels) !== null && _e !== void 0 ? _e : 0),
|
|
5021
|
+
}
|
|
5022
|
+
: resolveAnchorEndpoint({
|
|
5023
|
+
startIndex: fromRow,
|
|
5024
|
+
startOffset: offsetY,
|
|
5025
|
+
span: heightPx,
|
|
5026
|
+
getSize: function (index) { return getRowHeightPx(sheet, index, true); },
|
|
5027
|
+
});
|
|
5028
|
+
var toXml = "<xdr:to><xdr:col>".concat(toColumn.index, "</xdr:col><xdr:colOff>").concat(emu(toColumn.offset), "</xdr:colOff><xdr:row>").concat(toRow.index, "</xdr:row><xdr:rowOff>").concat(emu(toRow.offset), "</xdr:rowOff></xdr:to>");
|
|
5029
|
+
return "<xdr:twoCellAnchor>".concat(fromXml).concat(toXml).concat(body, "<xdr:clientData/></xdr:twoCellAnchor>");
|
|
5030
|
+
};
|
|
4778
5031
|
var resolveAnchorEndpoint = function (_a) {
|
|
4779
5032
|
var startIndex = _a.startIndex, startOffset = _a.startOffset, span = _a.span, getSize = _a.getSize;
|
|
4780
5033
|
var index = startIndex;
|
|
@@ -5021,7 +5274,7 @@ var buildWorkbookXml = function (sheets, sheetRelIds, sheetNames, namedRanges, i
|
|
|
5021
5274
|
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>");
|
|
5022
5275
|
};
|
|
5023
5276
|
var buildDefinedNamesXml = function (namedRanges, sheetNameById, printScopes) {
|
|
5024
|
-
var
|
|
5277
|
+
var e_50, _a, e_51, _b;
|
|
5025
5278
|
var _d, _e, _f;
|
|
5026
5279
|
if (printScopes === void 0) { printScopes = []; }
|
|
5027
5280
|
var entries = [];
|
|
@@ -5051,12 +5304,12 @@ var buildDefinedNamesXml = function (namedRanges, sheetNameById, printScopes) {
|
|
|
5051
5304
|
], false));
|
|
5052
5305
|
}
|
|
5053
5306
|
}
|
|
5054
|
-
catch (
|
|
5307
|
+
catch (e_50_1) { e_50 = { error: e_50_1 }; }
|
|
5055
5308
|
finally {
|
|
5056
5309
|
try {
|
|
5057
5310
|
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
|
|
5058
5311
|
}
|
|
5059
|
-
finally { if (
|
|
5312
|
+
finally { if (e_50) throw e_50.error; }
|
|
5060
5313
|
}
|
|
5061
5314
|
printScopes.forEach(function (_a, index) {
|
|
5062
5315
|
var _b;
|
|
@@ -5104,12 +5357,12 @@ var buildDefinedNamesXml = function (namedRanges, sheetNameById, printScopes) {
|
|
|
5104
5357
|
entries.push("<definedName name=\"".concat(escapeXmlAttr(namedRange.name), "\"").concat(hiddenAttr, ">").concat(escapeXmlText(expression), "</definedName>"));
|
|
5105
5358
|
}
|
|
5106
5359
|
}
|
|
5107
|
-
catch (
|
|
5360
|
+
catch (e_51_1) { e_51 = { error: e_51_1 }; }
|
|
5108
5361
|
finally {
|
|
5109
5362
|
try {
|
|
5110
5363
|
if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
|
|
5111
5364
|
}
|
|
5112
|
-
finally { if (
|
|
5365
|
+
finally { if (e_51) throw e_51.error; }
|
|
5113
5366
|
}
|
|
5114
5367
|
if (!entries.length)
|
|
5115
5368
|
return "";
|
|
@@ -5142,7 +5395,9 @@ var buildWorkbookSlicerCachesXml = function (slicerCacheRelIds) {
|
|
|
5142
5395
|
.join("");
|
|
5143
5396
|
return "<extLst><ext uri=\"{46BE6895-7355-4a93-B00E-2C351335B9C9}\" xmlns:x15=\"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main\"><x15:slicerCaches xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\">".concat(cacheEntries, "</x15:slicerCaches></ext></extLst>");
|
|
5144
5397
|
};
|
|
5145
|
-
var buildWorkbookRelationships = function (
|
|
5398
|
+
var buildWorkbookRelationships = function (
|
|
5399
|
+
/** One entry per sheet in `<sheets>` order; `target` is relative to `xl/`. */
|
|
5400
|
+
sheetParts, slicerCacheCount, externalLinkCount, pivotCacheCount, hasPersons) {
|
|
5146
5401
|
if (slicerCacheCount === void 0) { slicerCacheCount = 0; }
|
|
5147
5402
|
if (externalLinkCount === void 0) { externalLinkCount = 0; }
|
|
5148
5403
|
if (pivotCacheCount === void 0) { pivotCacheCount = 0; }
|
|
@@ -5150,11 +5405,12 @@ var buildWorkbookRelationships = function (sheetCount, slicerCacheCount, externa
|
|
|
5150
5405
|
var relationships = [];
|
|
5151
5406
|
var sheetRelIds = [];
|
|
5152
5407
|
var slicerCacheRelIds = [];
|
|
5153
|
-
|
|
5408
|
+
var sheetCount = sheetParts.length;
|
|
5409
|
+
sheetParts.forEach(function (part, i) {
|
|
5154
5410
|
var relId = "rId".concat(i + 1);
|
|
5155
5411
|
sheetRelIds.push(relId);
|
|
5156
|
-
relationships.push("<Relationship Id=\"".concat(relId, "\" Type=\"").concat(REL_NS, "/worksheet\" Target=\"
|
|
5157
|
-
}
|
|
5412
|
+
relationships.push("<Relationship Id=\"".concat(relId, "\" Type=\"").concat(REL_NS, "/").concat(part.chartsheet ? "chartsheet" : "worksheet", "\" Target=\"").concat(part.target, "\"/>"));
|
|
5413
|
+
});
|
|
5158
5414
|
var stylesId = "rId".concat(sheetCount + 1);
|
|
5159
5415
|
var themeId = "rId".concat(sheetCount + 2);
|
|
5160
5416
|
var sharedStringsId = "rId".concat(sheetCount + 3);
|
|
@@ -5199,10 +5455,13 @@ var buildWorkbookRelationships = function (sheetCount, slicerCacheCount, externa
|
|
|
5199
5455
|
};
|
|
5200
5456
|
};
|
|
5201
5457
|
var buildContentTypesXml = function (_a) {
|
|
5202
|
-
var
|
|
5203
|
-
var sheetOverrides = Array.from({ length:
|
|
5458
|
+
var worksheetCount = _a.worksheetCount, _b = _a.chartsheetCount, chartsheetCount = _b === void 0 ? 0 : _b, tableCount = _a.tableCount, drawingSheets = _a.drawingSheets, mediaExtensions = _a.mediaExtensions, chartCount = _a.chartCount, _d = _a.chartExCount, chartExCount = _d === void 0 ? 0 : _d, _e = _a.slicerCount, slicerCount = _e === void 0 ? 0 : _e, _f = _a.slicerCacheCount, slicerCacheCount = _f === void 0 ? 0 : _f, _g = _a.pivotTableCount, pivotTableCount = _g === void 0 ? 0 : _g, _h = _a.pivotCacheCount, pivotCacheCount = _h === void 0 ? 0 : _h, _j = _a.commentsSheets, commentsSheets = _j === void 0 ? [] : _j, _k = _a.threadedCommentsSheets, threadedCommentsSheets = _k === void 0 ? [] : _k, _l = _a.hasPersons, hasPersons = _l === void 0 ? false : _l, _m = _a.externalLinkCount, externalLinkCount = _m === void 0 ? 0 : _m, _o = _a.hasVmlDrawings, hasVmlDrawings = _o === void 0 ? false : _o, _p = _a.ctrlPropCount, ctrlPropCount = _p === void 0 ? 0 : _p;
|
|
5459
|
+
var sheetOverrides = Array.from({ length: worksheetCount }, function (_, index) {
|
|
5204
5460
|
return "<Override PartName=\"/xl/worksheets/sheet".concat(index + 1, ".xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\"/>");
|
|
5205
5461
|
}).join("");
|
|
5462
|
+
var chartsheetOverrides = Array.from({ length: chartsheetCount }, function (_, index) {
|
|
5463
|
+
return "<Override PartName=\"/xl/chartsheets/sheet".concat(index + 1, ".xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml\"/>");
|
|
5464
|
+
}).join("");
|
|
5206
5465
|
var tableOverrides = Array.from({ length: tableCount }, function (_, index) {
|
|
5207
5466
|
return "<Override PartName=\"/xl/tables/table".concat(index + 1, ".xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml\"/>");
|
|
5208
5467
|
}).join("");
|
|
@@ -5257,15 +5516,32 @@ var buildContentTypesXml = function (_a) {
|
|
|
5257
5516
|
var ctrlPropOverrides = Array.from({ length: ctrlPropCount }, function (_, index) {
|
|
5258
5517
|
return "<Override PartName=\"/xl/ctrlProps/ctrlProp".concat(index + 1, ".xml\" ContentType=\"").concat(CTRL_PROP_CONTENT_TYPE, "\"/>");
|
|
5259
5518
|
}).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>");
|
|
5519
|
+
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(chartsheetOverrides).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>");
|
|
5261
5520
|
};
|
|
5262
5521
|
var buildRootRelationshipsXml = function () {
|
|
5263
5522
|
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>");
|
|
5264
5523
|
};
|
|
5265
|
-
var buildAppXml = function (sheetNames, properties) {
|
|
5524
|
+
var buildAppXml = function (sheetNames, isChartsheet, properties) {
|
|
5266
5525
|
var _a;
|
|
5267
|
-
|
|
5268
|
-
|
|
5526
|
+
// Excel groups the tabs by kind: `HeadingPairs` counts `Worksheets` then
|
|
5527
|
+
// `Charts` (a pair is only written for a non-empty kind) and `TitlesOfParts`
|
|
5528
|
+
// lists the worksheet names followed by the chartsheet names.
|
|
5529
|
+
var worksheetNames = sheetNames.filter(function (_, index) { return !isChartsheet[index]; });
|
|
5530
|
+
var chartsheetNames = sheetNames.filter(function (_, index) { return isChartsheet[index]; });
|
|
5531
|
+
var headingPairs = [
|
|
5532
|
+
["Worksheets", worksheetNames.length],
|
|
5533
|
+
["Charts", chartsheetNames.length],
|
|
5534
|
+
].filter(function (_a) {
|
|
5535
|
+
var _b = __read(_a, 2), count = _b[1];
|
|
5536
|
+
return count > 0;
|
|
5537
|
+
});
|
|
5538
|
+
var headingPairsXml = headingPairs
|
|
5539
|
+
.map(function (_a) {
|
|
5540
|
+
var _b = __read(_a, 2), kind = _b[0], count = _b[1];
|
|
5541
|
+
return "<vt:variant><vt:lpstr>".concat(kind, "</vt:lpstr></vt:variant><vt:variant><vt:i4>").concat(count, "</vt:i4></vt:variant>");
|
|
5542
|
+
})
|
|
5543
|
+
.join("");
|
|
5544
|
+
var titles = __spreadArray(__spreadArray([], __read(worksheetNames), false), __read(chartsheetNames), false).map(function (name) { return "<vt:lpstr>".concat(escapeXmlText(name), "</vt:lpstr>"); })
|
|
5269
5545
|
.join("");
|
|
5270
5546
|
var application = (_a = properties === null || properties === void 0 ? void 0 : properties.application) !== null && _a !== void 0 ? _a : CREATOR;
|
|
5271
5547
|
var companyTag = (properties === null || properties === void 0 ? void 0 : properties.company)
|
|
@@ -5274,7 +5550,7 @@ var buildAppXml = function (sheetNames, properties) {
|
|
|
5274
5550
|
var managerTag = (properties === null || properties === void 0 ? void 0 : properties.manager)
|
|
5275
5551
|
? "<Manager>".concat(escapeXmlText(properties.manager), "</Manager>")
|
|
5276
5552
|
: "";
|
|
5277
|
-
return "".concat(XML_DECLARATION, "<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\"><Application>").concat(escapeXmlText(application), "</Application><DocSecurity>0</DocSecurity><ScaleCrop>false</ScaleCrop><HeadingPairs><vt:vector size=\"2\" baseType=\"variant\"
|
|
5553
|
+
return "".concat(XML_DECLARATION, "<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\"><Application>").concat(escapeXmlText(application), "</Application><DocSecurity>0</DocSecurity><ScaleCrop>false</ScaleCrop><HeadingPairs><vt:vector size=\"").concat(headingPairs.length * 2, "\" baseType=\"variant\">").concat(headingPairsXml, "</vt:vector></HeadingPairs><TitlesOfParts><vt:vector size=\"").concat(sheetNames.length, "\" baseType=\"lpstr\">").concat(titles, "</vt:vector></TitlesOfParts>").concat(companyTag).concat(managerTag, "</Properties>");
|
|
5278
5554
|
};
|
|
5279
5555
|
var buildCoreXml = function (properties) {
|
|
5280
5556
|
var _a, _b, _d, _e;
|