@rowsncolumns/toolkit 24.4.5 → 24.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +884 -470
- 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 +600 -206
- package/package.json +10 -5
|
@@ -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,20 +1432,125 @@ 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
|
};
|
|
1447
|
+
/** Escape `"` as `""` inside a formula string literal. */
|
|
1448
|
+
var escapeFormulaText = function (value) { return value.replace(/"/g, '""'); };
|
|
1449
|
+
// `xlsxSource` is meant to hold the verbatim OOXML representation, but
|
|
1450
|
+
// writers other than the importer have filled it from Excel's JavaScript-API
|
|
1451
|
+
// vocabulary: a bare `list.source` literal (`On track,Watch,Off track`),
|
|
1452
|
+
// PascalCase operators (`Between`), PascalCase types (`WholeNumber`) and
|
|
1453
|
+
// `=`-prefixed formulas. Excel opens a file carrying any of those in repair
|
|
1454
|
+
// mode and drops the rule, so the exporter normalizes every field before
|
|
1455
|
+
// replaying it, and a type / operator that is not an OOXML token even after
|
|
1456
|
+
// normalization (`undefined` below) is never replayed — the rule falls
|
|
1457
|
+
// through to the condition synthesizer. Twin of `normalize_source_*` in
|
|
1458
|
+
// `rust/crates/rnc-export/src/xlsx/datavalidation.rs` — keep the two in sync
|
|
1459
|
+
// so both engines emit identical XML.
|
|
1460
|
+
var normalizeXlsxSourceType = function (type) {
|
|
1461
|
+
switch (type.trim().toLowerCase()) {
|
|
1462
|
+
case "list":
|
|
1463
|
+
return "list";
|
|
1464
|
+
case "whole":
|
|
1465
|
+
case "wholenumber":
|
|
1466
|
+
return "whole";
|
|
1467
|
+
case "decimal":
|
|
1468
|
+
return "decimal";
|
|
1469
|
+
case "date":
|
|
1470
|
+
return "date";
|
|
1471
|
+
case "time":
|
|
1472
|
+
return "time";
|
|
1473
|
+
case "textlength":
|
|
1474
|
+
return "textLength";
|
|
1475
|
+
case "custom":
|
|
1476
|
+
return "custom";
|
|
1477
|
+
default:
|
|
1478
|
+
return undefined;
|
|
1479
|
+
}
|
|
1480
|
+
};
|
|
1481
|
+
var normalizeXlsxSourceOperator = function (operator) {
|
|
1482
|
+
switch (operator.trim().toLowerCase()) {
|
|
1483
|
+
case "between":
|
|
1484
|
+
return "between";
|
|
1485
|
+
case "notbetween":
|
|
1486
|
+
return "notBetween";
|
|
1487
|
+
case "equal":
|
|
1488
|
+
case "equalto":
|
|
1489
|
+
return "equal";
|
|
1490
|
+
case "notequal":
|
|
1491
|
+
case "notequalto":
|
|
1492
|
+
return "notEqual";
|
|
1493
|
+
case "greaterthan":
|
|
1494
|
+
return "greaterThan";
|
|
1495
|
+
case "lessthan":
|
|
1496
|
+
return "lessThan";
|
|
1497
|
+
case "greaterthanorequal":
|
|
1498
|
+
case "greaterthanorequalto":
|
|
1499
|
+
return "greaterThanOrEqual";
|
|
1500
|
+
case "lessthanorequal":
|
|
1501
|
+
case "lessthanorequalto":
|
|
1502
|
+
return "lessThanOrEqual";
|
|
1503
|
+
default:
|
|
1504
|
+
return undefined;
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1507
|
+
// OOXML `<formula1>` text never carries the leading `=` a formula-style
|
|
1508
|
+
// source (`=Sheet1!$A$1:$A$5`) has.
|
|
1509
|
+
var stripLeadingEquals = function (formula) {
|
|
1510
|
+
var trimmed = formula.trim();
|
|
1511
|
+
return trimmed.startsWith("=") ? trimmed.slice(1) : trimmed;
|
|
1512
|
+
};
|
|
1513
|
+
// One identifier token — `[A-Za-z_\\][A-Za-z0-9_.]*` — which is what a
|
|
1514
|
+
// defined name (`StatusList`, `My_List.v2`) or a single A1 cell (`A1`) looks
|
|
1515
|
+
// like; a word list with commas or spaces is not one.
|
|
1516
|
+
var XLSX_IDENTIFIER_TOKEN = /^[A-Za-z_\\][A-Za-z0-9_.]*$/;
|
|
1517
|
+
// A single A1 cell token: 1–3 letters followed by digits.
|
|
1518
|
+
var XLSX_A1_CELL_TOKEN = /^[A-Za-z]{1,3}[0-9]+$/;
|
|
1519
|
+
// A function call — `OFFSET(…)`, `INDIRECT(…)` — which Excel writes without
|
|
1520
|
+
// a leading `=`.
|
|
1521
|
+
var XLSX_FUNCTION_CALL = /^[A-Za-z_\\][A-Za-z0-9_.]*\(.*\)$/;
|
|
1522
|
+
// `true` when a list source reads as a reference / formula rather than as
|
|
1523
|
+
// list text: it carries a reference marker (`!` sheet qualifier, `:` range,
|
|
1524
|
+
// `$` absolute anchor, `[` structured / external ref), is a single A1 cell
|
|
1525
|
+
// or defined-name token, or is a function call. Anything else — comma lists,
|
|
1526
|
+
// text with spaces, digit-only entries — is a bare literal that Excel only
|
|
1527
|
+
// accepts quoted.
|
|
1528
|
+
var looksLikeXlsxListReference = function (text) {
|
|
1529
|
+
return text.length > 0 &&
|
|
1530
|
+
(/[!:$[]/.test(text) ||
|
|
1531
|
+
XLSX_A1_CELL_TOKEN.test(text) ||
|
|
1532
|
+
XLSX_IDENTIFIER_TOKEN.test(text) ||
|
|
1533
|
+
XLSX_FUNCTION_CALL.test(text));
|
|
1534
|
+
};
|
|
1535
|
+
// A `list` source is valid OOXML only as a quoted string literal (`"a,b"`)
|
|
1536
|
+
// or a reference (`$A$1:$A$5`, `Sheet1!$A$1:$A$5`, `StatusList`, `OFFSET(…)`).
|
|
1537
|
+
// Excel's API hands back a literal list as bare comma-separated text and a
|
|
1538
|
+
// reference with a leading `=`, so: quoted → verbatim, `=`-prefixed → the `=`
|
|
1539
|
+
// is stripped and the rest replayed verbatim, reference-like → verbatim,
|
|
1540
|
+
// anything else → a literal that must be quoted (with `"` doubled inside, as
|
|
1541
|
+
// the ONE_OF_LIST branch does).
|
|
1542
|
+
var normalizeXlsxSourceListFormula1 = function (formula1) {
|
|
1543
|
+
var trimmed = formula1.trim();
|
|
1544
|
+
if (trimmed.startsWith('"'))
|
|
1545
|
+
return trimmed;
|
|
1546
|
+
if (trimmed.startsWith("="))
|
|
1547
|
+
return trimmed.slice(1).trim();
|
|
1548
|
+
if (looksLikeXlsxListReference(trimmed))
|
|
1549
|
+
return trimmed;
|
|
1550
|
+
return "\"".concat(escapeFormulaText(trimmed), "\"");
|
|
1551
|
+
};
|
|
1370
1552
|
var convertDataValidationRule = function (rule) {
|
|
1371
|
-
var _a, _b, _d, _e, _f, _g
|
|
1553
|
+
var _a, _b, _d, _e, _f, _g;
|
|
1372
1554
|
if (!rule)
|
|
1373
1555
|
return undefined;
|
|
1374
1556
|
var allowBlank = rule.allowBlank !== false;
|
|
@@ -1385,14 +1567,48 @@ var convertDataValidationRule = function (rule) {
|
|
|
1385
1567
|
prompt: (_g = inputMessage === null || inputMessage === void 0 ? void 0 : inputMessage.message) !== null && _g !== void 0 ? _g : undefined,
|
|
1386
1568
|
};
|
|
1387
1569
|
// Round-trip path: when the rule was imported from xlsx, replay the
|
|
1388
|
-
//
|
|
1389
|
-
//
|
|
1390
|
-
//
|
|
1570
|
+
// source representation after normalizing it to OOXML vocabulary (see
|
|
1571
|
+
// `normalizeXlsxSource*`). Preserves type/operator/formulas, including
|
|
1572
|
+
// `whole`/`textLength`/`time` types and user-written custom formulas
|
|
1573
|
+
// without `INDIRECT("RC",FALSE)` rewriting. A type / operator that is not
|
|
1574
|
+
// an OOXML token even after normalization (Excel's `Inconsistent`,
|
|
1575
|
+
// `MixedCriteria`) is never written: the rule falls through to the
|
|
1576
|
+
// condition synthesizer.
|
|
1391
1577
|
var src = rule.xlsxSource;
|
|
1578
|
+
var rejectedListSource;
|
|
1392
1579
|
if (src && src.type && typeof src.formula1 === "string" && src.formula1) {
|
|
1393
|
-
|
|
1580
|
+
var type = normalizeXlsxSourceType(src.type);
|
|
1581
|
+
var operator = src.operator
|
|
1582
|
+
? normalizeXlsxSourceOperator(src.operator)
|
|
1583
|
+
: undefined;
|
|
1584
|
+
var operatorValid = !src.operator || operator !== undefined;
|
|
1585
|
+
if (type !== undefined && operatorValid) {
|
|
1586
|
+
var formula1 = type === "list"
|
|
1587
|
+
? normalizeXlsxSourceListFormula1(src.formula1)
|
|
1588
|
+
: stripLeadingEquals(src.formula1);
|
|
1589
|
+
return __assign({ type: type, operator: operator, formula1: formula1, formula2: src.formula2 ? stripLeadingEquals(src.formula2) : undefined, showDropDown: type === "list" && rule.displayStyle === "plain" ? true : undefined }, baseConfig);
|
|
1590
|
+
}
|
|
1591
|
+
if (type === "list") {
|
|
1592
|
+
rejectedListSource = normalizeXlsxSourceListFormula1(src.formula1);
|
|
1593
|
+
}
|
|
1394
1594
|
}
|
|
1395
|
-
|
|
1595
|
+
var synthesized = convertDataValidationCondition(rule, baseConfig);
|
|
1596
|
+
if (synthesized)
|
|
1597
|
+
return synthesized;
|
|
1598
|
+
// A rejected `list` source with no usable condition is still kept — its
|
|
1599
|
+
// normalized source text (quoted literal or reference) is always valid
|
|
1600
|
+
// OOXML. Anything else rejected has nothing valid to write and is skipped.
|
|
1601
|
+
if (rejectedListSource !== undefined) {
|
|
1602
|
+
return __assign({ type: "list", formula1: rejectedListSource, showDropDown: rule.displayStyle === "plain" ? true : undefined }, baseConfig);
|
|
1603
|
+
}
|
|
1604
|
+
return undefined;
|
|
1605
|
+
};
|
|
1606
|
+
// The condition-based synthesizer: the Excel config for a rule that has no
|
|
1607
|
+
// replayable `xlsxSource` (UI-authored, edited after import, or rejected by
|
|
1608
|
+
// the round-trip guard above).
|
|
1609
|
+
var convertDataValidationCondition = function (rule, baseConfig) {
|
|
1610
|
+
var _a, _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
1611
|
+
if (!((_a = rule.condition) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
1396
1612
|
// Prompt-only DV (no validation rule, just an input-message tooltip
|
|
1397
1613
|
// and/or an error alert). Emit it with no type/formula so Excel still
|
|
1398
1614
|
// shows the tooltip when the cell is selected.
|
|
@@ -1402,9 +1618,8 @@ var convertDataValidationRule = function (rule) {
|
|
|
1402
1618
|
return undefined;
|
|
1403
1619
|
}
|
|
1404
1620
|
var condition = rule.condition;
|
|
1405
|
-
var values = (
|
|
1621
|
+
var values = (_b = condition.values) !== null && _b !== void 0 ? _b : [];
|
|
1406
1622
|
var currentCell = 'INDIRECT("RC",FALSE)';
|
|
1407
|
-
var escapeFormulaText = function (value) { return value.replace(/"/g, '""'); };
|
|
1408
1623
|
var ensureFormula = function (value) {
|
|
1409
1624
|
return value.startsWith("=") ? value : "=".concat(value);
|
|
1410
1625
|
};
|
|
@@ -1428,7 +1643,7 @@ var convertDataValidationRule = function (rule) {
|
|
|
1428
1643
|
return __assign({ type: "list", formula1: formula1.startsWith("=") ? formula1 : "=".concat(formula1), showDropDown: rule.displayStyle === "plain" ? true : undefined }, baseConfig);
|
|
1429
1644
|
}
|
|
1430
1645
|
if (condition.type === "CUSTOM_FORMULA") {
|
|
1431
|
-
var raw = (
|
|
1646
|
+
var raw = (_e = (_d = values[0]) === null || _d === void 0 ? void 0 : _d.userEnteredValue) !== null && _e !== void 0 ? _e : "";
|
|
1432
1647
|
if (!raw)
|
|
1433
1648
|
return undefined;
|
|
1434
1649
|
return __assign({ type: "custom", formula1: ensureFormula(raw) }, baseConfig);
|
|
@@ -1443,33 +1658,33 @@ var convertDataValidationRule = function (rule) {
|
|
|
1443
1658
|
return __assign({ type: "custom", formula1: "=".concat(currentCell, "<>\"\"") }, baseConfig);
|
|
1444
1659
|
}
|
|
1445
1660
|
if (condition.type === "TEXT_EQ" || condition.type === "TEXT_NOT_EQ") {
|
|
1446
|
-
var raw = (
|
|
1661
|
+
var raw = (_g = (_f = values[0]) === null || _f === void 0 ? void 0 : _f.userEnteredValue) !== null && _g !== void 0 ? _g : "";
|
|
1447
1662
|
if (!raw)
|
|
1448
1663
|
return undefined;
|
|
1449
1664
|
var op = condition.type === "TEXT_EQ" ? "=" : "<>";
|
|
1450
1665
|
return __assign({ type: "custom", formula1: "=".concat(currentCell).concat(op, "\"").concat(escapeFormulaText(raw), "\"") }, baseConfig);
|
|
1451
1666
|
}
|
|
1452
1667
|
if (condition.type === "TEXT_CONTAINS") {
|
|
1453
|
-
var raw = (
|
|
1668
|
+
var raw = (_j = (_h = values[0]) === null || _h === void 0 ? void 0 : _h.userEnteredValue) !== null && _j !== void 0 ? _j : "";
|
|
1454
1669
|
if (!raw)
|
|
1455
1670
|
return undefined;
|
|
1456
1671
|
return __assign({ type: "custom", formula1: "=ISNUMBER(SEARCH(\"".concat(escapeFormulaText(raw), "\",").concat(currentCell, "))") }, baseConfig);
|
|
1457
1672
|
}
|
|
1458
1673
|
if (condition.type === "TEXT_NOT_CONTAINS") {
|
|
1459
|
-
var raw = (
|
|
1674
|
+
var raw = (_l = (_k = values[0]) === null || _k === void 0 ? void 0 : _k.userEnteredValue) !== null && _l !== void 0 ? _l : "";
|
|
1460
1675
|
if (!raw)
|
|
1461
1676
|
return undefined;
|
|
1462
1677
|
return __assign({ type: "custom", formula1: "=ISERROR(SEARCH(\"".concat(escapeFormulaText(raw), "\",").concat(currentCell, "))") }, baseConfig);
|
|
1463
1678
|
}
|
|
1464
1679
|
if (condition.type === "TEXT_STARTS_WITH") {
|
|
1465
|
-
var raw = (
|
|
1680
|
+
var raw = (_o = (_m = values[0]) === null || _m === void 0 ? void 0 : _m.userEnteredValue) !== null && _o !== void 0 ? _o : "";
|
|
1466
1681
|
if (!raw)
|
|
1467
1682
|
return undefined;
|
|
1468
1683
|
var text = escapeFormulaText(raw);
|
|
1469
1684
|
return __assign({ type: "custom", formula1: "=LEFT(".concat(currentCell, ",LEN(\"").concat(text, "\"))=\"").concat(text, "\"") }, baseConfig);
|
|
1470
1685
|
}
|
|
1471
1686
|
if (condition.type === "TEXT_ENDS_WITH") {
|
|
1472
|
-
var raw = (
|
|
1687
|
+
var raw = (_q = (_p = values[0]) === null || _p === void 0 ? void 0 : _p.userEnteredValue) !== null && _q !== void 0 ? _q : "";
|
|
1473
1688
|
if (!raw)
|
|
1474
1689
|
return undefined;
|
|
1475
1690
|
var text = escapeFormulaText(raw);
|
|
@@ -1489,10 +1704,10 @@ var convertDataValidationRule = function (rule) {
|
|
|
1489
1704
|
condition.type === "NUMBER_GREATER_THAN_EQ" ||
|
|
1490
1705
|
condition.type === "NUMBER_LESS" ||
|
|
1491
1706
|
condition.type === "NUMBER_LESS_THAN_EQ") {
|
|
1492
|
-
var first = (
|
|
1707
|
+
var first = (_t = (_s = values[0]) === null || _s === void 0 ? void 0 : _s.userEnteredValue) !== null && _t !== void 0 ? _t : "";
|
|
1493
1708
|
if (!first)
|
|
1494
1709
|
return undefined;
|
|
1495
|
-
var second = (
|
|
1710
|
+
var second = (_v = (_u = values[1]) === null || _u === void 0 ? void 0 : _u.userEnteredValue) !== null && _v !== void 0 ? _v : "";
|
|
1496
1711
|
var operatorMap = {
|
|
1497
1712
|
NUMBER_BETWEEN: "between",
|
|
1498
1713
|
NUMBER_NOT_BETWEEN: "notBetween",
|
|
@@ -1529,10 +1744,10 @@ var convertDataValidationRule = function (rule) {
|
|
|
1529
1744
|
condition.type === "DATE_ON_OR_AFTER" ||
|
|
1530
1745
|
condition.type === "DATE_BETWEEN" ||
|
|
1531
1746
|
condition.type === "DATE_NOT_BETWEEN") {
|
|
1532
|
-
var first = (
|
|
1747
|
+
var first = (_x = (_w = values[0]) === null || _w === void 0 ? void 0 : _w.userEnteredValue) !== null && _x !== void 0 ? _x : "";
|
|
1533
1748
|
if (!first)
|
|
1534
1749
|
return undefined;
|
|
1535
|
-
var second = (
|
|
1750
|
+
var second = (_z = (_y = values[1]) === null || _y === void 0 ? void 0 : _y.userEnteredValue) !== null && _z !== void 0 ? _z : "";
|
|
1536
1751
|
var operatorMap = {
|
|
1537
1752
|
DATE_EQ: "equal",
|
|
1538
1753
|
DATE_NOT_EQ: "notEqual",
|
|
@@ -1730,7 +1945,7 @@ var buildWorksheetRow = function (_a) {
|
|
|
1730
1945
|
};
|
|
1731
1946
|
};
|
|
1732
1947
|
var buildCellXml = function (_a) {
|
|
1733
|
-
var
|
|
1948
|
+
var e_33, _b;
|
|
1734
1949
|
var _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1735
1950
|
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
1951
|
var normalizedCell = cell;
|
|
@@ -1827,12 +2042,12 @@ var buildCellXml = function (_a) {
|
|
|
1827
2042
|
sheetIdByName_1.set(s.title, s.sheetId);
|
|
1828
2043
|
}
|
|
1829
2044
|
}
|
|
1830
|
-
catch (
|
|
2045
|
+
catch (e_33_1) { e_33 = { error: e_33_1 }; }
|
|
1831
2046
|
finally {
|
|
1832
2047
|
try {
|
|
1833
2048
|
if (sheets_1_1 && !sheets_1_1.done && (_b = sheets_1.return)) _b.call(sheets_1);
|
|
1834
2049
|
}
|
|
1835
|
-
finally { if (
|
|
2050
|
+
finally { if (e_33) throw e_33.error; }
|
|
1836
2051
|
}
|
|
1837
2052
|
// A real CellXfsRegistry so `SheetCell.assign` inside the derive
|
|
1838
2053
|
// helper can resolve precedent cells whose `uf` is a `{ sid }` style
|
|
@@ -2069,7 +2284,7 @@ function isValidExcelDateSerial(value) {
|
|
|
2069
2284
|
return value >= MIN_EXCEL_DATE_SERIAL && value <= MAX_EXCEL_DATE_SERIAL;
|
|
2070
2285
|
}
|
|
2071
2286
|
function rewriteTableNamesInFormula(formula, tableNameMap) {
|
|
2072
|
-
var
|
|
2287
|
+
var e_34, _a;
|
|
2073
2288
|
if (!(tableNameMap === null || tableNameMap === void 0 ? void 0 : tableNameMap.size))
|
|
2074
2289
|
return formula;
|
|
2075
2290
|
var normalized = formula;
|
|
@@ -2084,12 +2299,12 @@ function rewriteTableNamesInFormula(formula, tableNameMap) {
|
|
|
2084
2299
|
normalized = normalized.replace(new RegExp("".concat(escaped, "(?=\\[)"), "g"), exportedName);
|
|
2085
2300
|
}
|
|
2086
2301
|
}
|
|
2087
|
-
catch (
|
|
2302
|
+
catch (e_34_1) { e_34 = { error: e_34_1 }; }
|
|
2088
2303
|
finally {
|
|
2089
2304
|
try {
|
|
2090
2305
|
if (tableNameMap_1_1 && !tableNameMap_1_1.done && (_a = tableNameMap_1.return)) _a.call(tableNameMap_1);
|
|
2091
2306
|
}
|
|
2092
|
-
finally { if (
|
|
2307
|
+
finally { if (e_34) throw e_34.error; }
|
|
2093
2308
|
}
|
|
2094
2309
|
return normalized;
|
|
2095
2310
|
}
|
|
@@ -2489,7 +2704,7 @@ var buildRichRunProperties = function (format) {
|
|
|
2489
2704
|
* style flag, but that's a cell-style concern, not a sharedString one.
|
|
2490
2705
|
*/
|
|
2491
2706
|
var buildRichTextRuns = function (text, runs) {
|
|
2492
|
-
var
|
|
2707
|
+
var e_35, _a;
|
|
2493
2708
|
var sorted = __spreadArray([], __read(runs), false).sort(function (a, b) { return a.startIndex - b.startIndex; });
|
|
2494
2709
|
var out = [];
|
|
2495
2710
|
var cursor = 0;
|
|
@@ -2522,12 +2737,12 @@ var buildRichTextRuns = function (text, runs) {
|
|
|
2522
2737
|
cursor = end;
|
|
2523
2738
|
}
|
|
2524
2739
|
}
|
|
2525
|
-
catch (
|
|
2740
|
+
catch (e_35_1) { e_35 = { error: e_35_1 }; }
|
|
2526
2741
|
finally {
|
|
2527
2742
|
try {
|
|
2528
2743
|
if (sorted_2_1 && !sorted_2_1.done && (_a = sorted_2.return)) _a.call(sorted_2);
|
|
2529
2744
|
}
|
|
2530
|
-
finally { if (
|
|
2745
|
+
finally { if (e_35) throw e_35.error; }
|
|
2531
2746
|
}
|
|
2532
2747
|
if (cursor < text.length) {
|
|
2533
2748
|
emit(text.slice(cursor), "");
|
|
@@ -2548,7 +2763,7 @@ var buildSharedStringsXml = function (sharedStrings) {
|
|
|
2548
2763
|
return "".concat(XML_DECLARATION, "<sst xmlns=\"").concat(WORKSHEET_NS, "\" count=\"").concat(sharedStrings.totalCount, "\" uniqueCount=\"").concat(sharedStrings.entries.length, "\">").concat(entries, "</sst>");
|
|
2549
2764
|
};
|
|
2550
2765
|
var buildTableNameMap = function (tables) {
|
|
2551
|
-
var
|
|
2766
|
+
var e_36, _a;
|
|
2552
2767
|
var _b;
|
|
2553
2768
|
var map = new Map();
|
|
2554
2769
|
try {
|
|
@@ -2560,12 +2775,12 @@ var buildTableNameMap = function (tables) {
|
|
|
2560
2775
|
map.set(tableTitle, table.name);
|
|
2561
2776
|
}
|
|
2562
2777
|
}
|
|
2563
|
-
catch (
|
|
2778
|
+
catch (e_36_1) { e_36 = { error: e_36_1 }; }
|
|
2564
2779
|
finally {
|
|
2565
2780
|
try {
|
|
2566
2781
|
if (tables_1_1 && !tables_1_1.done && (_a = tables_1.return)) _a.call(tables_1);
|
|
2567
2782
|
}
|
|
2568
|
-
finally { if (
|
|
2783
|
+
finally { if (e_36) throw e_36.error; }
|
|
2569
2784
|
}
|
|
2570
2785
|
return map;
|
|
2571
2786
|
};
|
|
@@ -2573,7 +2788,7 @@ var buildTableNameMap = function (tables) {
|
|
|
2573
2788
|
// whose box intersects another table on the same sheet. Drop both before
|
|
2574
2789
|
// emitting so the workbook opens without "We found a problem" recovery prompts.
|
|
2575
2790
|
var filterExportableTables = function (tables) {
|
|
2576
|
-
var
|
|
2791
|
+
var e_37, _a;
|
|
2577
2792
|
var _b;
|
|
2578
2793
|
var isValidBox = function (range) {
|
|
2579
2794
|
if (!range)
|
|
@@ -2600,7 +2815,7 @@ var filterExportableTables = function (tables) {
|
|
|
2600
2815
|
};
|
|
2601
2816
|
var keptBySheet = new Map();
|
|
2602
2817
|
var result = [];
|
|
2603
|
-
var
|
|
2818
|
+
var _loop_5 = function (table) {
|
|
2604
2819
|
if (!isValidBox(table.range))
|
|
2605
2820
|
return "continue";
|
|
2606
2821
|
var sheetKept = (_b = keptBySheet.get(table.sheetId)) !== null && _b !== void 0 ? _b : [];
|
|
@@ -2613,15 +2828,15 @@ var filterExportableTables = function (tables) {
|
|
|
2613
2828
|
try {
|
|
2614
2829
|
for (var tables_2 = __values(tables), tables_2_1 = tables_2.next(); !tables_2_1.done; tables_2_1 = tables_2.next()) {
|
|
2615
2830
|
var table = tables_2_1.value;
|
|
2616
|
-
|
|
2831
|
+
_loop_5(table);
|
|
2617
2832
|
}
|
|
2618
2833
|
}
|
|
2619
|
-
catch (
|
|
2834
|
+
catch (e_37_1) { e_37 = { error: e_37_1 }; }
|
|
2620
2835
|
finally {
|
|
2621
2836
|
try {
|
|
2622
2837
|
if (tables_2_1 && !tables_2_1.done && (_a = tables_2.return)) _a.call(tables_2);
|
|
2623
2838
|
}
|
|
2624
|
-
finally { if (
|
|
2839
|
+
finally { if (e_37) throw e_37.error; }
|
|
2625
2840
|
}
|
|
2626
2841
|
return result;
|
|
2627
2842
|
};
|
|
@@ -2697,8 +2912,8 @@ var resolveTableColumnTotals = function (column, totalsCell) {
|
|
|
2697
2912
|
var label = getExtendedValueString(getCellUserEnteredValue(totalsCell));
|
|
2698
2913
|
return label && label.trim() !== "" ? { totalsRowLabel: label } : undefined;
|
|
2699
2914
|
};
|
|
2700
|
-
var buildTableXml = function (table, rows, sourceSharedStrings, styleBuilder) {
|
|
2701
|
-
var _a, _b, _d;
|
|
2915
|
+
var buildTableXml = function (table, rows, sourceSharedStrings, styleBuilder, customTableStyleNames) {
|
|
2916
|
+
var _a, _b, _d, _e;
|
|
2702
2917
|
var rangeRef = table.ref;
|
|
2703
2918
|
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
2919
|
table.range.startColumnIndex +
|
|
@@ -2774,18 +2989,76 @@ var buildTableXml = function (table, rows, sourceSharedStrings, styleBuilder) {
|
|
|
2774
2989
|
})
|
|
2775
2990
|
.join(""), "</tableColumns>");
|
|
2776
2991
|
var isBuiltInStyle = table.theme && /^TableStyle(Light|Medium|Dark)\d+$/.test(table.theme);
|
|
2777
|
-
|
|
2992
|
+
// A custom style written to `<tableStyles>` keeps its name here (#668 T-103).
|
|
2993
|
+
var isCustomStyle = !!table.theme && ((_e = customTableStyleNames === null || customTableStyleNames === void 0 ? void 0 : customTableStyleNames.has(table.theme)) !== null && _e !== void 0 ? _e : false);
|
|
2994
|
+
var tableStyleName = isBuiltInStyle || isCustomStyle ? table.theme : "TableStyleMedium2";
|
|
2778
2995
|
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, "\"/>");
|
|
2996
|
+
// Excel's per-column "filter button" toggle: `<filterColumn hiddenButton="1">`
|
|
2997
|
+
// (the table-level toggle is the presence of `<autoFilter>` itself).
|
|
2998
|
+
var hiddenButtonColumns = new Set(columnNames
|
|
2999
|
+
.map(function (_, idx) { return idx; })
|
|
3000
|
+
.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
3001
|
var autoFilter = headerRowCount > 0 && table.filterButton !== false
|
|
2780
3002
|
? (function () {
|
|
2781
3003
|
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);
|
|
3004
|
+
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
3005
|
return filterColumns
|
|
2784
3006
|
? "<autoFilter ref=\"".concat(rangeRef, "\">").concat(filterColumns, "</autoFilter>")
|
|
2785
3007
|
: "<autoFilter ref=\"".concat(rangeRef, "\"/>");
|
|
2786
3008
|
})()
|
|
2787
3009
|
: "";
|
|
2788
|
-
|
|
3010
|
+
var sortState = buildTableSortStateXml(table, headerRowCount, totalsRowCount, styleBuilder);
|
|
3011
|
+
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>");
|
|
3012
|
+
};
|
|
3013
|
+
/**
|
|
3014
|
+
* A table's persisted sort levels as `<sortState ref="<body>">` with one
|
|
3015
|
+
* `<sortCondition>` per level (`CT_SortCondition`: `ref` is the level's
|
|
3016
|
+
* column over the body rows, `descending`, `sortBy` + `dxfId` for a colour
|
|
3017
|
+
* level, `sortBy="icon"` + `iconSet`/`iconId`, and Excel's comma-joined
|
|
3018
|
+
* `customList`). Sits between `<autoFilter>` and `<tableColumns>` per
|
|
3019
|
+
* `CT_Table`. The inverse of the parser's `createSortSpecsFromSortState`.
|
|
3020
|
+
*/
|
|
3021
|
+
var buildTableSortStateXml = function (table, headerRowCount, totalsRowCount, styleBuilder) {
|
|
3022
|
+
var _a;
|
|
3023
|
+
var sortSpecs = (_a = table.sortSpecs) !== null && _a !== void 0 ? _a : [];
|
|
3024
|
+
var bodyStartRow = table.range.startRowIndex + headerRowCount;
|
|
3025
|
+
var bodyEndRow = table.range.endRowIndex - totalsRowCount;
|
|
3026
|
+
if (!sortSpecs.length || bodyEndRow < bodyStartRow)
|
|
3027
|
+
return "";
|
|
3028
|
+
var bodyRef = function (startColumnIndex, endColumnIndex) {
|
|
3029
|
+
return cellRangeToAddress(undefined, {
|
|
3030
|
+
startRowIndex: bodyStartRow,
|
|
3031
|
+
endRowIndex: bodyEndRow,
|
|
3032
|
+
startColumnIndex: startColumnIndex,
|
|
3033
|
+
endColumnIndex: endColumnIndex,
|
|
3034
|
+
});
|
|
3035
|
+
};
|
|
3036
|
+
var conditions = sortSpecs.map(function (spec) {
|
|
3037
|
+
var _a, _b, _d;
|
|
3038
|
+
var columnIndex = table.range.startColumnIndex + spec.dimensionIndex;
|
|
3039
|
+
var attrs = ["ref=\"".concat(bodyRef(columnIndex, columnIndex), "\"")];
|
|
3040
|
+
if (spec.sortOrder === "DESCENDING")
|
|
3041
|
+
attrs.push("descending=\"1\"");
|
|
3042
|
+
var sortBy = (_a = spec.sortBy) !== null && _a !== void 0 ? _a : "value";
|
|
3043
|
+
if (sortBy === "cellColor" || sortBy === "fontColor") {
|
|
3044
|
+
attrs.push("sortBy=\"".concat(sortBy, "\""));
|
|
3045
|
+
var dxfId = spec.sortColor && styleBuilder
|
|
3046
|
+
? styleBuilder.registerDifferentialFormat(sortBy === "cellColor"
|
|
3047
|
+
? { backgroundColor: spec.sortColor }
|
|
3048
|
+
: { textFormat: { color: spec.sortColor } })
|
|
3049
|
+
: undefined;
|
|
3050
|
+
if (typeof dxfId === "number")
|
|
3051
|
+
attrs.push("dxfId=\"".concat(dxfId, "\""));
|
|
3052
|
+
}
|
|
3053
|
+
else if (sortBy === "icon" && spec.sortIcon) {
|
|
3054
|
+
attrs.push("sortBy=\"icon\"", "iconSet=\"".concat(escapeXmlAttr(spec.sortIcon.iconSet), "\""), "iconId=\"".concat((_b = spec.sortIcon.iconId) !== null && _b !== void 0 ? _b : 0, "\""));
|
|
3055
|
+
}
|
|
3056
|
+
if ((_d = spec.customList) === null || _d === void 0 ? void 0 : _d.length) {
|
|
3057
|
+
attrs.push("customList=\"".concat(escapeXmlAttr(spec.customList.join(",")), "\""));
|
|
3058
|
+
}
|
|
3059
|
+
return "<sortCondition ".concat(attrs.join(" "), "/>");
|
|
3060
|
+
});
|
|
3061
|
+
return "<sortState ref=\"".concat(bodyRef(table.range.startColumnIndex, table.range.endColumnIndex), "\">").concat(conditions.join(""), "</sortState>");
|
|
2789
3062
|
};
|
|
2790
3063
|
var getFilterVisibleValues = function (spec, range, rows, headerRow, totalRow) {
|
|
2791
3064
|
var _a, _b, _d;
|
|
@@ -2846,7 +3119,7 @@ var SHEET_PROTECTION_FLAG_ATTRS = [
|
|
|
2846
3119
|
* Excel's schema default applies). Mirrors `rnc-export`'s `sheet_protection_xml`.
|
|
2847
3120
|
*/
|
|
2848
3121
|
var buildSheetProtectionElementXml = function (protection) {
|
|
2849
|
-
var
|
|
3122
|
+
var e_38, _a;
|
|
2850
3123
|
var attrs = [];
|
|
2851
3124
|
if (protection.algorithmName) {
|
|
2852
3125
|
attrs.push("algorithmName=\"".concat(escapeXmlAttr(protection.algorithmName), "\""));
|
|
@@ -2872,12 +3145,12 @@ var buildSheetProtectionElementXml = function (protection) {
|
|
|
2872
3145
|
}
|
|
2873
3146
|
}
|
|
2874
3147
|
}
|
|
2875
|
-
catch (
|
|
3148
|
+
catch (e_38_1) { e_38 = { error: e_38_1 }; }
|
|
2876
3149
|
finally {
|
|
2877
3150
|
try {
|
|
2878
3151
|
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
3152
|
}
|
|
2880
|
-
finally { if (
|
|
3153
|
+
finally { if (e_38) throw e_38.error; }
|
|
2881
3154
|
}
|
|
2882
3155
|
return attrs.length ? "<sheetProtection ".concat(attrs.join(" "), "/>") : "";
|
|
2883
3156
|
};
|
|
@@ -2889,7 +3162,7 @@ var buildSheetProtectionElementXml = function (protection) {
|
|
|
2889
3162
|
* is the range's id, synthesized as `Range{n}` when absent (schema requires it).
|
|
2890
3163
|
*/
|
|
2891
3164
|
var buildSheetProtectionXml = function (sheet, protectedRanges) {
|
|
2892
|
-
var
|
|
3165
|
+
var e_39, _a;
|
|
2893
3166
|
var protectionXml = sheet.sheetProtection
|
|
2894
3167
|
? buildSheetProtectionElementXml(sheet.sheetProtection)
|
|
2895
3168
|
: "";
|
|
@@ -2930,12 +3203,12 @@ var buildSheetProtectionXml = function (sheet, protectedRanges) {
|
|
|
2930
3203
|
rangeItems.push("<protectedRange sqref=\"".concat(escapeXmlAttr(sqref), "\" name=\"").concat(escapeXmlAttr(name_1), "\"").concat(securityDescriptor, "/>"));
|
|
2931
3204
|
}
|
|
2932
3205
|
}
|
|
2933
|
-
catch (
|
|
3206
|
+
catch (e_39_1) { e_39 = { error: e_39_1 }; }
|
|
2934
3207
|
finally {
|
|
2935
3208
|
try {
|
|
2936
3209
|
if (_d && !_d.done && (_a = _b.return)) _a.call(_b);
|
|
2937
3210
|
}
|
|
2938
|
-
finally { if (
|
|
3211
|
+
finally { if (e_39) throw e_39.error; }
|
|
2939
3212
|
}
|
|
2940
3213
|
var rangesXml = rangeItems.length
|
|
2941
3214
|
? "<protectedRanges>".concat(rangeItems.join(""), "</protectedRanges>")
|
|
@@ -2984,8 +3257,14 @@ var xmlNumAttr = function (name, value) {
|
|
|
2984
3257
|
* mandatory in practice (Excel always writes it), so the default margins go
|
|
2985
3258
|
* out when the sheet has none of its own.
|
|
2986
3259
|
*/
|
|
2987
|
-
var
|
|
3260
|
+
var buildPageMarginsXml = function (print) {
|
|
2988
3261
|
var _a, _b, _d, _e, _f, _g;
|
|
3262
|
+
var margins = print === null || print === void 0 ? void 0 : print.pageMargins;
|
|
3263
|
+
return margins && Object.values(margins).some(function (v) { return typeof v === "number"; })
|
|
3264
|
+
? "<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, "\"/>")
|
|
3265
|
+
: DEFAULT_PAGE_MARGINS;
|
|
3266
|
+
};
|
|
3267
|
+
var buildPrintSettingsXml = function (print) {
|
|
2989
3268
|
var parts = [];
|
|
2990
3269
|
var options = print === null || print === void 0 ? void 0 : print.printOptions;
|
|
2991
3270
|
var optionAttrs = xmlBoolAttr("horizontalCentered", options === null || options === void 0 ? void 0 : options.horizontalCentered) +
|
|
@@ -2994,11 +3273,7 @@ var buildPrintSettingsXml = function (print) {
|
|
|
2994
3273
|
xmlBoolAttr("gridLines", options === null || options === void 0 ? void 0 : options.gridLines);
|
|
2995
3274
|
if (optionAttrs)
|
|
2996
3275
|
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);
|
|
3276
|
+
parts.push(buildPageMarginsXml(print));
|
|
3002
3277
|
var setup = print === null || print === void 0 ? void 0 : print.pageSetup;
|
|
3003
3278
|
if (setup) {
|
|
3004
3279
|
// Excel keeps `firstPageNumber` as a dormant value until the user picks
|
|
@@ -3063,20 +3338,49 @@ var buildPrintSettingsXml = function (print) {
|
|
|
3063
3338
|
}
|
|
3064
3339
|
return parts.join("");
|
|
3065
3340
|
};
|
|
3066
|
-
var buildFilterColumnsXml = function (filterSpecs, range, rows, headerRow, totalRow, styleBuilder
|
|
3341
|
+
var buildFilterColumnsXml = function (filterSpecs, range, rows, headerRow, totalRow, styleBuilder,
|
|
3342
|
+
/** Table-relative column ids whose header hides its filter button. */
|
|
3343
|
+
hiddenButtonColumns) {
|
|
3344
|
+
var e_40, _a;
|
|
3067
3345
|
if (headerRow === void 0) { headerRow = true; }
|
|
3068
3346
|
if (totalRow === void 0) { totalRow = false; }
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3347
|
+
var entries = new Map();
|
|
3348
|
+
try {
|
|
3349
|
+
for (var _b = __values(filterSpecs !== null && filterSpecs !== void 0 ? filterSpecs : []), _d = _b.next(); !_d.done; _d = _b.next()) {
|
|
3350
|
+
var spec = _d.value;
|
|
3351
|
+
var xml = buildFilterColumnXml(spec, range, rows, headerRow, totalRow, styleBuilder);
|
|
3352
|
+
if (xml)
|
|
3353
|
+
entries.set(spec.columnIndex, xml);
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
catch (e_40_1) { e_40 = { error: e_40_1 }; }
|
|
3357
|
+
finally {
|
|
3358
|
+
try {
|
|
3359
|
+
if (_d && !_d.done && (_a = _b.return)) _a.call(_b);
|
|
3360
|
+
}
|
|
3361
|
+
finally { if (e_40) throw e_40.error; }
|
|
3362
|
+
}
|
|
3363
|
+
// `hiddenButton="1"` rides the column's criteria element when it has one,
|
|
3364
|
+
// else a bare `<filterColumn/>` carries it.
|
|
3365
|
+
hiddenButtonColumns === null || hiddenButtonColumns === void 0 ? void 0 : hiddenButtonColumns.forEach(function (colId) {
|
|
3366
|
+
var existing = entries.get(colId);
|
|
3367
|
+
entries.set(colId, existing
|
|
3368
|
+
? existing.replace("<filterColumn colId=\"".concat(colId, "\">"), "<filterColumn colId=\"".concat(colId, "\" hiddenButton=\"1\">"))
|
|
3369
|
+
: "<filterColumn colId=\"".concat(colId, "\" hiddenButton=\"1\"/>"));
|
|
3370
|
+
});
|
|
3371
|
+
return __spreadArray([], __read(entries.entries()), false).sort(function (_a, _b) {
|
|
3372
|
+
var _d = __read(_a, 1), a = _d[0];
|
|
3373
|
+
var _e = __read(_b, 1), b = _e[0];
|
|
3374
|
+
return a - b;
|
|
3074
3375
|
})
|
|
3075
|
-
.
|
|
3076
|
-
|
|
3376
|
+
.map(function (_a) {
|
|
3377
|
+
var _b = __read(_a, 2), xml = _b[1];
|
|
3378
|
+
return xml;
|
|
3379
|
+
})
|
|
3380
|
+
.join("");
|
|
3077
3381
|
};
|
|
3078
3382
|
var buildFilterColumnXml = function (spec, range, rows, headerRow, totalRow, styleBuilder) {
|
|
3079
|
-
var _a, _b, _d, _e, _f
|
|
3383
|
+
var _a, _b, _d, _e, _f;
|
|
3080
3384
|
if (headerRow === void 0) { headerRow = true; }
|
|
3081
3385
|
if (totalRow === void 0) { totalRow = false; }
|
|
3082
3386
|
var parts = [];
|
|
@@ -3105,13 +3409,15 @@ var buildFilterColumnXml = function (spec, range, rows, headerRow, totalRow, sty
|
|
|
3105
3409
|
// above-average …) takes precedence over a value-list and is emitted as
|
|
3106
3410
|
// <customFilters> or <dynamicFilter>. Falls back to the value list when the
|
|
3107
3411
|
// condition has no AutoFilter representation.
|
|
3108
|
-
var conditionXml =
|
|
3412
|
+
var conditionXml = spec.filterCriteria
|
|
3413
|
+
? buildAutoFilterCriteriaXml(spec.filterCriteria)
|
|
3414
|
+
: null;
|
|
3109
3415
|
if (conditionXml) {
|
|
3110
3416
|
parts.push(conditionXml);
|
|
3111
3417
|
}
|
|
3112
3418
|
else {
|
|
3113
3419
|
// <filters><filter val=…/></filters>
|
|
3114
|
-
var values = (
|
|
3420
|
+
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
3421
|
if (values === null || values === void 0 ? void 0 : values.length) {
|
|
3116
3422
|
var filters = values
|
|
3117
3423
|
.map(function (value) { return "<filter val=\"".concat(escapeXmlAttr(value), "\"/>"); })
|
|
@@ -3134,10 +3440,10 @@ var gridRangeToRef = function (range) {
|
|
|
3134
3440
|
return undefined;
|
|
3135
3441
|
}
|
|
3136
3442
|
};
|
|
3137
|
-
var groupEmbedsBySheet = function (embeds) {
|
|
3443
|
+
var groupEmbedsBySheet = function (embeds, chartCount) {
|
|
3138
3444
|
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;
|
|
3445
|
+
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed, index) {
|
|
3446
|
+
var _a, _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
3141
3447
|
if (!((_a = embed.position) === null || _a === void 0 ? void 0 : _a.overlayPosition))
|
|
3142
3448
|
return;
|
|
3143
3449
|
if (((_b = embed.spec) === null || _b === void 0 ? void 0 : _b.type) !== "image")
|
|
@@ -3156,24 +3462,25 @@ var groupEmbedsBySheet = function (embeds) {
|
|
|
3156
3462
|
adjustments: Object.values(adjustments).some(function (v) { return v !== undefined; })
|
|
3157
3463
|
? adjustments
|
|
3158
3464
|
: undefined,
|
|
3159
|
-
order:
|
|
3465
|
+
order: (_h = embed.position.zOrder) !== null && _h !== void 0 ? _h : chartCount + index,
|
|
3160
3466
|
rowIndex: overlay.anchorCell.rowIndex,
|
|
3161
3467
|
columnIndex: overlay.anchorCell.columnIndex,
|
|
3162
|
-
offsetX: (
|
|
3163
|
-
offsetY: (
|
|
3164
|
-
width: (
|
|
3165
|
-
height: (
|
|
3468
|
+
offsetX: (_j = overlay.offsetXPixels) !== null && _j !== void 0 ? _j : 0,
|
|
3469
|
+
offsetY: (_k = overlay.offsetYPixels) !== null && _k !== void 0 ? _k : 0,
|
|
3470
|
+
width: (_l = overlay.widthPixels) !== null && _l !== void 0 ? _l : 120,
|
|
3471
|
+
height: (_m = overlay.heightPixels) !== null && _m !== void 0 ? _m : 120,
|
|
3472
|
+
overlay: overlay,
|
|
3166
3473
|
};
|
|
3167
|
-
var list = (
|
|
3474
|
+
var list = (_o = result.get(embed.position.sheetId)) !== null && _o !== void 0 ? _o : [];
|
|
3168
3475
|
list.push(placement);
|
|
3169
3476
|
result.set(embed.position.sheetId, list);
|
|
3170
3477
|
});
|
|
3171
3478
|
return result;
|
|
3172
3479
|
};
|
|
3173
|
-
var groupTextBoxesBySheet = function (embeds) {
|
|
3480
|
+
var groupTextBoxesBySheet = function (embeds, chartCount) {
|
|
3174
3481
|
var result = new Map();
|
|
3175
|
-
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed,
|
|
3176
|
-
var _a, _b, _d, _e, _f, _g, _h;
|
|
3482
|
+
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed, index) {
|
|
3483
|
+
var _a, _b, _d, _e, _f, _g, _h, _j;
|
|
3177
3484
|
if (!((_a = embed.position) === null || _a === void 0 ? void 0 : _a.overlayPosition))
|
|
3178
3485
|
return;
|
|
3179
3486
|
if (((_b = embed.spec) === null || _b === void 0 ? void 0 : _b.type) !== "textbox")
|
|
@@ -3181,25 +3488,25 @@ var groupTextBoxesBySheet = function (embeds) {
|
|
|
3181
3488
|
var overlay = embed.position.overlayPosition;
|
|
3182
3489
|
var placement = {
|
|
3183
3490
|
textBox: embed,
|
|
3184
|
-
order:
|
|
3491
|
+
order: (_d = embed.position.zOrder) !== null && _d !== void 0 ? _d : chartCount + index,
|
|
3185
3492
|
rowIndex: overlay.anchorCell.rowIndex,
|
|
3186
3493
|
columnIndex: overlay.anchorCell.columnIndex,
|
|
3187
|
-
offsetX: (
|
|
3188
|
-
offsetY: (
|
|
3189
|
-
width: (
|
|
3190
|
-
height: (
|
|
3494
|
+
offsetX: (_e = overlay.offsetXPixels) !== null && _e !== void 0 ? _e : 0,
|
|
3495
|
+
offsetY: (_f = overlay.offsetYPixels) !== null && _f !== void 0 ? _f : 0,
|
|
3496
|
+
width: (_g = overlay.widthPixels) !== null && _g !== void 0 ? _g : 120,
|
|
3497
|
+
height: (_h = overlay.heightPixels) !== null && _h !== void 0 ? _h : 60,
|
|
3191
3498
|
};
|
|
3192
|
-
var list = (
|
|
3499
|
+
var list = (_j = result.get(embed.position.sheetId)) !== null && _j !== void 0 ? _j : [];
|
|
3193
3500
|
list.push(placement);
|
|
3194
3501
|
result.set(embed.position.sheetId, list);
|
|
3195
3502
|
});
|
|
3196
3503
|
return result;
|
|
3197
3504
|
};
|
|
3198
3505
|
/** Form-control embeds (`spec.type === "formControl"`) by sheet, in host order. */
|
|
3199
|
-
var groupFormControlsBySheet = function (embeds) {
|
|
3506
|
+
var groupFormControlsBySheet = function (embeds, chartCount) {
|
|
3200
3507
|
var result = new Map();
|
|
3201
|
-
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed,
|
|
3202
|
-
var _a, _b, _d, _e, _f, _g, _h;
|
|
3508
|
+
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed, index) {
|
|
3509
|
+
var _a, _b, _d, _e, _f, _g, _h, _j;
|
|
3203
3510
|
if (!((_a = embed.position) === null || _a === void 0 ? void 0 : _a.overlayPosition))
|
|
3204
3511
|
return;
|
|
3205
3512
|
if (((_b = embed.spec) === null || _b === void 0 ? void 0 : _b.type) !== "formControl")
|
|
@@ -3207,15 +3514,15 @@ var groupFormControlsBySheet = function (embeds) {
|
|
|
3207
3514
|
var overlay = embed.position.overlayPosition;
|
|
3208
3515
|
var placement = {
|
|
3209
3516
|
shape: embed,
|
|
3210
|
-
order:
|
|
3517
|
+
order: (_d = embed.position.zOrder) !== null && _d !== void 0 ? _d : chartCount + index,
|
|
3211
3518
|
rowIndex: overlay.anchorCell.rowIndex,
|
|
3212
3519
|
columnIndex: overlay.anchorCell.columnIndex,
|
|
3213
|
-
offsetX: (
|
|
3214
|
-
offsetY: (
|
|
3215
|
-
width: (
|
|
3216
|
-
height: (
|
|
3520
|
+
offsetX: (_e = overlay.offsetXPixels) !== null && _e !== void 0 ? _e : 0,
|
|
3521
|
+
offsetY: (_f = overlay.offsetYPixels) !== null && _f !== void 0 ? _f : 0,
|
|
3522
|
+
width: (_g = overlay.widthPixels) !== null && _g !== void 0 ? _g : 120,
|
|
3523
|
+
height: (_h = overlay.heightPixels) !== null && _h !== void 0 ? _h : 20,
|
|
3217
3524
|
};
|
|
3218
|
-
var list = (
|
|
3525
|
+
var list = (_j = result.get(embed.position.sheetId)) !== null && _j !== void 0 ? _j : [];
|
|
3219
3526
|
list.push(placement);
|
|
3220
3527
|
result.set(embed.position.sheetId, list);
|
|
3221
3528
|
});
|
|
@@ -3254,7 +3561,7 @@ var buildSheetFormControls = function (_a) {
|
|
|
3254
3561
|
return total;
|
|
3255
3562
|
};
|
|
3256
3563
|
controls.forEach(function (placement, position) {
|
|
3257
|
-
var _a, _b, _d, _e;
|
|
3564
|
+
var _a, _b, _d, _e, _f, _g, _h;
|
|
3258
3565
|
var spec = placement.shape.spec;
|
|
3259
3566
|
var fromRow = Math.max(0, placement.rowIndex - 1);
|
|
3260
3567
|
var fromColumn = Math.max(0, placement.columnIndex - 1);
|
|
@@ -3264,18 +3571,33 @@ var buildSheetFormControls = function (_a) {
|
|
|
3264
3571
|
var heightPx = Math.max(5, (_e = placement.height) !== null && _e !== void 0 ? _e : 20);
|
|
3265
3572
|
var columnSize = function (index) { return getColumnWidthPx(sheet, index, true); };
|
|
3266
3573
|
var rowSize = function (index) { return getRowHeightPx(sheet, index, true); };
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3574
|
+
// A "Move and size" control keeps its persisted second anchor (#668 C-46)
|
|
3575
|
+
var overlay = (_f = placement.shape.position) === null || _f === void 0 ? void 0 : _f.overlayPosition;
|
|
3576
|
+
var persistedTo = controlAnchorFlags(spec, overlay).sizeWithCells && (overlay === null || overlay === void 0 ? void 0 : overlay.toCell)
|
|
3577
|
+
? overlay.toCell
|
|
3578
|
+
: undefined;
|
|
3579
|
+
var toColumn = persistedTo
|
|
3580
|
+
? {
|
|
3581
|
+
index: Math.max(0, persistedTo.columnIndex - 1),
|
|
3582
|
+
offset: Math.max(0, (_g = overlay === null || overlay === void 0 ? void 0 : overlay.toOffsetXPixels) !== null && _g !== void 0 ? _g : 0),
|
|
3583
|
+
}
|
|
3584
|
+
: resolveAnchorEndpoint({
|
|
3585
|
+
startIndex: fromColumn,
|
|
3586
|
+
startOffset: offsetX,
|
|
3587
|
+
span: widthPx,
|
|
3588
|
+
getSize: columnSize,
|
|
3589
|
+
});
|
|
3590
|
+
var toRow = persistedTo
|
|
3591
|
+
? {
|
|
3592
|
+
index: Math.max(0, persistedTo.rowIndex - 1),
|
|
3593
|
+
offset: Math.max(0, (_h = overlay === null || overlay === void 0 ? void 0 : overlay.toOffsetYPixels) !== null && _h !== void 0 ? _h : 0),
|
|
3594
|
+
}
|
|
3595
|
+
: resolveAnchorEndpoint({
|
|
3596
|
+
startIndex: fromRow,
|
|
3597
|
+
startOffset: offsetY,
|
|
3598
|
+
span: heightPx,
|
|
3599
|
+
getSize: rowSize,
|
|
3600
|
+
});
|
|
3279
3601
|
var partIndex = ctrlProps.parts.length + 1;
|
|
3280
3602
|
var path = "xl/ctrlProps/ctrlProp".concat(partIndex, ".xml");
|
|
3281
3603
|
ctrlProps.parts.push({ path: path, xml: buildCtrlPropXml(spec) });
|
|
@@ -3297,11 +3619,13 @@ var buildSheetFormControls = function (_a) {
|
|
|
3297
3619
|
row: toRow.index,
|
|
3298
3620
|
rowOff: toRow.offset * EMUS_PER_PIXEL,
|
|
3299
3621
|
},
|
|
3622
|
+
overlay: overlay,
|
|
3300
3623
|
}));
|
|
3301
3624
|
vmlShapes.push(buildFormControlVmlShape({
|
|
3302
3625
|
spec: spec,
|
|
3303
3626
|
shapeId: shapeId,
|
|
3304
3627
|
zIndex: zIndexStart + position + 1,
|
|
3628
|
+
overlay: overlay,
|
|
3305
3629
|
geometry: {
|
|
3306
3630
|
leftPx: sumSizes(fromColumn, columnSize) + offsetX,
|
|
3307
3631
|
topPx: sumSizes(fromRow, rowSize) + offsetY,
|
|
@@ -3322,10 +3646,10 @@ var buildSheetFormControls = function (_a) {
|
|
|
3322
3646
|
});
|
|
3323
3647
|
return { controlsXml: buildControlsXml(controlElements), vmlShapes: vmlShapes };
|
|
3324
3648
|
};
|
|
3325
|
-
var groupShapesBySheet = function (embeds) {
|
|
3649
|
+
var groupShapesBySheet = function (embeds, chartCount) {
|
|
3326
3650
|
var result = new Map();
|
|
3327
|
-
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed,
|
|
3328
|
-
var _a, _b, _d, _e, _f, _g, _h;
|
|
3651
|
+
(embeds !== null && embeds !== void 0 ? embeds : []).forEach(function (embed, index) {
|
|
3652
|
+
var _a, _b, _d, _e, _f, _g, _h, _j;
|
|
3329
3653
|
if (!((_a = embed.position) === null || _a === void 0 ? void 0 : _a.overlayPosition))
|
|
3330
3654
|
return;
|
|
3331
3655
|
if (((_b = embed.spec) === null || _b === void 0 ? void 0 : _b.type) !== "shape")
|
|
@@ -3333,55 +3657,45 @@ var groupShapesBySheet = function (embeds) {
|
|
|
3333
3657
|
var overlay = embed.position.overlayPosition;
|
|
3334
3658
|
var placement = {
|
|
3335
3659
|
shape: embed,
|
|
3336
|
-
order:
|
|
3660
|
+
order: (_d = embed.position.zOrder) !== null && _d !== void 0 ? _d : chartCount + index,
|
|
3337
3661
|
rowIndex: overlay.anchorCell.rowIndex,
|
|
3338
3662
|
columnIndex: overlay.anchorCell.columnIndex,
|
|
3339
|
-
offsetX: (
|
|
3340
|
-
offsetY: (
|
|
3341
|
-
width: (
|
|
3342
|
-
height: (
|
|
3663
|
+
offsetX: (_e = overlay.offsetXPixels) !== null && _e !== void 0 ? _e : 0,
|
|
3664
|
+
offsetY: (_f = overlay.offsetYPixels) !== null && _f !== void 0 ? _f : 0,
|
|
3665
|
+
width: (_g = overlay.widthPixels) !== null && _g !== void 0 ? _g : 120,
|
|
3666
|
+
height: (_h = overlay.heightPixels) !== null && _h !== void 0 ? _h : 60,
|
|
3343
3667
|
};
|
|
3344
|
-
var list = (
|
|
3668
|
+
var list = (_j = result.get(embed.position.sheetId)) !== null && _j !== void 0 ? _j : [];
|
|
3345
3669
|
list.push(placement);
|
|
3346
3670
|
result.set(embed.position.sheetId, list);
|
|
3347
3671
|
});
|
|
3348
3672
|
return result;
|
|
3349
3673
|
};
|
|
3350
3674
|
var groupChartsBySheet = function (charts) {
|
|
3351
|
-
var e_39, _a;
|
|
3352
|
-
var _b, _d, _e, _f, _g, _h;
|
|
3353
3675
|
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
|
-
}
|
|
3676
|
+
(charts !== null && charts !== void 0 ? charts : []).forEach(function (chart, index) {
|
|
3677
|
+
var _a, _b, _d, _e, _f, _g, _h;
|
|
3678
|
+
var overlay = (_a = chart.position) === null || _a === void 0 ? void 0 : _a.overlayPosition;
|
|
3679
|
+
if (!overlay)
|
|
3680
|
+
return;
|
|
3681
|
+
var placement = {
|
|
3682
|
+
chart: chart,
|
|
3683
|
+
order: (_b = chart.position.zOrder) !== null && _b !== void 0 ? _b : index,
|
|
3684
|
+
rowIndex: overlay.anchorCell.rowIndex,
|
|
3685
|
+
columnIndex: overlay.anchorCell.columnIndex,
|
|
3686
|
+
offsetX: (_d = overlay.offsetXPixels) !== null && _d !== void 0 ? _d : 0,
|
|
3687
|
+
offsetY: (_e = overlay.offsetYPixels) !== null && _e !== void 0 ? _e : 0,
|
|
3688
|
+
width: (_f = overlay.widthPixels) !== null && _f !== void 0 ? _f : 300,
|
|
3689
|
+
height: (_g = overlay.heightPixels) !== null && _g !== void 0 ? _g : 200,
|
|
3690
|
+
};
|
|
3691
|
+
var list = (_h = result.get(chart.position.sheetId)) !== null && _h !== void 0 ? _h : [];
|
|
3692
|
+
list.push(placement);
|
|
3693
|
+
result.set(chart.position.sheetId, list);
|
|
3694
|
+
});
|
|
3381
3695
|
return result;
|
|
3382
3696
|
};
|
|
3383
3697
|
var groupSlicersBySheet = function (slicers) {
|
|
3384
|
-
var
|
|
3698
|
+
var e_41, _a;
|
|
3385
3699
|
var _b, _d, _e, _f, _g, _h;
|
|
3386
3700
|
var result = new Map();
|
|
3387
3701
|
try {
|
|
@@ -3404,17 +3718,17 @@ var groupSlicersBySheet = function (slicers) {
|
|
|
3404
3718
|
result.set(slicer.position.sheetId, list);
|
|
3405
3719
|
}
|
|
3406
3720
|
}
|
|
3407
|
-
catch (
|
|
3721
|
+
catch (e_41_1) { e_41 = { error: e_41_1 }; }
|
|
3408
3722
|
finally {
|
|
3409
3723
|
try {
|
|
3410
3724
|
if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
|
|
3411
3725
|
}
|
|
3412
|
-
finally { if (
|
|
3726
|
+
finally { if (e_41) throw e_41.error; }
|
|
3413
3727
|
}
|
|
3414
3728
|
return result;
|
|
3415
3729
|
};
|
|
3416
3730
|
var buildConditionalFormattingXml = function (_a) {
|
|
3417
|
-
var
|
|
3731
|
+
var e_42, _b;
|
|
3418
3732
|
var _d, _e, _f;
|
|
3419
3733
|
var conditionalFormats = _a.conditionalFormats, sheetId = _a.sheetId, styleBuilder = _a.styleBuilder;
|
|
3420
3734
|
if (!(conditionalFormats === null || conditionalFormats === void 0 ? void 0 : conditionalFormats.length)) {
|
|
@@ -3478,12 +3792,12 @@ var buildConditionalFormattingXml = function (_a) {
|
|
|
3478
3792
|
parts.push("<conditionalFormatting sqref=\"".concat(sqrefParts.join(" "), "\">").concat(ruleXmlEntries.join(""), "</conditionalFormatting>"));
|
|
3479
3793
|
}
|
|
3480
3794
|
}
|
|
3481
|
-
catch (
|
|
3795
|
+
catch (e_42_1) { e_42 = { error: e_42_1 }; }
|
|
3482
3796
|
finally {
|
|
3483
3797
|
try {
|
|
3484
3798
|
if (orderedRules_1_1 && !orderedRules_1_1.done && (_b = orderedRules_1.return)) _b.call(orderedRules_1);
|
|
3485
3799
|
}
|
|
3486
|
-
finally { if (
|
|
3800
|
+
finally { if (e_42) throw e_42.error; }
|
|
3487
3801
|
}
|
|
3488
3802
|
return parts.join("");
|
|
3489
3803
|
};
|
|
@@ -3979,9 +4293,9 @@ var buildConditionalFormattingRuleXml = function (_a) {
|
|
|
3979
4293
|
return rules.length ? rules : undefined;
|
|
3980
4294
|
};
|
|
3981
4295
|
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;
|
|
4296
|
+
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;
|
|
4297
|
+
var e_44, _d, e_45, _e, e_46, _f, e_47, _g, e_43, _h, e_48, _j;
|
|
4298
|
+
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
4299
|
return __generator(this, function (_m) {
|
|
3986
4300
|
switch (_m.label) {
|
|
3987
4301
|
case 0:
|
|
@@ -4001,6 +4315,10 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4001
4315
|
frameId = 1;
|
|
4002
4316
|
chartEntries = [];
|
|
4003
4317
|
chartExEntries = [];
|
|
4318
|
+
orderedAnchors = [];
|
|
4319
|
+
orderOf = function (order) {
|
|
4320
|
+
return order !== null && order !== void 0 ? order : Number.MAX_SAFE_INTEGER;
|
|
4321
|
+
};
|
|
4004
4322
|
try {
|
|
4005
4323
|
for (charts_1 = __values(charts), charts_1_1 = charts_1.next(); !charts_1_1.done; charts_1_1 = charts_1.next()) {
|
|
4006
4324
|
placement = charts_1_1.value;
|
|
@@ -4009,7 +4327,16 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4009
4327
|
if (!chartExXml)
|
|
4010
4328
|
continue;
|
|
4011
4329
|
relId_1 = relationships.add(CHART_EX_REL_TYPE, "../charts/chartEx".concat(chartExIndex, ".xml"));
|
|
4012
|
-
|
|
4330
|
+
orderedAnchors.push({
|
|
4331
|
+
order: placement.order,
|
|
4332
|
+
xml: createChartAnchor({
|
|
4333
|
+
sheet: sheet,
|
|
4334
|
+
placement: placement,
|
|
4335
|
+
relId: relId_1,
|
|
4336
|
+
frameId: frameId,
|
|
4337
|
+
chartEx: true,
|
|
4338
|
+
}),
|
|
4339
|
+
});
|
|
4013
4340
|
chartExEntries.push({
|
|
4014
4341
|
path: "xl/charts/chartEx".concat(chartExIndex, ".xml"),
|
|
4015
4342
|
xml: chartExXml,
|
|
@@ -4018,16 +4345,19 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4018
4345
|
frameId += 1;
|
|
4019
4346
|
continue;
|
|
4020
4347
|
}
|
|
4021
|
-
chartXml = buildChartXml(placement.chart, sheetNameById);
|
|
4348
|
+
chartXml = buildChartXml(placement.chart, sheetNameById, resolvePivotSourceName);
|
|
4022
4349
|
if (!chartXml)
|
|
4023
4350
|
continue;
|
|
4024
4351
|
relId = relationships.add(CHART_REL_TYPE, "../charts/chart".concat(chartIndex, ".xml"));
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4352
|
+
orderedAnchors.push({
|
|
4353
|
+
order: placement.order,
|
|
4354
|
+
xml: createChartAnchor({
|
|
4355
|
+
sheet: sheet,
|
|
4356
|
+
placement: placement,
|
|
4357
|
+
relId: relId,
|
|
4358
|
+
frameId: frameId,
|
|
4359
|
+
}),
|
|
4360
|
+
});
|
|
4031
4361
|
chartEntries.push({
|
|
4032
4362
|
path: "xl/charts/chart".concat(chartIndex, ".xml"),
|
|
4033
4363
|
xml: chartXml,
|
|
@@ -4036,12 +4366,12 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4036
4366
|
frameId += 1;
|
|
4037
4367
|
}
|
|
4038
4368
|
}
|
|
4039
|
-
catch (
|
|
4369
|
+
catch (e_44_1) { e_44 = { error: e_44_1 }; }
|
|
4040
4370
|
finally {
|
|
4041
4371
|
try {
|
|
4042
4372
|
if (charts_1_1 && !charts_1_1.done && (_d = charts_1.return)) _d.call(charts_1);
|
|
4043
4373
|
}
|
|
4044
|
-
finally { if (
|
|
4374
|
+
finally { if (e_44) throw e_44.error; }
|
|
4045
4375
|
}
|
|
4046
4376
|
try {
|
|
4047
4377
|
for (slicers_1 = __values(slicers), slicers_1_1 = slicers_1.next(); !slicers_1_1.done; slicers_1_1 = slicers_1.next()) {
|
|
@@ -4054,21 +4384,17 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4054
4384
|
frameId += 1;
|
|
4055
4385
|
}
|
|
4056
4386
|
}
|
|
4057
|
-
catch (
|
|
4387
|
+
catch (e_45_1) { e_45 = { error: e_45_1 }; }
|
|
4058
4388
|
finally {
|
|
4059
4389
|
try {
|
|
4060
4390
|
if (slicers_1_1 && !slicers_1_1.done && (_e = slicers_1.return)) _e.call(slicers_1);
|
|
4061
4391
|
}
|
|
4062
|
-
finally { if (
|
|
4392
|
+
finally { if (e_45) throw e_45.error; }
|
|
4063
4393
|
}
|
|
4064
|
-
embedAnchors = [];
|
|
4065
|
-
orderOf = function (order) {
|
|
4066
|
-
return order !== null && order !== void 0 ? order : Number.MAX_SAFE_INTEGER;
|
|
4067
|
-
};
|
|
4068
4394
|
try {
|
|
4069
4395
|
for (textBoxes_1 = __values(textBoxes), textBoxes_1_1 = textBoxes_1.next(); !textBoxes_1_1.done; textBoxes_1_1 = textBoxes_1.next()) {
|
|
4070
4396
|
placement = textBoxes_1_1.value;
|
|
4071
|
-
|
|
4397
|
+
orderedAnchors.push({
|
|
4072
4398
|
order: orderOf(placement.order),
|
|
4073
4399
|
xml: createTextBoxAnchor({
|
|
4074
4400
|
sheet: sheet,
|
|
@@ -4079,17 +4405,17 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4079
4405
|
frameId += 1;
|
|
4080
4406
|
}
|
|
4081
4407
|
}
|
|
4082
|
-
catch (
|
|
4408
|
+
catch (e_46_1) { e_46 = { error: e_46_1 }; }
|
|
4083
4409
|
finally {
|
|
4084
4410
|
try {
|
|
4085
4411
|
if (textBoxes_1_1 && !textBoxes_1_1.done && (_f = textBoxes_1.return)) _f.call(textBoxes_1);
|
|
4086
4412
|
}
|
|
4087
|
-
finally { if (
|
|
4413
|
+
finally { if (e_46) throw e_46.error; }
|
|
4088
4414
|
}
|
|
4089
4415
|
try {
|
|
4090
4416
|
for (shapes_1 = __values(shapes), shapes_1_1 = shapes_1.next(); !shapes_1_1.done; shapes_1_1 = shapes_1.next()) {
|
|
4091
4417
|
placement = shapes_1_1.value;
|
|
4092
|
-
|
|
4418
|
+
orderedAnchors.push({
|
|
4093
4419
|
order: orderOf(placement.order),
|
|
4094
4420
|
xml: createShapeAnchor({
|
|
4095
4421
|
sheet: sheet,
|
|
@@ -4100,12 +4426,12 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4100
4426
|
frameId += 1;
|
|
4101
4427
|
}
|
|
4102
4428
|
}
|
|
4103
|
-
catch (
|
|
4429
|
+
catch (e_47_1) { e_47 = { error: e_47_1 }; }
|
|
4104
4430
|
finally {
|
|
4105
4431
|
try {
|
|
4106
4432
|
if (shapes_1_1 && !shapes_1_1.done && (_g = shapes_1.return)) _g.call(shapes_1);
|
|
4107
4433
|
}
|
|
4108
|
-
finally { if (
|
|
4434
|
+
finally { if (e_47) throw e_47.error; }
|
|
4109
4435
|
}
|
|
4110
4436
|
_m.label = 1;
|
|
4111
4437
|
case 1:
|
|
@@ -4130,7 +4456,7 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4130
4456
|
extension: buffer.extension,
|
|
4131
4457
|
});
|
|
4132
4458
|
relId = relationships.add(IMAGE_REL_TYPE, "../media/image".concat(imageIndex, ".").concat(buffer.extension));
|
|
4133
|
-
|
|
4459
|
+
orderedAnchors.push({
|
|
4134
4460
|
order: orderOf(placement.order),
|
|
4135
4461
|
xml: createTwoCellAnchor({
|
|
4136
4462
|
sheet: sheet,
|
|
@@ -4147,29 +4473,29 @@ var buildDrawingParts = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
4147
4473
|
return [3 /*break*/, 2];
|
|
4148
4474
|
case 5: return [3 /*break*/, 8];
|
|
4149
4475
|
case 6:
|
|
4150
|
-
|
|
4151
|
-
|
|
4476
|
+
e_43_1 = _m.sent();
|
|
4477
|
+
e_43 = { error: e_43_1 };
|
|
4152
4478
|
return [3 /*break*/, 8];
|
|
4153
4479
|
case 7:
|
|
4154
4480
|
try {
|
|
4155
4481
|
if (placements_1_1 && !placements_1_1.done && (_h = placements_1.return)) _h.call(placements_1);
|
|
4156
4482
|
}
|
|
4157
|
-
finally { if (
|
|
4483
|
+
finally { if (e_43) throw e_43.error; }
|
|
4158
4484
|
return [7 /*endfinally*/];
|
|
4159
4485
|
case 8:
|
|
4160
|
-
|
|
4486
|
+
orderedAnchors.sort(function (a, b) { return a.order - b.order; });
|
|
4161
4487
|
try {
|
|
4162
|
-
for (
|
|
4163
|
-
entry =
|
|
4488
|
+
for (orderedAnchors_1 = __values(orderedAnchors), orderedAnchors_1_1 = orderedAnchors_1.next(); !orderedAnchors_1_1.done; orderedAnchors_1_1 = orderedAnchors_1.next()) {
|
|
4489
|
+
entry = orderedAnchors_1_1.value;
|
|
4164
4490
|
anchors.push(entry.xml);
|
|
4165
4491
|
}
|
|
4166
4492
|
}
|
|
4167
|
-
catch (
|
|
4493
|
+
catch (e_48_1) { e_48 = { error: e_48_1 }; }
|
|
4168
4494
|
finally {
|
|
4169
4495
|
try {
|
|
4170
|
-
if (
|
|
4496
|
+
if (orderedAnchors_1_1 && !orderedAnchors_1_1.done && (_j = orderedAnchors_1.return)) _j.call(orderedAnchors_1);
|
|
4171
4497
|
}
|
|
4172
|
-
finally { if (
|
|
4498
|
+
finally { if (e_48) throw e_48.error; }
|
|
4173
4499
|
}
|
|
4174
4500
|
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
4501
|
return [2 /*return*/, {
|
|
@@ -4196,25 +4522,21 @@ var createTwoCellAnchor = function (_a) {
|
|
|
4196
4522
|
var defaultHeight = placement.kind === "cell" ? getRowHeightPx(sheet, fromRow) : 120;
|
|
4197
4523
|
var widthPx = Math.max(5, (_e = placement.width) !== null && _e !== void 0 ? _e : defaultWidth);
|
|
4198
4524
|
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
4525
|
var _g = buildPictureAdjustmentsXml(placement.adjustments), blipChildren = _g.blipChildren, srcRectXml = _g.srcRectXml;
|
|
4214
4526
|
var blipXml = blipChildren
|
|
4215
4527
|
? "<a:blip r:embed=\"".concat(relId, "\">").concat(blipChildren, "</a:blip>")
|
|
4216
4528
|
: "<a:blip r:embed=\"".concat(relId, "\"/>");
|
|
4217
|
-
return
|
|
4529
|
+
return buildDrawingAnchorXml({
|
|
4530
|
+
sheet: sheet,
|
|
4531
|
+
overlay: placement.overlay,
|
|
4532
|
+
fromRow: fromRow,
|
|
4533
|
+
fromColumn: fromColumn,
|
|
4534
|
+
offsetX: offsetX,
|
|
4535
|
+
offsetY: offsetY,
|
|
4536
|
+
widthPx: widthPx,
|
|
4537
|
+
heightPx: heightPx,
|
|
4538
|
+
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>"),
|
|
4539
|
+
});
|
|
4218
4540
|
};
|
|
4219
4541
|
/** Fraction (0…1) → DrawingML per-mille percent (100000 = 100%). */
|
|
4220
4542
|
var fractionToPct = function (value) {
|
|
@@ -4261,40 +4583,40 @@ var buildPictureAdjustmentsXml = function (adjustments) {
|
|
|
4261
4583
|
return { blipChildren: blipChildren, srcRectXml: srcRectXml };
|
|
4262
4584
|
};
|
|
4263
4585
|
var createChartAnchor = function (_a) {
|
|
4264
|
-
var _b, _d, _e, _f;
|
|
4265
|
-
var placement = _a.placement, relId = _a.relId, frameId = _a.frameId, sheet = _a.sheet,
|
|
4586
|
+
var _b, _d, _e, _f, _g;
|
|
4587
|
+
var placement = _a.placement, relId = _a.relId, frameId = _a.frameId, sheet = _a.sheet, _h = _a.chartEx, chartEx = _h === void 0 ? false : _h;
|
|
4266
4588
|
var fromRow = Math.max(0, placement.rowIndex - 1);
|
|
4267
4589
|
var fromColumn = Math.max(0, placement.columnIndex - 1);
|
|
4268
4590
|
var offsetX = Math.max(0, (_b = placement.offsetX) !== null && _b !== void 0 ? _b : 0);
|
|
4269
4591
|
var offsetY = Math.max(0, (_d = placement.offsetY) !== null && _d !== void 0 ? _d : 0);
|
|
4270
4592
|
var widthPx = Math.max(5, (_e = placement.width) !== null && _e !== void 0 ? _e : 300);
|
|
4271
4593
|
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({
|
|
4594
|
+
var body = chartEx
|
|
4595
|
+
? buildChartExGraphicFrameXml({
|
|
4288
4596
|
relId: relId,
|
|
4289
4597
|
frameId: frameId,
|
|
4290
4598
|
widthEmu: Math.round(widthPx * EMUS_PER_PIXEL),
|
|
4291
4599
|
heightEmu: Math.round(heightPx * EMUS_PER_PIXEL),
|
|
4292
|
-
})
|
|
4293
|
-
|
|
4294
|
-
|
|
4600
|
+
})
|
|
4601
|
+
: "<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>");
|
|
4602
|
+
var overlay = (_g = placement.chart.position) === null || _g === void 0 ? void 0 : _g.overlayPosition;
|
|
4603
|
+
return buildDrawingAnchorXml({
|
|
4604
|
+
sheet: sheet,
|
|
4605
|
+
// A chartsheet has no cells to anchor to: Excel only reads an
|
|
4606
|
+
// `absoluteAnchor` there, whatever placement the chart carries.
|
|
4607
|
+
overlay: sheet.type === "chartsheet" && overlay
|
|
4608
|
+
? __assign(__assign({}, overlay), { placement: "absolute" }) : overlay,
|
|
4609
|
+
fromRow: fromRow,
|
|
4610
|
+
fromColumn: fromColumn,
|
|
4611
|
+
offsetX: offsetX,
|
|
4612
|
+
offsetY: offsetY,
|
|
4613
|
+
widthPx: widthPx,
|
|
4614
|
+
heightPx: heightPx,
|
|
4615
|
+
body: body,
|
|
4616
|
+
});
|
|
4295
4617
|
};
|
|
4296
4618
|
var createSlicerAnchor = function (_a) {
|
|
4297
|
-
var _b, _d, _e, _f;
|
|
4619
|
+
var _b, _d, _e, _f, _g, _h, _j;
|
|
4298
4620
|
var placement = _a.placement, frameId = _a.frameId, sheet = _a.sheet;
|
|
4299
4621
|
var fromRow = Math.max(0, placement.rowIndex - 1);
|
|
4300
4622
|
var fromColumn = Math.max(0, placement.columnIndex - 1);
|
|
@@ -4302,24 +4624,45 @@ var createSlicerAnchor = function (_a) {
|
|
|
4302
4624
|
var offsetY = Math.max(0, (_d = placement.offsetY) !== null && _d !== void 0 ? _d : 0);
|
|
4303
4625
|
var widthPx = Math.max(50, (_e = placement.width) !== null && _e !== void 0 ? _e : 200);
|
|
4304
4626
|
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
|
-
|
|
4627
|
+
// Excel keeps a slicer in a `twoCellAnchor` whatever its placement and
|
|
4628
|
+
// spells the other two modes as `editAs` (#668 C-46); a "Move and size"
|
|
4629
|
+
// slicer keeps its persisted second anchor.
|
|
4630
|
+
var overlay = placement.overlay;
|
|
4631
|
+
var mode = (_g = overlay === null || overlay === void 0 ? void 0 : overlay.placement) !== null && _g !== void 0 ? _g : "moveAndSize";
|
|
4632
|
+
var persistedTo = mode === "moveAndSize" ? overlay === null || overlay === void 0 ? void 0 : overlay.toCell : undefined;
|
|
4633
|
+
var editAs = mode === "moveOnly"
|
|
4634
|
+
? ' editAs="oneCell"'
|
|
4635
|
+
: mode === "absolute"
|
|
4636
|
+
? ' editAs="absolute"'
|
|
4637
|
+
: "";
|
|
4638
|
+
var toColumn = persistedTo
|
|
4639
|
+
? {
|
|
4640
|
+
index: Math.max(0, persistedTo.columnIndex - 1),
|
|
4641
|
+
offset: Math.max(0, (_h = overlay === null || overlay === void 0 ? void 0 : overlay.toOffsetXPixels) !== null && _h !== void 0 ? _h : 0),
|
|
4642
|
+
}
|
|
4643
|
+
: resolveAnchorEndpoint({
|
|
4644
|
+
startIndex: fromColumn,
|
|
4645
|
+
startOffset: offsetX,
|
|
4646
|
+
span: widthPx,
|
|
4647
|
+
getSize: function (index) { return getColumnWidthPx(sheet, index, true); },
|
|
4648
|
+
});
|
|
4649
|
+
var toRow = persistedTo
|
|
4650
|
+
? {
|
|
4651
|
+
index: Math.max(0, persistedTo.rowIndex - 1),
|
|
4652
|
+
offset: Math.max(0, (_j = overlay === null || overlay === void 0 ? void 0 : overlay.toOffsetYPixels) !== null && _j !== void 0 ? _j : 0),
|
|
4653
|
+
}
|
|
4654
|
+
: resolveAnchorEndpoint({
|
|
4655
|
+
startIndex: fromRow,
|
|
4656
|
+
startOffset: offsetY,
|
|
4657
|
+
span: heightPx,
|
|
4658
|
+
getSize: function (index) { return getRowHeightPx(sheet, index, true); },
|
|
4659
|
+
});
|
|
4317
4660
|
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
4661
|
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
|
|
4662
|
+
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
4663
|
};
|
|
4321
4664
|
var createTextBoxAnchor = function (_a) {
|
|
4322
|
-
var _b, _d, _e, _f;
|
|
4665
|
+
var _b, _d, _e, _f, _g;
|
|
4323
4666
|
var placement = _a.placement, frameId = _a.frameId, sheet = _a.sheet;
|
|
4324
4667
|
var fromRow = Math.max(0, placement.rowIndex - 1);
|
|
4325
4668
|
var fromColumn = Math.max(0, placement.columnIndex - 1);
|
|
@@ -4327,24 +4670,20 @@ var createTextBoxAnchor = function (_a) {
|
|
|
4327
4670
|
var offsetY = Math.max(0, (_d = placement.offsetY) !== null && _d !== void 0 ? _d : 0);
|
|
4328
4671
|
var widthPx = Math.max(50, (_e = placement.width) !== null && _e !== void 0 ? _e : 200);
|
|
4329
4672
|
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
4673
|
var spec = placement.textBox.spec;
|
|
4345
4674
|
var textBodyXml = buildTextBodyXml(spec);
|
|
4346
4675
|
var shapePropertiesXml = buildShapePropertiesXml(spec, widthPx, heightPx);
|
|
4347
|
-
return
|
|
4676
|
+
return buildDrawingAnchorXml({
|
|
4677
|
+
sheet: sheet,
|
|
4678
|
+
overlay: (_g = placement.textBox.position) === null || _g === void 0 ? void 0 : _g.overlayPosition,
|
|
4679
|
+
fromRow: fromRow,
|
|
4680
|
+
fromColumn: fromColumn,
|
|
4681
|
+
offsetX: offsetX,
|
|
4682
|
+
offsetY: offsetY,
|
|
4683
|
+
widthPx: widthPx,
|
|
4684
|
+
heightPx: heightPx,
|
|
4685
|
+
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>"),
|
|
4686
|
+
});
|
|
4348
4687
|
};
|
|
4349
4688
|
/** ColorIndex slots → canonical DrawingML scheme names (inverse of the importer's map). */
|
|
4350
4689
|
var THEME_INDEX_TO_SCHEME = [
|
|
@@ -4462,7 +4801,7 @@ var buildShapeStyleRefXml = function (tag, ref) {
|
|
|
4462
4801
|
};
|
|
4463
4802
|
/** Export an `EmbedShapeSpec` embed as an `<xdr:sp>` two-cell anchor. */
|
|
4464
4803
|
var createShapeAnchor = function (_a) {
|
|
4465
|
-
var _b, _d, _e, _f, _g, _h, _j, _k;
|
|
4804
|
+
var _b, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
4466
4805
|
var placement = _a.placement, frameId = _a.frameId, sheet = _a.sheet;
|
|
4467
4806
|
var spec = placement.shape.spec;
|
|
4468
4807
|
var fromRow = Math.max(0, placement.rowIndex - 1);
|
|
@@ -4471,20 +4810,6 @@ var createShapeAnchor = function (_a) {
|
|
|
4471
4810
|
var offsetY = Math.max(0, (_d = placement.offsetY) !== null && _d !== void 0 ? _d : 0);
|
|
4472
4811
|
var widthPx = Math.max(10, (_e = placement.width) !== null && _e !== void 0 ? _e : 120);
|
|
4473
4812
|
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
4813
|
var xfrmAttrs = [
|
|
4489
4814
|
placement.shape.rotation
|
|
4490
4815
|
? " rot=\"".concat(Math.round(placement.shape.rotation * 60000), "\"")
|
|
@@ -4514,7 +4839,17 @@ var createShapeAnchor = function (_a) {
|
|
|
4514
4839
|
? buildTextBodyXml(spec.textBody)
|
|
4515
4840
|
: "<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
4841
|
var name = escapeXmlAttr((_k = spec.name) !== null && _k !== void 0 ? _k : "Shape ".concat(frameId));
|
|
4517
|
-
return
|
|
4842
|
+
return buildDrawingAnchorXml({
|
|
4843
|
+
sheet: sheet,
|
|
4844
|
+
overlay: (_l = placement.shape.position) === null || _l === void 0 ? void 0 : _l.overlayPosition,
|
|
4845
|
+
fromRow: fromRow,
|
|
4846
|
+
fromColumn: fromColumn,
|
|
4847
|
+
offsetX: offsetX,
|
|
4848
|
+
offsetY: offsetY,
|
|
4849
|
+
widthPx: widthPx,
|
|
4850
|
+
heightPx: heightPx,
|
|
4851
|
+
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>"),
|
|
4852
|
+
});
|
|
4518
4853
|
};
|
|
4519
4854
|
var buildTextWithTabs = function (text, rPrXml) {
|
|
4520
4855
|
var parts = text.split("\t");
|
|
@@ -4531,7 +4866,7 @@ var buildTextWithTabs = function (text, rPrXml) {
|
|
|
4531
4866
|
.join("");
|
|
4532
4867
|
};
|
|
4533
4868
|
var buildTextBodyXml = function (spec) {
|
|
4534
|
-
var
|
|
4869
|
+
var e_49, _a;
|
|
4535
4870
|
var richText = spec.richText || [];
|
|
4536
4871
|
var plainText = spec.text || "";
|
|
4537
4872
|
// Build vertical alignment and wrap attributes
|
|
@@ -4572,12 +4907,12 @@ var buildTextBodyXml = function (spec) {
|
|
|
4572
4907
|
}
|
|
4573
4908
|
}
|
|
4574
4909
|
}
|
|
4575
|
-
catch (
|
|
4910
|
+
catch (e_49_1) { e_49 = { error: e_49_1 }; }
|
|
4576
4911
|
finally {
|
|
4577
4912
|
try {
|
|
4578
4913
|
if (richText_1_1 && !richText_1_1.done && (_a = richText_1.return)) _a.call(richText_1);
|
|
4579
4914
|
}
|
|
4580
|
-
finally { if (
|
|
4915
|
+
finally { if (e_49) throw e_49.error; }
|
|
4581
4916
|
}
|
|
4582
4917
|
paragraphsXml = paragraphs
|
|
4583
4918
|
.filter(function (runs) { return runs.length > 0; })
|
|
@@ -4775,6 +5110,62 @@ var buildShapePropertiesXml = function (spec, widthPx, heightPx) {
|
|
|
4775
5110
|
}
|
|
4776
5111
|
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
5112
|
};
|
|
5113
|
+
/**
|
|
5114
|
+
* Wrap a drawing object's body in the anchor its placement mode calls for
|
|
5115
|
+
* (#668 C-06). "Move and size with cells" (Excel's default) is a
|
|
5116
|
+
* `twoCellAnchor` whose `to` is the object's persisted second anchor — or,
|
|
5117
|
+
* for an object that has none yet, the cell its pixel extent reaches over
|
|
5118
|
+
* this sheet's row / column sizes. "Move but don't size" is a
|
|
5119
|
+
* `oneCellAnchor` (`from` + `ext`); "Don't move or size" is an
|
|
5120
|
+
* `absoluteAnchor` (`pos` + `ext`). The importers read all three back into
|
|
5121
|
+
* the same placement.
|
|
5122
|
+
*/
|
|
5123
|
+
var buildDrawingAnchorXml = function (_a) {
|
|
5124
|
+
var _b, _d, _e;
|
|
5125
|
+
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;
|
|
5126
|
+
var emu = function (px) { return Math.round(px * EMUS_PER_PIXEL); };
|
|
5127
|
+
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>");
|
|
5128
|
+
var extXml = "<xdr:ext cx=\"".concat(emu(widthPx), "\" cy=\"").concat(emu(heightPx), "\"/>");
|
|
5129
|
+
var placement = (_b = overlay === null || overlay === void 0 ? void 0 : overlay.placement) !== null && _b !== void 0 ? _b : "moveAndSize";
|
|
5130
|
+
if (placement === "moveOnly") {
|
|
5131
|
+
return "<xdr:oneCellAnchor>".concat(fromXml).concat(extXml).concat(body, "<xdr:clientData/></xdr:oneCellAnchor>");
|
|
5132
|
+
}
|
|
5133
|
+
if (placement === "absolute") {
|
|
5134
|
+
var x = offsetX;
|
|
5135
|
+
for (var index = 0; index < fromColumn; index++) {
|
|
5136
|
+
x += getColumnWidthPx(sheet, index, true);
|
|
5137
|
+
}
|
|
5138
|
+
var y = offsetY;
|
|
5139
|
+
for (var index = 0; index < fromRow; index++) {
|
|
5140
|
+
y += getRowHeightPx(sheet, index, true);
|
|
5141
|
+
}
|
|
5142
|
+
return "<xdr:absoluteAnchor><xdr:pos x=\"".concat(emu(x), "\" y=\"").concat(emu(y), "\"/>").concat(extXml).concat(body, "<xdr:clientData/></xdr:absoluteAnchor>");
|
|
5143
|
+
}
|
|
5144
|
+
var toColumn = (overlay === null || overlay === void 0 ? void 0 : overlay.toCell)
|
|
5145
|
+
? {
|
|
5146
|
+
index: Math.max(0, overlay.toCell.columnIndex - 1),
|
|
5147
|
+
offset: Math.max(0, (_d = overlay.toOffsetXPixels) !== null && _d !== void 0 ? _d : 0),
|
|
5148
|
+
}
|
|
5149
|
+
: resolveAnchorEndpoint({
|
|
5150
|
+
startIndex: fromColumn,
|
|
5151
|
+
startOffset: offsetX,
|
|
5152
|
+
span: widthPx,
|
|
5153
|
+
getSize: function (index) { return getColumnWidthPx(sheet, index, true); },
|
|
5154
|
+
});
|
|
5155
|
+
var toRow = (overlay === null || overlay === void 0 ? void 0 : overlay.toCell)
|
|
5156
|
+
? {
|
|
5157
|
+
index: Math.max(0, overlay.toCell.rowIndex - 1),
|
|
5158
|
+
offset: Math.max(0, (_e = overlay.toOffsetYPixels) !== null && _e !== void 0 ? _e : 0),
|
|
5159
|
+
}
|
|
5160
|
+
: resolveAnchorEndpoint({
|
|
5161
|
+
startIndex: fromRow,
|
|
5162
|
+
startOffset: offsetY,
|
|
5163
|
+
span: heightPx,
|
|
5164
|
+
getSize: function (index) { return getRowHeightPx(sheet, index, true); },
|
|
5165
|
+
});
|
|
5166
|
+
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>");
|
|
5167
|
+
return "<xdr:twoCellAnchor>".concat(fromXml).concat(toXml).concat(body, "<xdr:clientData/></xdr:twoCellAnchor>");
|
|
5168
|
+
};
|
|
4778
5169
|
var resolveAnchorEndpoint = function (_a) {
|
|
4779
5170
|
var startIndex = _a.startIndex, startOffset = _a.startOffset, span = _a.span, getSize = _a.getSize;
|
|
4780
5171
|
var index = startIndex;
|
|
@@ -5021,7 +5412,7 @@ var buildWorkbookXml = function (sheets, sheetRelIds, sheetNames, namedRanges, i
|
|
|
5021
5412
|
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
5413
|
};
|
|
5023
5414
|
var buildDefinedNamesXml = function (namedRanges, sheetNameById, printScopes) {
|
|
5024
|
-
var
|
|
5415
|
+
var e_50, _a, e_51, _b;
|
|
5025
5416
|
var _d, _e, _f;
|
|
5026
5417
|
if (printScopes === void 0) { printScopes = []; }
|
|
5027
5418
|
var entries = [];
|
|
@@ -5051,12 +5442,12 @@ var buildDefinedNamesXml = function (namedRanges, sheetNameById, printScopes) {
|
|
|
5051
5442
|
], false));
|
|
5052
5443
|
}
|
|
5053
5444
|
}
|
|
5054
|
-
catch (
|
|
5445
|
+
catch (e_50_1) { e_50 = { error: e_50_1 }; }
|
|
5055
5446
|
finally {
|
|
5056
5447
|
try {
|
|
5057
5448
|
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
|
|
5058
5449
|
}
|
|
5059
|
-
finally { if (
|
|
5450
|
+
finally { if (e_50) throw e_50.error; }
|
|
5060
5451
|
}
|
|
5061
5452
|
printScopes.forEach(function (_a, index) {
|
|
5062
5453
|
var _b;
|
|
@@ -5104,12 +5495,12 @@ var buildDefinedNamesXml = function (namedRanges, sheetNameById, printScopes) {
|
|
|
5104
5495
|
entries.push("<definedName name=\"".concat(escapeXmlAttr(namedRange.name), "\"").concat(hiddenAttr, ">").concat(escapeXmlText(expression), "</definedName>"));
|
|
5105
5496
|
}
|
|
5106
5497
|
}
|
|
5107
|
-
catch (
|
|
5498
|
+
catch (e_51_1) { e_51 = { error: e_51_1 }; }
|
|
5108
5499
|
finally {
|
|
5109
5500
|
try {
|
|
5110
5501
|
if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
|
|
5111
5502
|
}
|
|
5112
|
-
finally { if (
|
|
5503
|
+
finally { if (e_51) throw e_51.error; }
|
|
5113
5504
|
}
|
|
5114
5505
|
if (!entries.length)
|
|
5115
5506
|
return "";
|
|
@@ -5142,7 +5533,9 @@ var buildWorkbookSlicerCachesXml = function (slicerCacheRelIds) {
|
|
|
5142
5533
|
.join("");
|
|
5143
5534
|
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
5535
|
};
|
|
5145
|
-
var buildWorkbookRelationships = function (
|
|
5536
|
+
var buildWorkbookRelationships = function (
|
|
5537
|
+
/** One entry per sheet in `<sheets>` order; `target` is relative to `xl/`. */
|
|
5538
|
+
sheetParts, slicerCacheCount, externalLinkCount, pivotCacheCount, hasPersons) {
|
|
5146
5539
|
if (slicerCacheCount === void 0) { slicerCacheCount = 0; }
|
|
5147
5540
|
if (externalLinkCount === void 0) { externalLinkCount = 0; }
|
|
5148
5541
|
if (pivotCacheCount === void 0) { pivotCacheCount = 0; }
|
|
@@ -5150,11 +5543,12 @@ var buildWorkbookRelationships = function (sheetCount, slicerCacheCount, externa
|
|
|
5150
5543
|
var relationships = [];
|
|
5151
5544
|
var sheetRelIds = [];
|
|
5152
5545
|
var slicerCacheRelIds = [];
|
|
5153
|
-
|
|
5546
|
+
var sheetCount = sheetParts.length;
|
|
5547
|
+
sheetParts.forEach(function (part, i) {
|
|
5154
5548
|
var relId = "rId".concat(i + 1);
|
|
5155
5549
|
sheetRelIds.push(relId);
|
|
5156
|
-
relationships.push("<Relationship Id=\"".concat(relId, "\" Type=\"").concat(REL_NS, "/worksheet\" Target=\"
|
|
5157
|
-
}
|
|
5550
|
+
relationships.push("<Relationship Id=\"".concat(relId, "\" Type=\"").concat(REL_NS, "/").concat(part.chartsheet ? "chartsheet" : "worksheet", "\" Target=\"").concat(part.target, "\"/>"));
|
|
5551
|
+
});
|
|
5158
5552
|
var stylesId = "rId".concat(sheetCount + 1);
|
|
5159
5553
|
var themeId = "rId".concat(sheetCount + 2);
|
|
5160
5554
|
var sharedStringsId = "rId".concat(sheetCount + 3);
|
|
@@ -5199,10 +5593,13 @@ var buildWorkbookRelationships = function (sheetCount, slicerCacheCount, externa
|
|
|
5199
5593
|
};
|
|
5200
5594
|
};
|
|
5201
5595
|
var buildContentTypesXml = function (_a) {
|
|
5202
|
-
var
|
|
5203
|
-
var sheetOverrides = Array.from({ length:
|
|
5596
|
+
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;
|
|
5597
|
+
var sheetOverrides = Array.from({ length: worksheetCount }, function (_, index) {
|
|
5204
5598
|
return "<Override PartName=\"/xl/worksheets/sheet".concat(index + 1, ".xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\"/>");
|
|
5205
5599
|
}).join("");
|
|
5600
|
+
var chartsheetOverrides = Array.from({ length: chartsheetCount }, function (_, index) {
|
|
5601
|
+
return "<Override PartName=\"/xl/chartsheets/sheet".concat(index + 1, ".xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml\"/>");
|
|
5602
|
+
}).join("");
|
|
5206
5603
|
var tableOverrides = Array.from({ length: tableCount }, function (_, index) {
|
|
5207
5604
|
return "<Override PartName=\"/xl/tables/table".concat(index + 1, ".xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml\"/>");
|
|
5208
5605
|
}).join("");
|
|
@@ -5257,15 +5654,32 @@ var buildContentTypesXml = function (_a) {
|
|
|
5257
5654
|
var ctrlPropOverrides = Array.from({ length: ctrlPropCount }, function (_, index) {
|
|
5258
5655
|
return "<Override PartName=\"/xl/ctrlProps/ctrlProp".concat(index + 1, ".xml\" ContentType=\"").concat(CTRL_PROP_CONTENT_TYPE, "\"/>");
|
|
5259
5656
|
}).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>");
|
|
5657
|
+
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
5658
|
};
|
|
5262
5659
|
var buildRootRelationshipsXml = function () {
|
|
5263
5660
|
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
5661
|
};
|
|
5265
|
-
var buildAppXml = function (sheetNames, properties) {
|
|
5662
|
+
var buildAppXml = function (sheetNames, isChartsheet, properties) {
|
|
5266
5663
|
var _a;
|
|
5267
|
-
|
|
5268
|
-
|
|
5664
|
+
// Excel groups the tabs by kind: `HeadingPairs` counts `Worksheets` then
|
|
5665
|
+
// `Charts` (a pair is only written for a non-empty kind) and `TitlesOfParts`
|
|
5666
|
+
// lists the worksheet names followed by the chartsheet names.
|
|
5667
|
+
var worksheetNames = sheetNames.filter(function (_, index) { return !isChartsheet[index]; });
|
|
5668
|
+
var chartsheetNames = sheetNames.filter(function (_, index) { return isChartsheet[index]; });
|
|
5669
|
+
var headingPairs = [
|
|
5670
|
+
["Worksheets", worksheetNames.length],
|
|
5671
|
+
["Charts", chartsheetNames.length],
|
|
5672
|
+
].filter(function (_a) {
|
|
5673
|
+
var _b = __read(_a, 2), count = _b[1];
|
|
5674
|
+
return count > 0;
|
|
5675
|
+
});
|
|
5676
|
+
var headingPairsXml = headingPairs
|
|
5677
|
+
.map(function (_a) {
|
|
5678
|
+
var _b = __read(_a, 2), kind = _b[0], count = _b[1];
|
|
5679
|
+
return "<vt:variant><vt:lpstr>".concat(kind, "</vt:lpstr></vt:variant><vt:variant><vt:i4>").concat(count, "</vt:i4></vt:variant>");
|
|
5680
|
+
})
|
|
5681
|
+
.join("");
|
|
5682
|
+
var titles = __spreadArray(__spreadArray([], __read(worksheetNames), false), __read(chartsheetNames), false).map(function (name) { return "<vt:lpstr>".concat(escapeXmlText(name), "</vt:lpstr>"); })
|
|
5269
5683
|
.join("");
|
|
5270
5684
|
var application = (_a = properties === null || properties === void 0 ? void 0 : properties.application) !== null && _a !== void 0 ? _a : CREATOR;
|
|
5271
5685
|
var companyTag = (properties === null || properties === void 0 ? void 0 : properties.company)
|
|
@@ -5274,7 +5688,7 @@ var buildAppXml = function (sheetNames, properties) {
|
|
|
5274
5688
|
var managerTag = (properties === null || properties === void 0 ? void 0 : properties.manager)
|
|
5275
5689
|
? "<Manager>".concat(escapeXmlText(properties.manager), "</Manager>")
|
|
5276
5690
|
: "";
|
|
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\"
|
|
5691
|
+
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
5692
|
};
|
|
5279
5693
|
var buildCoreXml = function (properties) {
|
|
5280
5694
|
var _a, _b, _d, _e;
|