@rowsncolumns/toolkit 24.4.1 → 24.4.3
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/excel-parser/cfb-decryptor.d.ts +6 -0
- package/dist/cjs/excel-parser/cfb-decryptor.d.ts.map +1 -1
- package/dist/cjs/excel-parser/cfb-decryptor.js +6 -0
- package/dist/cjs/excel-parser/helpers.d.ts +9 -1
- package/dist/cjs/excel-parser/helpers.d.ts.map +1 -1
- package/dist/cjs/excel-parser/helpers.js +37 -0
- package/dist/cjs/excel-parser/interface.d.ts +10 -1
- package/dist/cjs/excel-parser/interface.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/index.d.ts +19 -0
- package/dist/cjs/excel-parser/plugins/ods/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/index.js +676 -304
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts +43 -1
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/styles.js +343 -45
- package/dist/cjs/excel-parser/plugins/xls/index.d.ts +11 -3
- package/dist/cjs/excel-parser/plugins/xls/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xls/index.js +55 -6
- package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts +4 -0
- package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsb/index.js +21 -9
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts +10 -0
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/charts.js +68 -9
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts +28 -1
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.js +155 -20
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +26 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.js +567 -234
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.js +125 -37
- package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.d.ts +3 -0
- package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.js +4 -1
- package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/styles.js +12 -2
- package/dist/cjs/excel-parser/registry.d.ts.map +1 -1
- package/dist/cjs/excel-parser/registry.js +2 -0
- package/dist/cjs/excel-parser/types.d.ts +7 -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 +4 -0
- package/dist/cjs/excel-parser/worker.js +3 -1
- package/dist/cjs/exporter/ods/ods-export.d.ts.map +1 -1
- package/dist/cjs/exporter/ods/ods-export.js +432 -175
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/chart-builder.js +210 -6
- package/dist/cjs/exporter/xlsx/pivot-builder.d.ts +8 -0
- package/dist/cjs/exporter/xlsx/pivot-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/pivot-builder.js +141 -42
- package/dist/cjs/exporter/xlsx/style-builder.js +9 -3
- package/dist/cjs/exporter/xlsx/threaded-comments-builder.d.ts +7 -1
- package/dist/cjs/exporter/xlsx/threaded-comments-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/threaded-comments-builder.js +15 -3
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts +11 -2
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/xlsx-export.js +678 -222
- package/dist/cjs/helpers/implicit-intersection.d.ts +16 -0
- package/dist/cjs/helpers/implicit-intersection.d.ts.map +1 -0
- package/dist/cjs/helpers/implicit-intersection.js +197 -0
- package/dist/cjs/print-settings.d.ts +105 -0
- package/dist/cjs/print-settings.d.ts.map +1 -0
- package/dist/cjs/print-settings.js +494 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/excel-parser/cfb-decryptor.d.ts +6 -0
- package/dist/esm/excel-parser/cfb-decryptor.d.ts.map +1 -1
- package/dist/esm/excel-parser/cfb-decryptor.js +6 -0
- package/dist/esm/excel-parser/helpers.d.ts +9 -1
- package/dist/esm/excel-parser/helpers.d.ts.map +1 -1
- package/dist/esm/excel-parser/helpers.js +34 -0
- package/dist/esm/excel-parser/interface.d.ts +10 -1
- package/dist/esm/excel-parser/interface.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/index.d.ts +19 -0
- package/dist/esm/excel-parser/plugins/ods/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/index.js +347 -33
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts +43 -1
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/styles.js +276 -2
- package/dist/esm/excel-parser/plugins/xls/index.d.ts +11 -3
- package/dist/esm/excel-parser/plugins/xls/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xls/index.js +37 -5
- package/dist/esm/excel-parser/plugins/xlsb/index.d.ts +4 -0
- package/dist/esm/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsb/index.js +20 -6
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts +10 -0
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/charts.js +69 -6
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts +28 -1
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/drawing.js +99 -0
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +26 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.js +362 -26
- package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/pivots.js +86 -6
- package/dist/esm/excel-parser/plugins/xlsx/sheet-views.d.ts +3 -0
- package/dist/esm/excel-parser/plugins/xlsx/sheet-views.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/sheet-views.js +2 -0
- package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/styles.js +12 -2
- package/dist/esm/excel-parser/registry.d.ts.map +1 -1
- package/dist/esm/excel-parser/registry.js +2 -0
- package/dist/esm/excel-parser/types.d.ts +7 -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 +3 -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 +306 -35
- package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/chart-builder.js +161 -0
- package/dist/esm/exporter/xlsx/pivot-builder.d.ts +8 -0
- package/dist/esm/exporter/xlsx/pivot-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/pivot-builder.js +104 -19
- package/dist/esm/exporter/xlsx/style-builder.js +9 -3
- package/dist/esm/exporter/xlsx/threaded-comments-builder.d.ts +7 -1
- package/dist/esm/exporter/xlsx/threaded-comments-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/threaded-comments-builder.js +15 -3
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts +11 -2
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/xlsx-export.js +449 -47
- package/dist/esm/helpers/implicit-intersection.d.ts +16 -0
- package/dist/esm/helpers/implicit-intersection.d.ts.map +1 -0
- package/dist/esm/helpers/implicit-intersection.js +184 -0
- package/dist/esm/print-settings.d.ts +105 -0
- package/dist/esm/print-settings.d.ts.map +1 -0
- package/dist/esm/print-settings.js +422 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -4,6 +4,7 @@ import { CellXfsRegistry, deriveEffectiveNumberFormatFromFormula, } from "@rowsn
|
|
|
4
4
|
import { cellRangeToAddress, cellToAddress, getCellEffectiveFormat, getCellEffectiveValue, getCellFormattedValue, getCellUserEnteredFormat, getCellUserEnteredValue, getExtendedValueBool, getExtendedValueError, getExtendedValueFormula, getExtendedValueNumber, getExtendedValueString, escapeCharacters, isNil, sortSheetsByIndex, addressToSelection, } from "@rowsncolumns/utils";
|
|
5
5
|
import { defaultSpreadsheetTheme } from "../../excel-parser/theme-default";
|
|
6
6
|
import { imageUrlToBase64 } from "../../helpers";
|
|
7
|
+
import { buildOdsPrintTokens, DEFAULT_PAGE_MARGINS_IN, inchesToOdsCm, isHeaderFooterEmpty, odsTableCentering, paperSizeToCm, splitHeaderFooterZones, tokenizeHeaderFooterZone, } from "../../print-settings";
|
|
7
8
|
import { omitInvalidDataValidationError } from "../invalid-data-validation";
|
|
8
9
|
import { buildOdsSparklineGroupsXml } from "./sparkline-builder";
|
|
9
10
|
var BLANK_LABEL = "(Blanks)";
|
|
@@ -116,6 +117,36 @@ var outlineGroupOpenTag = function (span, tag) {
|
|
|
116
117
|
};
|
|
117
118
|
var XML_DECLARATION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
|
118
119
|
var ODS_MIMETYPE = "application/vnd.oasis.opendocument.spreadsheet";
|
|
120
|
+
/**
|
|
121
|
+
* Emit the wrappers that end at `rowIndex`: the header-rows band (when this
|
|
122
|
+
* is its last row) and any outline groups. A group may not close inside
|
|
123
|
+
* `<table:table-header-rows>`, so an open band is closed first — the caller
|
|
124
|
+
* re-opens it on the next band row. Returns the band's open state.
|
|
125
|
+
*/
|
|
126
|
+
var closeRowWrappers = function (chunks, rowIndex, closesAt, headerRowsCloseAt, headerRowsOpen) {
|
|
127
|
+
var e_4, _a;
|
|
128
|
+
var _b;
|
|
129
|
+
var open = headerRowsOpen;
|
|
130
|
+
var closes = (_b = closesAt.get(rowIndex)) !== null && _b !== void 0 ? _b : [];
|
|
131
|
+
if (open && (rowIndex === headerRowsCloseAt || closes.length)) {
|
|
132
|
+
chunks.push("</table:table-header-rows>");
|
|
133
|
+
open = false;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
for (var closes_1 = __values(closes), closes_1_1 = closes_1.next(); !closes_1_1.done; closes_1_1 = closes_1.next()) {
|
|
137
|
+
var _1 = closes_1_1.value;
|
|
138
|
+
chunks.push("</table:table-row-group>");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
142
|
+
finally {
|
|
143
|
+
try {
|
|
144
|
+
if (closes_1_1 && !closes_1_1.done && (_a = closes_1.return)) _a.call(closes_1);
|
|
145
|
+
}
|
|
146
|
+
finally { if (e_4) throw e_4.error; }
|
|
147
|
+
}
|
|
148
|
+
return open;
|
|
149
|
+
};
|
|
119
150
|
var CREATOR = "Rows n Columns";
|
|
120
151
|
var PIXELS_PER_INCH = 96;
|
|
121
152
|
var CM_PER_INCH = 2.54;
|
|
@@ -174,8 +205,11 @@ var OdsStyleBuilder = /** @class */ (function () {
|
|
|
174
205
|
this.numberXmlChunks = [];
|
|
175
206
|
// NEW: separate storage for conditional format styles (go to styles.xml)
|
|
176
207
|
this.conditionalStyleXmlChunks = [];
|
|
208
|
+
this.pageLayoutXmlChunks = [];
|
|
209
|
+
this.masterPageXmlChunks = [];
|
|
177
210
|
this.styleIndex = 1;
|
|
178
211
|
this.numberIndex = 1;
|
|
212
|
+
this.pageLayoutIndex = 0;
|
|
179
213
|
}
|
|
180
214
|
OdsStyleBuilder.prototype.registerCell = function (format) {
|
|
181
215
|
if (!format)
|
|
@@ -186,32 +220,75 @@ var OdsStyleBuilder = /** @class */ (function () {
|
|
|
186
220
|
return existing;
|
|
187
221
|
return this.registerCellWithName(format, key);
|
|
188
222
|
};
|
|
189
|
-
OdsStyleBuilder.prototype.registerRow = function (heightPx, hidden) {
|
|
190
|
-
if (
|
|
223
|
+
OdsStyleBuilder.prototype.registerRow = function (heightPx, hidden, breakBefore) {
|
|
224
|
+
if (breakBefore === void 0) { breakBefore = false; }
|
|
225
|
+
if (!heightPx && !hidden && !breakBefore)
|
|
191
226
|
return undefined;
|
|
192
|
-
var key = stableStringify({ heightPx: heightPx, hidden: hidden });
|
|
227
|
+
var key = stableStringify({ heightPx: heightPx, hidden: hidden, breakBefore: breakBefore });
|
|
193
228
|
var existing = this.rowStyles.get(key);
|
|
194
229
|
if (existing)
|
|
195
230
|
return existing;
|
|
196
231
|
var styleName = "ro".concat(this.styleIndex++);
|
|
197
|
-
var styleXml = buildRowStyleXml(styleName, heightPx, hidden);
|
|
232
|
+
var styleXml = buildRowStyleXml(styleName, heightPx, hidden, breakBefore);
|
|
198
233
|
this.rowStyles.set(key, styleName);
|
|
199
234
|
this.styleXmlChunks.push(styleXml);
|
|
200
235
|
return styleName;
|
|
201
236
|
};
|
|
202
|
-
OdsStyleBuilder.prototype.registerColumn = function (widthPx, hidden) {
|
|
203
|
-
if (
|
|
237
|
+
OdsStyleBuilder.prototype.registerColumn = function (widthPx, hidden, breakBefore) {
|
|
238
|
+
if (breakBefore === void 0) { breakBefore = false; }
|
|
239
|
+
if (!widthPx && !hidden && !breakBefore)
|
|
204
240
|
return undefined;
|
|
205
|
-
var key = stableStringify({ widthPx: widthPx, hidden: hidden });
|
|
241
|
+
var key = stableStringify({ widthPx: widthPx, hidden: hidden, breakBefore: breakBefore });
|
|
206
242
|
var existing = this.columnStyles.get(key);
|
|
207
243
|
if (existing)
|
|
208
244
|
return existing;
|
|
209
245
|
var styleName = "co".concat(this.styleIndex++);
|
|
210
|
-
var styleXml = buildColumnStyleXml(styleName, widthPx, hidden);
|
|
246
|
+
var styleXml = buildColumnStyleXml(styleName, widthPx, hidden, breakBefore);
|
|
211
247
|
this.columnStyles.set(key, styleName);
|
|
212
248
|
this.styleXmlChunks.push(styleXml);
|
|
213
249
|
return styleName;
|
|
214
250
|
};
|
|
251
|
+
/**
|
|
252
|
+
* A sheet's print settings → a `table` automatic style (content.xml)
|
|
253
|
+
* pointing at a master page whose page layout + header/footer live in
|
|
254
|
+
* styles.xml. Returns the table style name, or undefined when the sheet
|
|
255
|
+
* has no page-level print settings to carry.
|
|
256
|
+
*/
|
|
257
|
+
OdsStyleBuilder.prototype.registerTable = function (print, rightToLeft) {
|
|
258
|
+
var pageLayoutXml = buildOdsPageLayoutXml(print);
|
|
259
|
+
var headerFooter = print === null || print === void 0 ? void 0 : print.headerFooter;
|
|
260
|
+
var hasPrintSettings = !!pageLayoutXml || !isHeaderFooterEmpty(headerFooter);
|
|
261
|
+
// Right-to-left is the table style's `style:writing-mode="rl-tb"`, the
|
|
262
|
+
// ODF counterpart of `<sheetView rightToLeft="1">`. A sheet with only
|
|
263
|
+
// that flag shares one RTL style on the default master page.
|
|
264
|
+
var writingMode = rightToLeft ? "rl-tb" : "lr-tb";
|
|
265
|
+
if (!hasPrintSettings) {
|
|
266
|
+
if (!rightToLeft)
|
|
267
|
+
return undefined;
|
|
268
|
+
if (this.rtlTableStyleName)
|
|
269
|
+
return this.rtlTableStyleName;
|
|
270
|
+
var styleName = "ta".concat(this.styleIndex++);
|
|
271
|
+
this.rtlTableStyleName = styleName;
|
|
272
|
+
this.styleXmlChunks.push("<style:style style:name=\"".concat(styleName, "\" style:family=\"table\" style:master-page-name=\"Default\"><style:table-properties table:display=\"true\" style:writing-mode=\"").concat(writingMode, "\"/></style:style>"));
|
|
273
|
+
return styleName;
|
|
274
|
+
}
|
|
275
|
+
var index = ++this.pageLayoutIndex;
|
|
276
|
+
var layoutName = "Mpm".concat(index);
|
|
277
|
+
var masterName = "Mp".concat(index);
|
|
278
|
+
var tableStyleName = "ta".concat(this.styleIndex++);
|
|
279
|
+
this.pageLayoutXmlChunks.push("<style:page-layout style:name=\"".concat(layoutName, "\">").concat(pageLayoutXml !== null && pageLayoutXml !== void 0 ? pageLayoutXml : "<style:page-layout-properties/>", "</style:page-layout>"));
|
|
280
|
+
this.masterPageXmlChunks.push("<style:master-page style:name=\"".concat(masterName, "\" style:page-layout-name=\"").concat(layoutName, "\">").concat(buildOdsHeaderFooterXml("style:header", headerFooter === null || headerFooter === void 0 ? void 0 : headerFooter.oddHeader)).concat(buildOdsHeaderFooterXml("style:footer", headerFooter === null || headerFooter === void 0 ? void 0 : headerFooter.oddFooter), "</style:master-page>"));
|
|
281
|
+
this.styleXmlChunks.push("<style:style style:name=\"".concat(tableStyleName, "\" style:family=\"table\" style:master-page-name=\"").concat(masterName, "\"><style:table-properties table:display=\"true\" style:writing-mode=\"").concat(writingMode, "\"/></style:style>"));
|
|
282
|
+
return tableStyleName;
|
|
283
|
+
};
|
|
284
|
+
/** `<style:page-layout>` entries for styles.xml `<office:automatic-styles>`. */
|
|
285
|
+
OdsStyleBuilder.prototype.toPageLayoutStylesXml = function () {
|
|
286
|
+
return this.pageLayoutXmlChunks.join("");
|
|
287
|
+
};
|
|
288
|
+
/** `<style:master-page>` entries for styles.xml `<office:master-styles>`. */
|
|
289
|
+
OdsStyleBuilder.prototype.toMasterPagesXml = function () {
|
|
290
|
+
return this.masterPageXmlChunks.join("");
|
|
291
|
+
};
|
|
215
292
|
OdsStyleBuilder.prototype.registerText = function (format) {
|
|
216
293
|
if (!format || Object.keys(format).length === 0)
|
|
217
294
|
return undefined;
|
|
@@ -322,8 +399,8 @@ var buildConditionalCellStyleXml = function (name, format, theme) {
|
|
|
322
399
|
return "<style:style style:name=\"".concat(name, "\" style:family=\"table-cell\" style:parent-style-name=\"Default\"><style:table-cell-properties").concat(cellProps.length ? " " + cellProps.join(" ") : "", "/><style:text-properties").concat(textProps.length ? " " + textProps.join(" ") : "", "/></style:style>");
|
|
323
400
|
};
|
|
324
401
|
export var createODSFile = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
325
|
-
var sortedSheets, styleBuilder, preparedTables, embedsBySheet, chartsBySheet, namedRangeNames, sheetNameById, dataValidationsById, mediaEntries, sheetXmlEntries, chartObjectIndex, _loop_1, sortedSheets_1, sortedSheets_1_1, sheet,
|
|
326
|
-
var
|
|
402
|
+
var sortedSheets, styleBuilder, preparedTables, embedsBySheet, chartsBySheet, namedRangeNames, sheetNameById, dataValidationsById, mediaEntries, sheetXmlEntries, chartObjectIndex, _loop_1, sortedSheets_1, sortedSheets_1_1, sheet, e_5_1, validationEntries, contentValidationsXml, calculationSettingsXml, contentXml, stylesXml, metaXml, settingsXml, chartObjects, manifestXml, files, chartObjects_1, chartObjects_1_1, chartObject, mediaEntries_1, mediaEntries_1_1, entry, orderedEntries;
|
|
403
|
+
var e_5, _c, e_6, _d, e_7, _e;
|
|
327
404
|
var _f, _g, _h, _j, _k, _l;
|
|
328
405
|
var _conditionalFormats = _b.conditionalFormats, _dataValidations = _b.dataValidations, sheets = _b.sheets, sheetData = _b.sheetData, sourceSharedStrings = _b.sharedStrings, _m = _b.tables, _tables = _m === void 0 ? [] : _m, cellXfs = _b.cellXfs, _theme = _b.theme, _o = _b.embeds, embeds = _o === void 0 ? [] : _o, _p = _b.charts, charts = _p === void 0 ? [] : _p, _q = _b.namedRanges, namedRanges = _q === void 0 ? [] : _q, iterativeCalculationOptions = _b.iterativeCalculationOptions, ignoreFormulaPatterns = _b.ignoreFormulaPatterns, citations = _b.citations, locale = _b.locale;
|
|
329
406
|
return __generator(this, function (_r) {
|
|
@@ -417,14 +494,14 @@ export var createODSFile = function (_a) { return __awaiter(void 0, [_a], void 0
|
|
|
417
494
|
return [3 /*break*/, 2];
|
|
418
495
|
case 5: return [3 /*break*/, 8];
|
|
419
496
|
case 6:
|
|
420
|
-
|
|
421
|
-
|
|
497
|
+
e_5_1 = _r.sent();
|
|
498
|
+
e_5 = { error: e_5_1 };
|
|
422
499
|
return [3 /*break*/, 8];
|
|
423
500
|
case 7:
|
|
424
501
|
try {
|
|
425
502
|
if (sortedSheets_1_1 && !sortedSheets_1_1.done && (_c = sortedSheets_1.return)) _c.call(sortedSheets_1);
|
|
426
503
|
}
|
|
427
|
-
finally { if (
|
|
504
|
+
finally { if (e_5) throw e_5.error; }
|
|
428
505
|
return [7 /*endfinally*/];
|
|
429
506
|
case 8:
|
|
430
507
|
validationEntries = buildAllDataValidationEntries(_dataValidations !== null && _dataValidations !== void 0 ? _dataValidations : [], sheetNameById);
|
|
@@ -440,7 +517,7 @@ export var createODSFile = function (_a) { return __awaiter(void 0, [_a], void 0
|
|
|
440
517
|
automaticStylesXml: styleBuilder.toAutomaticStylesXml(),
|
|
441
518
|
calculationSettingsXml: calculationSettingsXml,
|
|
442
519
|
});
|
|
443
|
-
stylesXml = buildStylesXml(styleBuilder.toConditionalStylesXml());
|
|
520
|
+
stylesXml = buildStylesXml(styleBuilder.toConditionalStylesXml(), styleBuilder.toPageLayoutStylesXml(), styleBuilder.toMasterPagesXml());
|
|
444
521
|
metaXml = buildMetaXml();
|
|
445
522
|
settingsXml = buildSettingsXml(sortedSheets, _theme !== null && _theme !== void 0 ? _theme : defaultSpreadsheetTheme);
|
|
446
523
|
chartObjects = sheetXmlEntries.flatMap(function (entry) { return entry.chartObjects; });
|
|
@@ -460,12 +537,12 @@ export var createODSFile = function (_a) { return __awaiter(void 0, [_a], void 0
|
|
|
460
537
|
files["".concat(chartObject.folder, "/content.xml")] = encodeXml(chartObject.contentXml);
|
|
461
538
|
}
|
|
462
539
|
}
|
|
463
|
-
catch (
|
|
540
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
464
541
|
finally {
|
|
465
542
|
try {
|
|
466
543
|
if (chartObjects_1_1 && !chartObjects_1_1.done && (_d = chartObjects_1.return)) _d.call(chartObjects_1);
|
|
467
544
|
}
|
|
468
|
-
finally { if (
|
|
545
|
+
finally { if (e_6) throw e_6.error; }
|
|
469
546
|
}
|
|
470
547
|
try {
|
|
471
548
|
for (mediaEntries_1 = __values(mediaEntries), mediaEntries_1_1 = mediaEntries_1.next(); !mediaEntries_1_1.done; mediaEntries_1_1 = mediaEntries_1.next()) {
|
|
@@ -473,12 +550,12 @@ export var createODSFile = function (_a) { return __awaiter(void 0, [_a], void 0
|
|
|
473
550
|
files[entry.path] = entry.data;
|
|
474
551
|
}
|
|
475
552
|
}
|
|
476
|
-
catch (
|
|
553
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
477
554
|
finally {
|
|
478
555
|
try {
|
|
479
556
|
if (mediaEntries_1_1 && !mediaEntries_1_1.done && (_e = mediaEntries_1.return)) _e.call(mediaEntries_1);
|
|
480
557
|
}
|
|
481
|
-
finally { if (
|
|
558
|
+
finally { if (e_7) throw e_7.error; }
|
|
482
559
|
}
|
|
483
560
|
orderedEntries = __spreadArray([
|
|
484
561
|
{ name: "mimetype", data: new TextEncoder().encode(ODS_MIMETYPE) }
|
|
@@ -495,12 +572,12 @@ var getRowsForSheet = function (sheetData, sheetId) {
|
|
|
495
572
|
return ((_c = (_b = (_a = sheetData[sheetId]) !== null && _a !== void 0 ? _a : sheetData[String(sheetId)]) !== null && _b !== void 0 ? _b : sheetData[Number(sheetId)]) !== null && _c !== void 0 ? _c : []);
|
|
496
573
|
};
|
|
497
574
|
var buildWorksheetXml = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
498
|
-
var bounds, rowMetadata, maxRows, rowXmlEntries, mergeState, annotationsMap, citations_1, citations_1_1, citation, rowIndex, colIndex, address, conditionalFormattingXml, rowDataMap, rowIndex, row, metadata, rowXml, rowValues, _c, _d, _e, colIndex, cell, maxRowIndex, summaryBelow, rowSpans, _f, rowOpensAt, rowClosesAt, rowXmlChunks, index, rowIndex,
|
|
499
|
-
var
|
|
500
|
-
var
|
|
575
|
+
var bounds, rowMetadata, print, rowBreakSet, titleRows, maxRows, rowXmlEntries, mergeState, annotationsMap, citations_1, citations_1_1, citation, rowIndex, colIndex, address, conditionalFormattingXml, rowDataMap, rowIndex, row, metadata, rowXml, rowValues, _c, _d, _e, colIndex, cell, maxRowIndex, summaryBelow, rowSpans, _f, rowOpensAt, rowClosesAt, rowXmlChunks, headerRowsOpenAt, headerRowsCloseAt, headerRowsOpen, index, rowIndex, opens, opens_1, opens_1_1, span, entry, repeat, nextRowIndex, lastInRepeat, embedFrames, _g, chartFramesResult, _h, shapesXml, columnsXml, sparklineXml, protectedAttr, tableStyleName, tableStyleAttr, printRanges, printRangesAttr, sheetXml;
|
|
576
|
+
var e_8, _j, e_9, _k, e_10, _l;
|
|
577
|
+
var _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
501
578
|
var sheet = _b.sheet, sheetName = _b.sheetName, rows = _b.rows, sourceSharedStrings = _b.sourceSharedStrings, cellXfs = _b.cellXfs, styleBuilder = _b.styleBuilder, tables = _b.tables, conditionalFormats = _b.conditionalFormats, dataValidationsById = _b.dataValidationsById, embeds = _b.embeds, charts = _b.charts, mediaEntries = _b.mediaEntries, namedRangeNames = _b.namedRangeNames, sheetNameById = _b.sheetNameById, chartObjectIndex = _b.chartObjectIndex, ignoreFormulaPatterns = _b.ignoreFormulaPatterns, citations = _b.citations, sheetData = _b.sheetData, sheets = _b.sheets, locale = _b.locale;
|
|
502
|
-
return __generator(this, function (
|
|
503
|
-
switch (
|
|
579
|
+
return __generator(this, function (_x) {
|
|
580
|
+
switch (_x.label) {
|
|
504
581
|
case 0:
|
|
505
582
|
bounds = {
|
|
506
583
|
minRow: Number.POSITIVE_INFINITY,
|
|
@@ -508,10 +585,18 @@ var buildWorksheetXml = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
508
585
|
minColumn: Number.POSITIVE_INFINITY,
|
|
509
586
|
maxColumn: 0,
|
|
510
587
|
};
|
|
511
|
-
rowMetadata = (
|
|
512
|
-
|
|
588
|
+
rowMetadata = (_m = sheet.rowMetadata) !== null && _m !== void 0 ? _m : [];
|
|
589
|
+
print = sheet.printSettings;
|
|
590
|
+
rowBreakSet = new Set(((_o = print === null || print === void 0 ? void 0 : print.rowBreaks) !== null && _o !== void 0 ? _o : []).filter(function (n) { return Number.isInteger(n) && n >= 1; }));
|
|
591
|
+
titleRows = ((_p = print === null || print === void 0 ? void 0 : print.printTitles) === null || _p === void 0 ? void 0 : _p.rowStart) != null && print.printTitles.rowEnd != null
|
|
592
|
+
? {
|
|
593
|
+
start: Math.max(1, print.printTitles.rowStart),
|
|
594
|
+
end: Math.max(print.printTitles.rowStart, print.printTitles.rowEnd),
|
|
595
|
+
}
|
|
596
|
+
: undefined;
|
|
597
|
+
maxRows = Math.max(rows.length, rowMetadata.length, rowBreakSet.size ? Math.max.apply(Math, __spreadArray([], __read(rowBreakSet), false)) + 2 : 0, titleRows ? titleRows.end + 1 : 0);
|
|
513
598
|
rowXmlEntries = [];
|
|
514
|
-
mergeState = buildMergeState((
|
|
599
|
+
mergeState = buildMergeState((_q = sheet.merges) !== null && _q !== void 0 ? _q : []);
|
|
515
600
|
annotationsMap = new Map();
|
|
516
601
|
if (citations) {
|
|
517
602
|
try {
|
|
@@ -531,12 +616,12 @@ var buildWorksheetXml = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
531
616
|
}
|
|
532
617
|
}
|
|
533
618
|
}
|
|
534
|
-
catch (
|
|
619
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
535
620
|
finally {
|
|
536
621
|
try {
|
|
537
|
-
if (citations_1_1 && !citations_1_1.done && (
|
|
622
|
+
if (citations_1_1 && !citations_1_1.done && (_j = citations_1.return)) _j.call(citations_1);
|
|
538
623
|
}
|
|
539
|
-
finally { if (
|
|
624
|
+
finally { if (e_8) throw e_8.error; }
|
|
540
625
|
}
|
|
541
626
|
}
|
|
542
627
|
conditionalFormattingXml = conditionalFormats.length
|
|
@@ -549,7 +634,7 @@ var buildWorksheetXml = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
549
634
|
: "";
|
|
550
635
|
rowDataMap = {};
|
|
551
636
|
rowIndex = 1;
|
|
552
|
-
|
|
637
|
+
_x.label = 1;
|
|
553
638
|
case 1:
|
|
554
639
|
if (!(rowIndex < maxRows)) return [3 /*break*/, 4];
|
|
555
640
|
row = rows[rowIndex];
|
|
@@ -558,6 +643,7 @@ var buildWorksheetXml = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
558
643
|
rowNumber: rowIndex,
|
|
559
644
|
row: row,
|
|
560
645
|
rowMetadata: metadata,
|
|
646
|
+
breakBefore: rowBreakSet.has(rowIndex - 1),
|
|
561
647
|
sourceSharedStrings: sourceSharedStrings,
|
|
562
648
|
cellXfs: cellXfs,
|
|
563
649
|
styleBuilder: styleBuilder,
|
|
@@ -574,25 +660,25 @@ var buildWorksheetXml = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
574
660
|
locale: locale,
|
|
575
661
|
})];
|
|
576
662
|
case 2:
|
|
577
|
-
rowXml =
|
|
663
|
+
rowXml = _x.sent();
|
|
578
664
|
rowXmlEntries.push(rowXml);
|
|
579
665
|
// Collect row data for sparkline detection
|
|
580
666
|
if (row === null || row === void 0 ? void 0 : row.values) {
|
|
581
667
|
rowValues = {};
|
|
582
668
|
try {
|
|
583
|
-
for (_c = (
|
|
669
|
+
for (_c = (e_9 = void 0, __values(Object.entries(row.values))), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
584
670
|
_e = __read(_d.value, 2), colIndex = _e[0], cell = _e[1];
|
|
585
671
|
if (cell) {
|
|
586
672
|
rowValues[parseInt(colIndex, 10)] = cell;
|
|
587
673
|
}
|
|
588
674
|
}
|
|
589
675
|
}
|
|
590
|
-
catch (
|
|
676
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
591
677
|
finally {
|
|
592
678
|
try {
|
|
593
|
-
if (_d && !_d.done && (
|
|
679
|
+
if (_d && !_d.done && (_k = _c.return)) _k.call(_c);
|
|
594
680
|
}
|
|
595
|
-
finally { if (
|
|
681
|
+
finally { if (e_9) throw e_9.error; }
|
|
596
682
|
}
|
|
597
683
|
if (Object.keys(rowValues).length > 0) {
|
|
598
684
|
rowDataMap[rowIndex] = rowValues;
|
|
@@ -608,31 +694,47 @@ var buildWorksheetXml = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
608
694
|
}
|
|
609
695
|
bounds.minRow = Math.min(bounds.minRow, rowIndex);
|
|
610
696
|
bounds.maxRow = Math.max(bounds.maxRow, rowIndex);
|
|
611
|
-
|
|
697
|
+
_x.label = 3;
|
|
612
698
|
case 3:
|
|
613
699
|
rowIndex++;
|
|
614
700
|
return [3 /*break*/, 1];
|
|
615
701
|
case 4:
|
|
616
702
|
updateBoundsForMerges(bounds, mergeState);
|
|
617
703
|
maxRowIndex = rowXmlEntries.length;
|
|
618
|
-
summaryBelow = ((
|
|
704
|
+
summaryBelow = ((_r = sheet.outlinePr) === null || _r === void 0 ? void 0 : _r.summaryBelow) !== false;
|
|
619
705
|
rowSpans = findOutlineGroupSpans(rowMetadata, maxRowIndex, summaryBelow);
|
|
620
706
|
_f = buildOutlineGroupIndex(rowSpans), rowOpensAt = _f.opensAt, rowClosesAt = _f.closesAt;
|
|
621
707
|
rowXmlChunks = [];
|
|
708
|
+
headerRowsOpenAt = titleRows === null || titleRows === void 0 ? void 0 : titleRows.start;
|
|
709
|
+
headerRowsCloseAt = titleRows === null || titleRows === void 0 ? void 0 : titleRows.end;
|
|
710
|
+
headerRowsOpen = false;
|
|
622
711
|
for (index = 0; index < rowXmlEntries.length; index++) {
|
|
623
712
|
rowIndex = index + 1;
|
|
713
|
+
opens = (_s = rowOpensAt.get(rowIndex)) !== null && _s !== void 0 ? _s : [];
|
|
714
|
+
if (opens.length && headerRowsOpen) {
|
|
715
|
+
rowXmlChunks.push("</table:table-header-rows>");
|
|
716
|
+
headerRowsOpen = false;
|
|
717
|
+
}
|
|
624
718
|
try {
|
|
625
|
-
for (
|
|
626
|
-
span =
|
|
719
|
+
for (opens_1 = (e_10 = void 0, __values(opens)), opens_1_1 = opens_1.next(); !opens_1_1.done; opens_1_1 = opens_1.next()) {
|
|
720
|
+
span = opens_1_1.value;
|
|
627
721
|
rowXmlChunks.push(outlineGroupOpenTag(span, "table:table-row-group"));
|
|
628
722
|
}
|
|
629
723
|
}
|
|
630
|
-
catch (
|
|
724
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
631
725
|
finally {
|
|
632
726
|
try {
|
|
633
|
-
if (
|
|
727
|
+
if (opens_1_1 && !opens_1_1.done && (_l = opens_1.return)) _l.call(opens_1);
|
|
634
728
|
}
|
|
635
|
-
finally { if (
|
|
729
|
+
finally { if (e_10) throw e_10.error; }
|
|
730
|
+
}
|
|
731
|
+
if (!headerRowsOpen &&
|
|
732
|
+
headerRowsOpenAt != null &&
|
|
733
|
+
headerRowsCloseAt != null &&
|
|
734
|
+
rowIndex >= headerRowsOpenAt &&
|
|
735
|
+
rowIndex <= headerRowsCloseAt) {
|
|
736
|
+
rowXmlChunks.push("<table:table-header-rows>");
|
|
737
|
+
headerRowsOpen = true;
|
|
636
738
|
}
|
|
637
739
|
entry = rowXmlEntries[index];
|
|
638
740
|
if (entry) {
|
|
@@ -646,41 +748,21 @@ var buildWorksheetXml = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
646
748
|
if (rowOpensAt.has(nextRowIndex) || rowClosesAt.has(nextRowIndex - 1)) {
|
|
647
749
|
break;
|
|
648
750
|
}
|
|
751
|
+
if (nextRowIndex === headerRowsOpenAt ||
|
|
752
|
+
nextRowIndex - 1 === headerRowsCloseAt) {
|
|
753
|
+
break;
|
|
754
|
+
}
|
|
649
755
|
repeat += 1;
|
|
650
756
|
}
|
|
651
757
|
rowXmlChunks.push(repeat > 1
|
|
652
758
|
? "<table:table-row table:number-rows-repeated=\"".concat(repeat, "\"/>")
|
|
653
759
|
: "<table:table-row/>");
|
|
654
760
|
lastInRepeat = rowIndex + repeat - 1;
|
|
655
|
-
|
|
656
|
-
for (_j = (e_10 = void 0, __values((_z = rowClosesAt.get(lastInRepeat)) !== null && _z !== void 0 ? _z : [])), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
657
|
-
_1 = _k.value;
|
|
658
|
-
rowXmlChunks.push("</table:table-row-group>");
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
662
|
-
finally {
|
|
663
|
-
try {
|
|
664
|
-
if (_k && !_k.done && (_t = _j.return)) _t.call(_j);
|
|
665
|
-
}
|
|
666
|
-
finally { if (e_10) throw e_10.error; }
|
|
667
|
-
}
|
|
761
|
+
headerRowsOpen = closeRowWrappers(rowXmlChunks, lastInRepeat, rowClosesAt, headerRowsCloseAt, headerRowsOpen);
|
|
668
762
|
index += repeat - 1;
|
|
669
763
|
continue;
|
|
670
764
|
}
|
|
671
|
-
|
|
672
|
-
for (_l = (e_11 = void 0, __values((_0 = rowClosesAt.get(rowIndex)) !== null && _0 !== void 0 ? _0 : [])), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
673
|
-
_2 = _m.value;
|
|
674
|
-
rowXmlChunks.push("</table:table-row-group>");
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
678
|
-
finally {
|
|
679
|
-
try {
|
|
680
|
-
if (_m && !_m.done && (_u = _l.return)) _u.call(_l);
|
|
681
|
-
}
|
|
682
|
-
finally { if (e_11) throw e_11.error; }
|
|
683
|
-
}
|
|
765
|
+
headerRowsOpen = closeRowWrappers(rowXmlChunks, rowIndex, rowClosesAt, headerRowsCloseAt, headerRowsOpen);
|
|
684
766
|
}
|
|
685
767
|
if (!embeds.length) return [3 /*break*/, 6];
|
|
686
768
|
return [4 /*yield*/, buildEmbedFramesXml({
|
|
@@ -690,13 +772,13 @@ var buildWorksheetXml = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
690
772
|
sheet: sheet,
|
|
691
773
|
})];
|
|
692
774
|
case 5:
|
|
693
|
-
|
|
775
|
+
_g = _x.sent();
|
|
694
776
|
return [3 /*break*/, 7];
|
|
695
777
|
case 6:
|
|
696
|
-
|
|
697
|
-
|
|
778
|
+
_g = [];
|
|
779
|
+
_x.label = 7;
|
|
698
780
|
case 7:
|
|
699
|
-
embedFrames =
|
|
781
|
+
embedFrames = _g;
|
|
700
782
|
if (!charts.length) return [3 /*break*/, 9];
|
|
701
783
|
return [4 /*yield*/, buildChartFramesXml({
|
|
702
784
|
charts: charts,
|
|
@@ -706,19 +788,32 @@ var buildWorksheetXml = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
706
788
|
startIndex: chartObjectIndex,
|
|
707
789
|
})];
|
|
708
790
|
case 8:
|
|
709
|
-
|
|
791
|
+
_h = _x.sent();
|
|
710
792
|
return [3 /*break*/, 10];
|
|
711
793
|
case 9:
|
|
712
|
-
|
|
713
|
-
|
|
794
|
+
_h = { frames: [], chartObjects: [], nextIndex: chartObjectIndex };
|
|
795
|
+
_x.label = 10;
|
|
714
796
|
case 10:
|
|
715
|
-
chartFramesResult =
|
|
797
|
+
chartFramesResult = _h;
|
|
716
798
|
shapesXml = embedFrames.length || chartFramesResult.frames.length
|
|
717
799
|
? "<table:shapes>".concat(__spreadArray(__spreadArray([], __read(embedFrames), false), __read(chartFramesResult.frames), false).join(""), "</table:shapes>")
|
|
718
800
|
: "";
|
|
719
|
-
columnsXml = buildColumnsXml(sheet, styleBuilder, bounds);
|
|
720
|
-
sparklineXml = (
|
|
721
|
-
|
|
801
|
+
columnsXml = buildColumnsXml(sheet, styleBuilder, bounds, print);
|
|
802
|
+
sparklineXml = (_t = buildOdsSparklineGroupsXml(sheet, sheetName, rowDataMap)) !== null && _t !== void 0 ? _t : "";
|
|
803
|
+
protectedAttr = ((_u = sheet.sheetProtection) === null || _u === void 0 ? void 0 : _u.sheet)
|
|
804
|
+
? ' table:protected="true"'
|
|
805
|
+
: "";
|
|
806
|
+
tableStyleName = styleBuilder.registerTable(print, (_v = sheet.rightToLeft) !== null && _v !== void 0 ? _v : undefined);
|
|
807
|
+
tableStyleAttr = tableStyleName
|
|
808
|
+
? " table:style-name=\"".concat(tableStyleName, "\"")
|
|
809
|
+
: "";
|
|
810
|
+
printRanges = ((_w = print === null || print === void 0 ? void 0 : print.printArea) !== null && _w !== void 0 ? _w : [])
|
|
811
|
+
.map(function (range) { return buildOdsRangeAddress(range, sheetName); })
|
|
812
|
+
.filter(function (address) { return Boolean(address); });
|
|
813
|
+
printRangesAttr = printRanges.length
|
|
814
|
+
? " table:print-ranges=\"".concat(escapeXml(printRanges.join(" ")), "\"")
|
|
815
|
+
: "";
|
|
816
|
+
sheetXml = "<table:table table:name=\"".concat(escapeXml(sheetName), "\"").concat(tableStyleAttr).concat(protectedAttr).concat(printRangesAttr, ">").concat(shapesXml).concat(columnsXml).concat(rowXmlChunks.join("")).concat(conditionalFormattingXml).concat(sparklineXml, "</table:table>");
|
|
722
817
|
return [2 /*return*/, {
|
|
723
818
|
xml: sheetXml,
|
|
724
819
|
databaseRanges: buildDatabaseRangeEntries(tables, sheetName, sheet, rows),
|
|
@@ -731,9 +826,9 @@ var buildWorksheetXml = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
731
826
|
var buildWorksheetRow = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
732
827
|
var values, cellXmlChunks, minColumn, maxColumn, hasHiddenFlag, defaultRowHeightPx, rowSize, hasExplicitHeight, hasCustomHeight, rowStyle, maxColumnIndex, columnIndex, cell, mergeSpan, cellXml, hasCells, needsMetadata, attrs, rowXml;
|
|
733
828
|
var _c, _d;
|
|
734
|
-
var rowNumber = _b.rowNumber, row = _b.row, rowMetadata = _b.rowMetadata, sourceSharedStrings = _b.sourceSharedStrings, cellXfs = _b.cellXfs, styleBuilder = _b.styleBuilder, mergeState = _b.mergeState, dataValidationsById = _b.dataValidationsById, mediaEntries = _b.mediaEntries, sheet = _b.sheet, namedRangeNames = _b.namedRangeNames, tables = _b.tables, ignoreFormulaPatterns = _b.ignoreFormulaPatterns, annotationsMap = _b.annotationsMap, sheetData = _b.sheetData, sheets = _b.sheets, locale = _b.locale;
|
|
735
|
-
return __generator(this, function (
|
|
736
|
-
switch (
|
|
829
|
+
var rowNumber = _b.rowNumber, row = _b.row, rowMetadata = _b.rowMetadata, _e = _b.breakBefore, breakBefore = _e === void 0 ? false : _e, sourceSharedStrings = _b.sourceSharedStrings, cellXfs = _b.cellXfs, styleBuilder = _b.styleBuilder, mergeState = _b.mergeState, dataValidationsById = _b.dataValidationsById, mediaEntries = _b.mediaEntries, sheet = _b.sheet, namedRangeNames = _b.namedRangeNames, tables = _b.tables, ignoreFormulaPatterns = _b.ignoreFormulaPatterns, annotationsMap = _b.annotationsMap, sheetData = _b.sheetData, sheets = _b.sheets, locale = _b.locale;
|
|
830
|
+
return __generator(this, function (_f) {
|
|
831
|
+
switch (_f.label) {
|
|
737
832
|
case 0:
|
|
738
833
|
values = (_c = row === null || row === void 0 ? void 0 : row.values) !== null && _c !== void 0 ? _c : [];
|
|
739
834
|
cellXmlChunks = [];
|
|
@@ -744,10 +839,10 @@ var buildWorksheetRow = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
744
839
|
rowSize = (rowMetadata === null || rowMetadata === void 0 ? void 0 : rowMetadata.size) && rowMetadata.size > 0 ? rowMetadata.size : undefined;
|
|
745
840
|
hasExplicitHeight = Boolean(rowSize && Math.abs(rowSize - defaultRowHeightPx) > 0.01);
|
|
746
841
|
hasCustomHeight = Boolean(rowSize && (rowMetadata === null || rowMetadata === void 0 ? void 0 : rowMetadata.resizedByUser));
|
|
747
|
-
rowStyle = styleBuilder.registerRow(rowSize && (hasExplicitHeight || hasCustomHeight) ? rowSize : undefined, hasHiddenFlag);
|
|
842
|
+
rowStyle = styleBuilder.registerRow(rowSize && (hasExplicitHeight || hasCustomHeight) ? rowSize : undefined, hasHiddenFlag, breakBefore);
|
|
748
843
|
maxColumnIndex = Math.max(values.length - 1, (_d = mergeState.maxColumnByRow.get(rowNumber)) !== null && _d !== void 0 ? _d : 0);
|
|
749
844
|
columnIndex = 1;
|
|
750
|
-
|
|
845
|
+
_f.label = 1;
|
|
751
846
|
case 1:
|
|
752
847
|
if (!(columnIndex <= maxColumnIndex)) return [3 /*break*/, 4];
|
|
753
848
|
if (mergeState.coveredCells.has("".concat(rowNumber, ":").concat(columnIndex))) {
|
|
@@ -776,7 +871,7 @@ var buildWorksheetRow = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
776
871
|
locale: locale,
|
|
777
872
|
})];
|
|
778
873
|
case 2:
|
|
779
|
-
cellXml =
|
|
874
|
+
cellXml = _f.sent();
|
|
780
875
|
if (!cellXml) {
|
|
781
876
|
cellXmlChunks.push("<table:table-cell/>");
|
|
782
877
|
return [3 /*break*/, 3];
|
|
@@ -784,13 +879,13 @@ var buildWorksheetRow = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
784
879
|
cellXmlChunks.push(cellXml);
|
|
785
880
|
minColumn = Math.min(minColumn, columnIndex);
|
|
786
881
|
maxColumn = Math.max(maxColumn, columnIndex);
|
|
787
|
-
|
|
882
|
+
_f.label = 3;
|
|
788
883
|
case 3:
|
|
789
884
|
columnIndex++;
|
|
790
885
|
return [3 /*break*/, 1];
|
|
791
886
|
case 4:
|
|
792
887
|
hasCells = cellXmlChunks.length > 0;
|
|
793
|
-
needsMetadata = hasHiddenFlag || hasExplicitHeight || hasCustomHeight;
|
|
888
|
+
needsMetadata = hasHiddenFlag || hasExplicitHeight || hasCustomHeight || breakBefore;
|
|
794
889
|
if (!hasCells && !needsMetadata) {
|
|
795
890
|
return [2 /*return*/, null];
|
|
796
891
|
}
|
|
@@ -809,7 +904,7 @@ var buildWorksheetRow = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
809
904
|
}); };
|
|
810
905
|
var buildCellXml = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
811
906
|
var normalizedCell, userEnteredValue, effectiveValue, resolveStyleRef, effectiveFormat, formattedValue, richTextRuns, valueSource, numberValue, boolValue, rawFormulaValue, formulaValue, errorValue, stringValue, sharedStringIndex, sharedStringValue, isDateLike, hasExplicitValue, formatForExport, sheetIdByName_1, sheets_1, sheets_1_1, s, cellXfsRegistry, derived, cellStyle, address, validationRule, validationId, validationAttr, attrs, valueAttr, textNode, errorText, text, resolvedFormula, formulaAttr, arrayRef, spill, cols, rows, hyperlinkValue, href, display, imageXml, annotationXml, annotation, now;
|
|
812
|
-
var
|
|
907
|
+
var e_11, _c;
|
|
813
908
|
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
814
909
|
var rowNumber = _b.rowNumber, columnIndex = _b.columnIndex, cell = _b.cell, sourceSharedStrings = _b.sourceSharedStrings, cellXfs = _b.cellXfs, styleBuilder = _b.styleBuilder, dataValidationsById = _b.dataValidationsById, mergeSpan = _b.mergeSpan, mediaEntries = _b.mediaEntries, sheet = _b.sheet, namedRangeNames = _b.namedRangeNames, tables = _b.tables, ignoreFormulaPatterns = _b.ignoreFormulaPatterns, annotationsMap = _b.annotationsMap, sheetData = _b.sheetData, sheets = _b.sheets, locale = _b.locale;
|
|
815
910
|
return __generator(this, function (_p) {
|
|
@@ -887,12 +982,12 @@ var buildCellXml = function (_a) { return __awaiter(void 0, [_a], void 0, functi
|
|
|
887
982
|
sheetIdByName_1.set(s.title, s.sheetId);
|
|
888
983
|
}
|
|
889
984
|
}
|
|
890
|
-
catch (
|
|
985
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
891
986
|
finally {
|
|
892
987
|
try {
|
|
893
988
|
if (sheets_1_1 && !sheets_1_1.done && (_c = sheets_1.return)) _c.call(sheets_1);
|
|
894
989
|
}
|
|
895
|
-
finally { if (
|
|
990
|
+
finally { if (e_11) throw e_11.error; }
|
|
896
991
|
}
|
|
897
992
|
cellXfsRegistry = cellXfs ? new CellXfsRegistry(cellXfs) : undefined;
|
|
898
993
|
derived = (_k = deriveEffectiveNumberFormatFromFormula(formulaValue, sheet.sheetId, rowNumber, columnIndex, sheetData, function (input) { return defaultTokenizer(input); }, function (name) { var _a; return (_a = sheetIdByName_1.get(name)) !== null && _a !== void 0 ? _a : sheet.sheetId; }, locale, cellXfsRegistry, undefined, typeof numberValue === "number" ? numberValue : null)) !== null && _k !== void 0 ? _k : undefined;
|
|
@@ -1068,7 +1163,7 @@ var resolveStructuredReferencesForOds = function (formula, tables, rowNumber, co
|
|
|
1068
1163
|
return result;
|
|
1069
1164
|
};
|
|
1070
1165
|
var resolveStructuredRefsInSegment = function (segment, tables, rowNumber, columnIndex) {
|
|
1071
|
-
var
|
|
1166
|
+
var e_12, _a, e_13, _b, e_14, _c, e_15, _d;
|
|
1072
1167
|
var _e, _f;
|
|
1073
1168
|
if (!segment)
|
|
1074
1169
|
return segment;
|
|
@@ -1092,7 +1187,7 @@ var resolveStructuredRefsInSegment = function (segment, tables, rowNumber, colum
|
|
|
1092
1187
|
if (!escapedColumn)
|
|
1093
1188
|
continue;
|
|
1094
1189
|
try {
|
|
1095
|
-
for (var nameVariants_1 = (
|
|
1190
|
+
for (var nameVariants_1 = (e_13 = void 0, __values(nameVariants)), nameVariants_1_1 = nameVariants_1.next(); !nameVariants_1_1.done; nameVariants_1_1 = nameVariants_1.next()) {
|
|
1096
1191
|
var tableName = nameVariants_1_1.value;
|
|
1097
1192
|
var escapedTable = escapeCharacters(tableName);
|
|
1098
1193
|
if (!escapedTable)
|
|
@@ -1103,26 +1198,26 @@ var resolveStructuredRefsInSegment = function (segment, tables, rowNumber, colum
|
|
|
1103
1198
|
"".concat(escapedTable, "\\[\\@").concat(escapedColumn, "\\]"),
|
|
1104
1199
|
];
|
|
1105
1200
|
try {
|
|
1106
|
-
for (var patterns_1 = (
|
|
1201
|
+
for (var patterns_1 = (e_14 = void 0, __values(patterns)), patterns_1_1 = patterns_1.next(); !patterns_1_1.done; patterns_1_1 = patterns_1.next()) {
|
|
1107
1202
|
var pattern = patterns_1_1.value;
|
|
1108
1203
|
normalized = normalized.replace(new RegExp(pattern, "g"), cellRef);
|
|
1109
1204
|
}
|
|
1110
1205
|
}
|
|
1111
|
-
catch (
|
|
1206
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
1112
1207
|
finally {
|
|
1113
1208
|
try {
|
|
1114
1209
|
if (patterns_1_1 && !patterns_1_1.done && (_c = patterns_1.return)) _c.call(patterns_1);
|
|
1115
1210
|
}
|
|
1116
|
-
finally { if (
|
|
1211
|
+
finally { if (e_14) throw e_14.error; }
|
|
1117
1212
|
}
|
|
1118
1213
|
}
|
|
1119
1214
|
}
|
|
1120
|
-
catch (
|
|
1215
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
1121
1216
|
finally {
|
|
1122
1217
|
try {
|
|
1123
1218
|
if (nameVariants_1_1 && !nameVariants_1_1.done && (_b = nameVariants_1.return)) _b.call(nameVariants_1);
|
|
1124
1219
|
}
|
|
1125
|
-
finally { if (
|
|
1220
|
+
finally { if (e_13) throw e_13.error; }
|
|
1126
1221
|
}
|
|
1127
1222
|
if ((tableForCell === null || tableForCell === void 0 ? void 0 : tableForCell.id) !== table.id) {
|
|
1128
1223
|
continue;
|
|
@@ -1133,27 +1228,27 @@ var resolveStructuredRefsInSegment = function (segment, tables, rowNumber, colum
|
|
|
1133
1228
|
"\\[\\@".concat(escapedColumn, "\\]"),
|
|
1134
1229
|
];
|
|
1135
1230
|
try {
|
|
1136
|
-
for (var unqualifiedPatterns_1 = (
|
|
1231
|
+
for (var unqualifiedPatterns_1 = (e_15 = void 0, __values(unqualifiedPatterns)), unqualifiedPatterns_1_1 = unqualifiedPatterns_1.next(); !unqualifiedPatterns_1_1.done; unqualifiedPatterns_1_1 = unqualifiedPatterns_1.next()) {
|
|
1137
1232
|
var pattern = unqualifiedPatterns_1_1.value;
|
|
1138
1233
|
normalized = normalized.replace(new RegExp(pattern, "g"), cellRef);
|
|
1139
1234
|
}
|
|
1140
1235
|
}
|
|
1141
|
-
catch (
|
|
1236
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
1142
1237
|
finally {
|
|
1143
1238
|
try {
|
|
1144
1239
|
if (unqualifiedPatterns_1_1 && !unqualifiedPatterns_1_1.done && (_d = unqualifiedPatterns_1.return)) _d.call(unqualifiedPatterns_1);
|
|
1145
1240
|
}
|
|
1146
|
-
finally { if (
|
|
1241
|
+
finally { if (e_15) throw e_15.error; }
|
|
1147
1242
|
}
|
|
1148
1243
|
}
|
|
1149
1244
|
}
|
|
1150
1245
|
}
|
|
1151
|
-
catch (
|
|
1246
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
1152
1247
|
finally {
|
|
1153
1248
|
try {
|
|
1154
1249
|
if (tables_1_1 && !tables_1_1.done && (_a = tables_1.return)) _a.call(tables_1);
|
|
1155
1250
|
}
|
|
1156
|
-
finally { if (
|
|
1251
|
+
finally { if (e_12) throw e_12.error; }
|
|
1157
1252
|
}
|
|
1158
1253
|
return normalized;
|
|
1159
1254
|
};
|
|
@@ -1204,9 +1299,116 @@ var buildContentXml = function (_a) {
|
|
|
1204
1299
|
var sheetsXml = _a.sheetsXml, databaseRangesXml = _a.databaseRangesXml, namedRangesXml = _a.namedRangesXml, contentValidationsXml = _a.contentValidationsXml, automaticStylesXml = _a.automaticStylesXml, calculationSettingsXml = _a.calculationSettingsXml;
|
|
1205
1300
|
return "".concat(XML_DECLARATION, "<office:document-content xmlns:office=\"").concat(ODS_NS.office, "\" xmlns:style=\"").concat(ODS_NS.style, "\" xmlns:text=\"").concat(ODS_NS.text, "\" xmlns:table=\"").concat(ODS_NS.table, "\" xmlns:draw=\"").concat(ODS_NS.draw, "\" xmlns:fo=\"").concat(ODS_NS.fo, "\" xmlns:xlink=\"").concat(ODS_NS.xlink, "\" xmlns:svg=\"").concat(ODS_NS.svg, "\" xmlns:number=\"").concat(ODS_NS.number, "\" xmlns:of=\"").concat(ODS_NS.of, "\" xmlns:calcext=\"").concat(ODS_NS.calcext, "\" xmlns:dc=\"").concat(ODS_NS.dc, "\" office:version=\"1.2\"><office:scripts/><office:automatic-styles>").concat(automaticStylesXml, "</office:automatic-styles><office:body><office:spreadsheet>").concat(calculationSettingsXml).concat(contentValidationsXml).concat(sheetsXml).concat(namedRangesXml).concat(databaseRangesXml, "</office:spreadsheet></office:body></office:document-content>");
|
|
1206
1301
|
};
|
|
1207
|
-
var buildStylesXml = function (conditionalStylesXml) {
|
|
1302
|
+
var buildStylesXml = function (conditionalStylesXml, pageLayoutsXml, masterPagesXml) {
|
|
1208
1303
|
if (conditionalStylesXml === void 0) { conditionalStylesXml = ""; }
|
|
1209
|
-
|
|
1304
|
+
if (pageLayoutsXml === void 0) { pageLayoutsXml = ""; }
|
|
1305
|
+
if (masterPagesXml === void 0) { masterPagesXml = ""; }
|
|
1306
|
+
var automaticStyles = pageLayoutsXml
|
|
1307
|
+
? "<office:automatic-styles>".concat(pageLayoutsXml, "</office:automatic-styles>")
|
|
1308
|
+
: "<office:automatic-styles/>";
|
|
1309
|
+
var masterStyles = masterPagesXml
|
|
1310
|
+
? "<office:master-styles>".concat(masterPagesXml, "</office:master-styles>")
|
|
1311
|
+
: "<office:master-styles/>";
|
|
1312
|
+
return "".concat(XML_DECLARATION, "<office:document-styles xmlns:office=\"").concat(ODS_NS.office, "\" xmlns:style=\"").concat(ODS_NS.style, "\" xmlns:text=\"").concat(ODS_NS.text, "\" xmlns:table=\"").concat(ODS_NS.table, "\" xmlns:draw=\"").concat(ODS_NS.draw, "\" xmlns:fo=\"").concat(ODS_NS.fo, "\" xmlns:xlink=\"").concat(ODS_NS.xlink, "\" xmlns:svg=\"").concat(ODS_NS.svg, "\" xmlns:number=\"").concat(ODS_NS.number, "\" xmlns:loext=\"urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0\" office:version=\"1.2\"><office:styles><style:style style:name=\"Default\" style:family=\"table-cell\"><style:paragraph-properties fo:margin-left=\"0cm\" fo:margin-right=\"0cm\"/></style:style>").concat(conditionalStylesXml, "</office:styles>").concat(automaticStyles).concat(masterStyles, "</office:document-styles>");
|
|
1313
|
+
};
|
|
1314
|
+
/**
|
|
1315
|
+
* `<style:page-layout-properties>` (+ header/footer styles) for a sheet's
|
|
1316
|
+
* page setup, margins and print options. ODF keeps the header INSIDE the
|
|
1317
|
+
* top margin, so Excel's `header` (edge → header) becomes `fo:margin-top`
|
|
1318
|
+
* and `top - header` the header's `fo:min-height`; footer likewise.
|
|
1319
|
+
*/
|
|
1320
|
+
var buildOdsPageLayoutXml = function (print) {
|
|
1321
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1322
|
+
var setup = print === null || print === void 0 ? void 0 : print.pageSetup;
|
|
1323
|
+
var margins = print === null || print === void 0 ? void 0 : print.pageMargins;
|
|
1324
|
+
var options = print === null || print === void 0 ? void 0 : print.printOptions;
|
|
1325
|
+
if (!setup && !margins && !options)
|
|
1326
|
+
return undefined;
|
|
1327
|
+
var attrs = [];
|
|
1328
|
+
var landscape = (setup === null || setup === void 0 ? void 0 : setup.orientation) === "landscape";
|
|
1329
|
+
var paper = paperSizeToCm(setup === null || setup === void 0 ? void 0 : setup.paperSize);
|
|
1330
|
+
if (paper) {
|
|
1331
|
+
var width = landscape ? paper.height : paper.width;
|
|
1332
|
+
var height = landscape ? paper.width : paper.height;
|
|
1333
|
+
attrs.push("fo:page-width=\"".concat(width.toFixed(3), "cm\""), "fo:page-height=\"".concat(height.toFixed(3), "cm\""));
|
|
1334
|
+
}
|
|
1335
|
+
if (setup === null || setup === void 0 ? void 0 : setup.orientation) {
|
|
1336
|
+
attrs.push("style:print-orientation=\"".concat(setup.orientation, "\""));
|
|
1337
|
+
}
|
|
1338
|
+
var left = (_a = margins === null || margins === void 0 ? void 0 : margins.left) !== null && _a !== void 0 ? _a : DEFAULT_PAGE_MARGINS_IN.left;
|
|
1339
|
+
var right = (_b = margins === null || margins === void 0 ? void 0 : margins.right) !== null && _b !== void 0 ? _b : DEFAULT_PAGE_MARGINS_IN.right;
|
|
1340
|
+
var top = (_c = margins === null || margins === void 0 ? void 0 : margins.top) !== null && _c !== void 0 ? _c : DEFAULT_PAGE_MARGINS_IN.top;
|
|
1341
|
+
var bottom = (_d = margins === null || margins === void 0 ? void 0 : margins.bottom) !== null && _d !== void 0 ? _d : DEFAULT_PAGE_MARGINS_IN.bottom;
|
|
1342
|
+
var header = Math.min((_e = margins === null || margins === void 0 ? void 0 : margins.header) !== null && _e !== void 0 ? _e : DEFAULT_PAGE_MARGINS_IN.header, top);
|
|
1343
|
+
var footer = Math.min((_f = margins === null || margins === void 0 ? void 0 : margins.footer) !== null && _f !== void 0 ? _f : DEFAULT_PAGE_MARGINS_IN.footer, bottom);
|
|
1344
|
+
attrs.push("fo:margin-top=\"".concat(inchesToOdsCm(header), "\""), "fo:margin-bottom=\"".concat(inchesToOdsCm(footer), "\""), "fo:margin-left=\"".concat(inchesToOdsCm(left), "\""), "fo:margin-right=\"".concat(inchesToOdsCm(right), "\""));
|
|
1345
|
+
if (setup === null || setup === void 0 ? void 0 : setup.fitToPage) {
|
|
1346
|
+
// LibreOffice's per-axis fit (`loext:scale-to-X/Y`); 0 = automatic.
|
|
1347
|
+
attrs.push("loext:scale-to-X=\"".concat((_g = setup.fitToWidth) !== null && _g !== void 0 ? _g : 1, "\""), "loext:scale-to-Y=\"".concat((_h = setup.fitToHeight) !== null && _h !== void 0 ? _h : 1, "\""));
|
|
1348
|
+
}
|
|
1349
|
+
else if (typeof (setup === null || setup === void 0 ? void 0 : setup.scale) === "number" && setup.scale > 0) {
|
|
1350
|
+
attrs.push("style:scale-to=\"".concat(setup.scale, "%\""));
|
|
1351
|
+
}
|
|
1352
|
+
var centering = odsTableCentering(options);
|
|
1353
|
+
if (centering)
|
|
1354
|
+
attrs.push("style:table-centering=\"".concat(centering, "\""));
|
|
1355
|
+
attrs.push("style:print=\"".concat(buildOdsPrintTokens(options), "\""));
|
|
1356
|
+
if ((setup === null || setup === void 0 ? void 0 : setup.pageOrder) === "overThenDown") {
|
|
1357
|
+
attrs.push("style:print-page-order=\"ltr\"");
|
|
1358
|
+
}
|
|
1359
|
+
if (typeof (setup === null || setup === void 0 ? void 0 : setup.firstPageNumber) === "number" &&
|
|
1360
|
+
setup.useFirstPageNumber !== false) {
|
|
1361
|
+
attrs.push("style:first-page-number=\"".concat(setup.firstPageNumber, "\""));
|
|
1362
|
+
}
|
|
1363
|
+
var headerStyle = "<style:header-style><style:header-footer-properties fo:min-height=\"".concat(inchesToOdsCm(Math.max(0, top - header)), "\" fo:margin-bottom=\"0cm\"/></style:header-style>");
|
|
1364
|
+
var footerStyle = "<style:footer-style><style:header-footer-properties fo:min-height=\"".concat(inchesToOdsCm(Math.max(0, bottom - footer)), "\" fo:margin-top=\"0cm\"/></style:footer-style>");
|
|
1365
|
+
return "<style:page-layout-properties ".concat(attrs.join(" "), "/>").concat(headerStyle).concat(footerStyle);
|
|
1366
|
+
};
|
|
1367
|
+
var odsFieldXml = function (token) {
|
|
1368
|
+
if (token.type === "text") {
|
|
1369
|
+
return token.text
|
|
1370
|
+
.split("\n")
|
|
1371
|
+
.map(function (line) { return escapeXml(line); })
|
|
1372
|
+
.join("<text:line-break/>");
|
|
1373
|
+
}
|
|
1374
|
+
switch (token.field) {
|
|
1375
|
+
case "page":
|
|
1376
|
+
return "<text:page-number>1</text:page-number>";
|
|
1377
|
+
case "pages":
|
|
1378
|
+
return "<text:page-count>1</text:page-count>";
|
|
1379
|
+
case "date":
|
|
1380
|
+
return "<text:date/>";
|
|
1381
|
+
case "time":
|
|
1382
|
+
return "<text:time/>";
|
|
1383
|
+
case "sheet":
|
|
1384
|
+
return "<text:sheet-name/>";
|
|
1385
|
+
case "file":
|
|
1386
|
+
return '<text:file-name text:display="name"/>';
|
|
1387
|
+
case "path":
|
|
1388
|
+
return '<text:file-name text:display="path"/>';
|
|
1389
|
+
default:
|
|
1390
|
+
return "";
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
var odsHeaderZoneXml = function (code) {
|
|
1394
|
+
return code
|
|
1395
|
+
? "<text:p>".concat(tokenizeHeaderFooterZone(code).map(odsFieldXml).join(""), "</text:p>")
|
|
1396
|
+
: "";
|
|
1397
|
+
};
|
|
1398
|
+
/**
|
|
1399
|
+
* Excel header/footer code → `<style:header>` / `<style:footer>` with
|
|
1400
|
+
* `&L` / `&C` / `&R` zones as ODF regions and field macros as `<text:*>`
|
|
1401
|
+
* fields. Formatting codes have no ODF counterpart and are dropped; an
|
|
1402
|
+
* absent code yields a hidden (`style:display="false"`) element.
|
|
1403
|
+
*/
|
|
1404
|
+
var buildOdsHeaderFooterXml = function (tag, code) {
|
|
1405
|
+
if (!code)
|
|
1406
|
+
return "<".concat(tag, " style:display=\"false\"/>");
|
|
1407
|
+
var zones = splitHeaderFooterZones(code);
|
|
1408
|
+
if (!zones.left && !zones.right) {
|
|
1409
|
+
return "<".concat(tag, ">").concat(odsHeaderZoneXml(zones.center), "</").concat(tag, ">");
|
|
1410
|
+
}
|
|
1411
|
+
return "<".concat(tag, "><style:region-left>").concat(odsHeaderZoneXml(zones.left), "</style:region-left><style:region-center>").concat(odsHeaderZoneXml(zones.center), "</style:region-center><style:region-right>").concat(odsHeaderZoneXml(zones.right), "</style:region-right></").concat(tag, ">");
|
|
1210
1412
|
};
|
|
1211
1413
|
var buildMetaXml = function () {
|
|
1212
1414
|
var now = new Date().toISOString();
|
|
@@ -1272,52 +1474,80 @@ var buildFreezeCell = function (rows, columns) {
|
|
|
1272
1474
|
var row = Math.max(1, rows + 1);
|
|
1273
1475
|
return "".concat(col).concat(row);
|
|
1274
1476
|
};
|
|
1275
|
-
var buildColumnsXml = function (sheet, styleBuilder, bounds) {
|
|
1276
|
-
var
|
|
1277
|
-
var _c, _d, _e, _f;
|
|
1477
|
+
var buildColumnsXml = function (sheet, styleBuilder, bounds, print) {
|
|
1478
|
+
var e_16, _a, e_17, _b;
|
|
1479
|
+
var _c, _d, _e, _f, _g, _h;
|
|
1278
1480
|
var metadata = (_c = sheet.columnMetadata) !== null && _c !== void 0 ? _c : [];
|
|
1279
|
-
var
|
|
1481
|
+
var columnBreakSet = new Set(((_d = print === null || print === void 0 ? void 0 : print.columnBreaks) !== null && _d !== void 0 ? _d : []).filter(function (n) { return Number.isInteger(n) && n >= 1; }));
|
|
1482
|
+
var titles = print === null || print === void 0 ? void 0 : print.printTitles;
|
|
1483
|
+
var titleColumns = (titles === null || titles === void 0 ? void 0 : titles.columnStart) != null && titles.columnEnd != null
|
|
1484
|
+
? {
|
|
1485
|
+
start: Math.max(1, titles.columnStart),
|
|
1486
|
+
end: Math.max(titles.columnStart, titles.columnEnd),
|
|
1487
|
+
}
|
|
1488
|
+
: undefined;
|
|
1489
|
+
var maxColumns = Math.max(metadata.length - 1, bounds.maxColumn || 0, columnBreakSet.size ? Math.max.apply(Math, __spreadArray([], __read(columnBreakSet), false)) + 1 : 0, (_e = titleColumns === null || titleColumns === void 0 ? void 0 : titleColumns.end) !== null && _e !== void 0 ? _e : 0);
|
|
1280
1490
|
if (!maxColumns)
|
|
1281
1491
|
return "";
|
|
1282
|
-
var summaryRight = ((
|
|
1492
|
+
var summaryRight = ((_f = sheet.outlinePr) === null || _f === void 0 ? void 0 : _f.summaryRight) !== false;
|
|
1283
1493
|
var spans = findOutlineGroupSpans(metadata, maxColumns, summaryRight);
|
|
1284
|
-
var
|
|
1494
|
+
var _j = buildOutlineGroupIndex(spans), opensAt = _j.opensAt, closesAt = _j.closesAt;
|
|
1285
1495
|
var parts = [];
|
|
1496
|
+
// Same rule as the row band: `<table:table-header-columns>` holds plain
|
|
1497
|
+
// columns only, so it closes around a column-group edge and re-opens.
|
|
1498
|
+
var headerColumnsOpen = false;
|
|
1286
1499
|
for (var index = 1; index <= maxColumns; index++) {
|
|
1500
|
+
var opens = (_g = opensAt.get(index)) !== null && _g !== void 0 ? _g : [];
|
|
1501
|
+
if (opens.length && headerColumnsOpen) {
|
|
1502
|
+
parts.push("</table:table-header-columns>");
|
|
1503
|
+
headerColumnsOpen = false;
|
|
1504
|
+
}
|
|
1287
1505
|
try {
|
|
1288
|
-
for (var
|
|
1289
|
-
var span =
|
|
1506
|
+
for (var opens_2 = (e_16 = void 0, __values(opens)), opens_2_1 = opens_2.next(); !opens_2_1.done; opens_2_1 = opens_2.next()) {
|
|
1507
|
+
var span = opens_2_1.value;
|
|
1290
1508
|
parts.push(outlineGroupOpenTag(span, "table:table-column-group"));
|
|
1291
1509
|
}
|
|
1292
1510
|
}
|
|
1293
|
-
catch (
|
|
1511
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
1294
1512
|
finally {
|
|
1295
1513
|
try {
|
|
1296
|
-
if (
|
|
1514
|
+
if (opens_2_1 && !opens_2_1.done && (_a = opens_2.return)) _a.call(opens_2);
|
|
1297
1515
|
}
|
|
1298
|
-
finally { if (
|
|
1516
|
+
finally { if (e_16) throw e_16.error; }
|
|
1517
|
+
}
|
|
1518
|
+
if (!headerColumnsOpen &&
|
|
1519
|
+
titleColumns &&
|
|
1520
|
+
index >= titleColumns.start &&
|
|
1521
|
+
index <= titleColumns.end) {
|
|
1522
|
+
parts.push("<table:table-header-columns>");
|
|
1523
|
+
headerColumnsOpen = true;
|
|
1299
1524
|
}
|
|
1300
1525
|
var props = metadata[index];
|
|
1301
1526
|
var widthPx = getColumnWidthPx(sheet, index);
|
|
1302
1527
|
var hidden = Boolean((props === null || props === void 0 ? void 0 : props.hiddenByUser) || (props === null || props === void 0 ? void 0 : props.hiddenByFilter));
|
|
1303
|
-
var styleName = styleBuilder.registerColumn(widthPx, hidden);
|
|
1528
|
+
var styleName = styleBuilder.registerColumn(widthPx, hidden, columnBreakSet.has(index - 1));
|
|
1304
1529
|
var attrs = [];
|
|
1305
1530
|
if (styleName) {
|
|
1306
1531
|
attrs.push("table:style-name=\"".concat(styleName, "\""));
|
|
1307
1532
|
}
|
|
1308
1533
|
parts.push("<table:table-column".concat(attrs.length ? " " + attrs.join(" ") : "", "/>"));
|
|
1534
|
+
var closes = (_h = closesAt.get(index)) !== null && _h !== void 0 ? _h : [];
|
|
1535
|
+
if (headerColumnsOpen && (index === (titleColumns === null || titleColumns === void 0 ? void 0 : titleColumns.end) || closes.length)) {
|
|
1536
|
+
parts.push("</table:table-header-columns>");
|
|
1537
|
+
headerColumnsOpen = false;
|
|
1538
|
+
}
|
|
1309
1539
|
try {
|
|
1310
|
-
for (var
|
|
1311
|
-
var
|
|
1540
|
+
for (var closes_2 = (e_17 = void 0, __values(closes)), closes_2_1 = closes_2.next(); !closes_2_1.done; closes_2_1 = closes_2.next()) {
|
|
1541
|
+
var _2 = closes_2_1.value;
|
|
1312
1542
|
parts.push("</table:table-column-group>");
|
|
1313
1543
|
}
|
|
1314
1544
|
}
|
|
1315
|
-
catch (
|
|
1545
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
1316
1546
|
finally {
|
|
1317
1547
|
try {
|
|
1318
|
-
if (
|
|
1548
|
+
if (closes_2_1 && !closes_2_1.done && (_b = closes_2.return)) _b.call(closes_2);
|
|
1319
1549
|
}
|
|
1320
|
-
finally { if (
|
|
1550
|
+
finally { if (e_17) throw e_17.error; }
|
|
1321
1551
|
}
|
|
1322
1552
|
}
|
|
1323
1553
|
return parts.join("");
|
|
@@ -1452,7 +1682,7 @@ var buildTextStyleXml = function (name, textFormat, theme) {
|
|
|
1452
1682
|
return "<style:style style:name=\"".concat(name, "\" style:family=\"text\"><style:text-properties").concat(textProps.length ? " " + textProps.join(" ") : "", "/></style:style>");
|
|
1453
1683
|
};
|
|
1454
1684
|
var buildRichTextParagraph = function (text, runs, styleBuilder) {
|
|
1455
|
-
var
|
|
1685
|
+
var e_18, _a;
|
|
1456
1686
|
if (!(runs === null || runs === void 0 ? void 0 : runs.length)) {
|
|
1457
1687
|
return "<text:p>".concat(escapeXml(String(text)), "</text:p>");
|
|
1458
1688
|
}
|
|
@@ -1479,19 +1709,20 @@ var buildRichTextParagraph = function (text, runs, styleBuilder) {
|
|
|
1479
1709
|
cursor = endIndex;
|
|
1480
1710
|
}
|
|
1481
1711
|
}
|
|
1482
|
-
catch (
|
|
1712
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
1483
1713
|
finally {
|
|
1484
1714
|
try {
|
|
1485
1715
|
if (sortedRuns_1_1 && !sortedRuns_1_1.done && (_a = sortedRuns_1.return)) _a.call(sortedRuns_1);
|
|
1486
1716
|
}
|
|
1487
|
-
finally { if (
|
|
1717
|
+
finally { if (e_18) throw e_18.error; }
|
|
1488
1718
|
}
|
|
1489
1719
|
if (cursor < text.length) {
|
|
1490
1720
|
parts.push(escapeXml(text.slice(cursor)));
|
|
1491
1721
|
}
|
|
1492
1722
|
return "<text:p>".concat(parts.join(""), "</text:p>");
|
|
1493
1723
|
};
|
|
1494
|
-
var buildRowStyleXml = function (name, heightPx, hidden) {
|
|
1724
|
+
var buildRowStyleXml = function (name, heightPx, hidden, breakBefore) {
|
|
1725
|
+
if (breakBefore === void 0) { breakBefore = false; }
|
|
1495
1726
|
var props = [];
|
|
1496
1727
|
if (heightPx) {
|
|
1497
1728
|
props.push("style:row-height=\"".concat(pxToCm(heightPx).toFixed(2), "cm\""));
|
|
@@ -1499,9 +1730,13 @@ var buildRowStyleXml = function (name, heightPx, hidden) {
|
|
|
1499
1730
|
if (hidden) {
|
|
1500
1731
|
props.push("style:visibility=\"collapse\"");
|
|
1501
1732
|
}
|
|
1733
|
+
if (breakBefore) {
|
|
1734
|
+
props.push("fo:break-before=\"page\"");
|
|
1735
|
+
}
|
|
1502
1736
|
return "<style:style style:name=\"".concat(name, "\" style:family=\"table-row\"><style:table-row-properties").concat(props.length ? " " + props.join(" ") : "", "/></style:style>");
|
|
1503
1737
|
};
|
|
1504
|
-
var buildColumnStyleXml = function (name, widthPx, hidden) {
|
|
1738
|
+
var buildColumnStyleXml = function (name, widthPx, hidden, breakBefore) {
|
|
1739
|
+
if (breakBefore === void 0) { breakBefore = false; }
|
|
1505
1740
|
var props = [];
|
|
1506
1741
|
if (widthPx) {
|
|
1507
1742
|
props.push("style:column-width=\"".concat(pxToCm(widthPx).toFixed(2), "cm\""));
|
|
@@ -1509,6 +1744,9 @@ var buildColumnStyleXml = function (name, widthPx, hidden) {
|
|
|
1509
1744
|
if (hidden) {
|
|
1510
1745
|
props.push("style:visibility=\"collapse\"");
|
|
1511
1746
|
}
|
|
1747
|
+
if (breakBefore) {
|
|
1748
|
+
props.push("fo:break-before=\"page\"");
|
|
1749
|
+
}
|
|
1512
1750
|
return "<style:style style:name=\"".concat(name, "\" style:family=\"table-column\"><style:table-column-properties").concat(props.length ? " " + props.join(" ") : "", "/></style:style>");
|
|
1513
1751
|
};
|
|
1514
1752
|
var buildNumberStyleXml = function (name, format) {
|
|
@@ -1574,7 +1812,7 @@ var buildAllDataValidationEntries = function (rules, sheetNameById) {
|
|
|
1574
1812
|
return entries;
|
|
1575
1813
|
};
|
|
1576
1814
|
var buildConditionalFormattingXml = function (_a) {
|
|
1577
|
-
var
|
|
1815
|
+
var e_19, _b;
|
|
1578
1816
|
var _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1579
1817
|
var conditionalFormats = _a.conditionalFormats, sheetName = _a.sheetName, styleBuilder = _a.styleBuilder, namedRangeNames = _a.namedRangeNames;
|
|
1580
1818
|
var entries = [];
|
|
@@ -2016,12 +2254,12 @@ var buildConditionalFormattingXml = function (_a) {
|
|
|
2016
2254
|
_loop_2(rule);
|
|
2017
2255
|
}
|
|
2018
2256
|
}
|
|
2019
|
-
catch (
|
|
2257
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
2020
2258
|
finally {
|
|
2021
2259
|
try {
|
|
2022
2260
|
if (orderedRules_1_1 && !orderedRules_1_1.done && (_b = orderedRules_1.return)) _b.call(orderedRules_1);
|
|
2023
2261
|
}
|
|
2024
|
-
finally { if (
|
|
2262
|
+
finally { if (e_19) throw e_19.error; }
|
|
2025
2263
|
}
|
|
2026
2264
|
if (!entries.length)
|
|
2027
2265
|
return "";
|
|
@@ -2048,7 +2286,7 @@ var getFilterVisibleValues = function (spec, range, rows, headerRow, totalRow) {
|
|
|
2048
2286
|
return __spreadArray([], __read(values), false);
|
|
2049
2287
|
};
|
|
2050
2288
|
var buildDatabaseRangeEntries = function (tables, sheetName, sheet, rows) {
|
|
2051
|
-
var
|
|
2289
|
+
var e_20, _a;
|
|
2052
2290
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2053
2291
|
var entries = [];
|
|
2054
2292
|
var basicFilter = sheet.basicFilter;
|
|
@@ -2079,12 +2317,12 @@ var buildDatabaseRangeEntries = function (tables, sheetName, sheet, rows) {
|
|
|
2079
2317
|
entries.push("<table:database-range ".concat(attrs.join(" "), ">").concat(filterXml).concat(sortXml, "</table:database-range>"));
|
|
2080
2318
|
}
|
|
2081
2319
|
}
|
|
2082
|
-
catch (
|
|
2320
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
2083
2321
|
finally {
|
|
2084
2322
|
try {
|
|
2085
2323
|
if (tables_2_1 && !tables_2_1.done && (_a = tables_2.return)) _a.call(tables_2);
|
|
2086
2324
|
}
|
|
2087
|
-
finally { if (
|
|
2325
|
+
finally { if (e_20) throw e_20.error; }
|
|
2088
2326
|
}
|
|
2089
2327
|
if (basicFilter &&
|
|
2090
2328
|
!tables.some(function (table) { return rangesEqual(table.range, basicFilter.range); })) {
|
|
@@ -2104,7 +2342,7 @@ var buildDatabaseRangesXml = function (entries) {
|
|
|
2104
2342
|
return "<table:database-ranges>".concat(entries.join(""), "</table:database-ranges>");
|
|
2105
2343
|
};
|
|
2106
2344
|
var buildNamedRangesXml = function (namedRanges, sheetNameById, namedRangeNames) {
|
|
2107
|
-
var
|
|
2345
|
+
var e_21, _a;
|
|
2108
2346
|
var _b;
|
|
2109
2347
|
if (!(namedRanges === null || namedRanges === void 0 ? void 0 : namedRanges.length))
|
|
2110
2348
|
return "";
|
|
@@ -2141,19 +2379,19 @@ var buildNamedRangesXml = function (namedRanges, sheetNameById, namedRangeNames)
|
|
|
2141
2379
|
}
|
|
2142
2380
|
}
|
|
2143
2381
|
}
|
|
2144
|
-
catch (
|
|
2382
|
+
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
2145
2383
|
finally {
|
|
2146
2384
|
try {
|
|
2147
2385
|
if (namedRanges_1_1 && !namedRanges_1_1.done && (_a = namedRanges_1.return)) _a.call(namedRanges_1);
|
|
2148
2386
|
}
|
|
2149
|
-
finally { if (
|
|
2387
|
+
finally { if (e_21) throw e_21.error; }
|
|
2150
2388
|
}
|
|
2151
2389
|
if (!ranges.length && !expressions.length)
|
|
2152
2390
|
return "";
|
|
2153
2391
|
return "<table:named-expressions>".concat(ranges.join("")).concat(expressions.join(""), "</table:named-expressions>");
|
|
2154
2392
|
};
|
|
2155
2393
|
var buildFilterXml = function (filterSpecs, range, rows, headerRow, totalRow) {
|
|
2156
|
-
var
|
|
2394
|
+
var e_22, _a, e_23, _b, e_24, _c;
|
|
2157
2395
|
var _d, _e, _f;
|
|
2158
2396
|
if (headerRow === void 0) { headerRow = true; }
|
|
2159
2397
|
if (totalRow === void 0) { totalRow = false; }
|
|
@@ -2188,39 +2426,39 @@ var buildFilterXml = function (filterSpecs, range, rows, headerRow, totalRow) {
|
|
|
2188
2426
|
var visibleValues = (_e = criteria === null || criteria === void 0 ? void 0 : criteria.visibleValues) !== null && _e !== void 0 ? _e : getFilterVisibleValues(spec, range, rows, headerRow, totalRow);
|
|
2189
2427
|
var hiddenValues = (_f = criteria === null || criteria === void 0 ? void 0 : criteria.hiddenValues) !== null && _f !== void 0 ? _f : [];
|
|
2190
2428
|
try {
|
|
2191
|
-
for (var visibleValues_1 = (
|
|
2429
|
+
for (var visibleValues_1 = (e_23 = void 0, __values(visibleValues)), visibleValues_1_1 = visibleValues_1.next(); !visibleValues_1_1.done; visibleValues_1_1 = visibleValues_1.next()) {
|
|
2192
2430
|
var value = visibleValues_1_1.value;
|
|
2193
2431
|
conditions.push("<table:filter-condition table:field-number=\"".concat(spec.columnIndex, "\" table:operator=\"=\" table:value=\"").concat(escapeXml(value), "\"/>"));
|
|
2194
2432
|
}
|
|
2195
2433
|
}
|
|
2196
|
-
catch (
|
|
2434
|
+
catch (e_23_1) { e_23 = { error: e_23_1 }; }
|
|
2197
2435
|
finally {
|
|
2198
2436
|
try {
|
|
2199
2437
|
if (visibleValues_1_1 && !visibleValues_1_1.done && (_b = visibleValues_1.return)) _b.call(visibleValues_1);
|
|
2200
2438
|
}
|
|
2201
|
-
finally { if (
|
|
2439
|
+
finally { if (e_23) throw e_23.error; }
|
|
2202
2440
|
}
|
|
2203
2441
|
try {
|
|
2204
|
-
for (var hiddenValues_1 = (
|
|
2442
|
+
for (var hiddenValues_1 = (e_24 = void 0, __values(hiddenValues)), hiddenValues_1_1 = hiddenValues_1.next(); !hiddenValues_1_1.done; hiddenValues_1_1 = hiddenValues_1.next()) {
|
|
2205
2443
|
var value = hiddenValues_1_1.value;
|
|
2206
2444
|
conditions.push("<table:filter-condition table:field-number=\"".concat(spec.columnIndex, "\" table:operator=\"!=\" table:value=\"").concat(escapeXml(value), "\"/>"));
|
|
2207
2445
|
}
|
|
2208
2446
|
}
|
|
2209
|
-
catch (
|
|
2447
|
+
catch (e_24_1) { e_24 = { error: e_24_1 }; }
|
|
2210
2448
|
finally {
|
|
2211
2449
|
try {
|
|
2212
2450
|
if (hiddenValues_1_1 && !hiddenValues_1_1.done && (_c = hiddenValues_1.return)) _c.call(hiddenValues_1);
|
|
2213
2451
|
}
|
|
2214
|
-
finally { if (
|
|
2452
|
+
finally { if (e_24) throw e_24.error; }
|
|
2215
2453
|
}
|
|
2216
2454
|
}
|
|
2217
2455
|
}
|
|
2218
|
-
catch (
|
|
2456
|
+
catch (e_22_1) { e_22 = { error: e_22_1 }; }
|
|
2219
2457
|
finally {
|
|
2220
2458
|
try {
|
|
2221
2459
|
if (filterSpecs_1_1 && !filterSpecs_1_1.done && (_a = filterSpecs_1.return)) _a.call(filterSpecs_1);
|
|
2222
2460
|
}
|
|
2223
|
-
finally { if (
|
|
2461
|
+
finally { if (e_22) throw e_22.error; }
|
|
2224
2462
|
}
|
|
2225
2463
|
if (!conditions.length)
|
|
2226
2464
|
return "";
|
|
@@ -2300,7 +2538,7 @@ var resolveCellDataValidation = function (cell, map) {
|
|
|
2300
2538
|
return raw;
|
|
2301
2539
|
};
|
|
2302
2540
|
var buildMergeState = function (ranges) {
|
|
2303
|
-
var
|
|
2541
|
+
var e_25, _a;
|
|
2304
2542
|
var _b;
|
|
2305
2543
|
var normalized = normalizeMergeRanges(ranges);
|
|
2306
2544
|
var anchorSpans = new Map();
|
|
@@ -2327,17 +2565,17 @@ var buildMergeState = function (ranges) {
|
|
|
2327
2565
|
}
|
|
2328
2566
|
}
|
|
2329
2567
|
}
|
|
2330
|
-
catch (
|
|
2568
|
+
catch (e_25_1) { e_25 = { error: e_25_1 }; }
|
|
2331
2569
|
finally {
|
|
2332
2570
|
try {
|
|
2333
2571
|
if (normalized_1_1 && !normalized_1_1.done && (_a = normalized_1.return)) _a.call(normalized_1);
|
|
2334
2572
|
}
|
|
2335
|
-
finally { if (
|
|
2573
|
+
finally { if (e_25) throw e_25.error; }
|
|
2336
2574
|
}
|
|
2337
2575
|
return { anchorSpans: anchorSpans, coveredCells: coveredCells, maxColumnByRow: maxColumnByRow, ranges: normalized };
|
|
2338
2576
|
};
|
|
2339
2577
|
var updateBoundsForMerges = function (bounds, state) {
|
|
2340
|
-
var
|
|
2578
|
+
var e_26, _a;
|
|
2341
2579
|
try {
|
|
2342
2580
|
for (var _b = __values(state.ranges), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2343
2581
|
var range = _c.value;
|
|
@@ -2347,12 +2585,12 @@ var updateBoundsForMerges = function (bounds, state) {
|
|
|
2347
2585
|
bounds.maxColumn = Math.max(bounds.maxColumn, range.endColumnIndex);
|
|
2348
2586
|
}
|
|
2349
2587
|
}
|
|
2350
|
-
catch (
|
|
2588
|
+
catch (e_26_1) { e_26 = { error: e_26_1 }; }
|
|
2351
2589
|
finally {
|
|
2352
2590
|
try {
|
|
2353
2591
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2354
2592
|
}
|
|
2355
|
-
finally { if (
|
|
2593
|
+
finally { if (e_26) throw e_26.error; }
|
|
2356
2594
|
}
|
|
2357
2595
|
};
|
|
2358
2596
|
var sanitizeMergeRange = function (range) {
|
|
@@ -2385,7 +2623,7 @@ var sanitizeIndex = function (value) {
|
|
|
2385
2623
|
return Math.max(1, Math.floor(value));
|
|
2386
2624
|
};
|
|
2387
2625
|
var normalizeMergeRanges = function (ranges) {
|
|
2388
|
-
var
|
|
2626
|
+
var e_27, _a;
|
|
2389
2627
|
if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length))
|
|
2390
2628
|
return [];
|
|
2391
2629
|
var sanitized = ranges
|
|
@@ -2427,12 +2665,12 @@ var normalizeMergeRanges = function (ranges) {
|
|
|
2427
2665
|
_loop_3(merge);
|
|
2428
2666
|
}
|
|
2429
2667
|
}
|
|
2430
|
-
catch (
|
|
2668
|
+
catch (e_27_1) { e_27 = { error: e_27_1 }; }
|
|
2431
2669
|
finally {
|
|
2432
2670
|
try {
|
|
2433
2671
|
if (sorted_1_1 && !sorted_1_1.done && (_a = sorted_1.return)) _a.call(sorted_1);
|
|
2434
2672
|
}
|
|
2435
|
-
finally { if (
|
|
2673
|
+
finally { if (e_27) throw e_27.error; }
|
|
2436
2674
|
}
|
|
2437
2675
|
return valid;
|
|
2438
2676
|
};
|
|
@@ -2682,7 +2920,7 @@ var mapVerticalAlignment = function (value) {
|
|
|
2682
2920
|
return value !== null && value !== void 0 ? value : "bottom";
|
|
2683
2921
|
};
|
|
2684
2922
|
var buildZipStore = function (entries) {
|
|
2685
|
-
var
|
|
2923
|
+
var e_28, _a, e_29, _b;
|
|
2686
2924
|
var normalized = entries.map(function (entry) {
|
|
2687
2925
|
var nameBytes = textEncoder.encode(entry.name);
|
|
2688
2926
|
var data = entry.data;
|
|
@@ -2725,12 +2963,12 @@ var buildZipStore = function (entries) {
|
|
|
2725
2963
|
cursor += entry.data.length;
|
|
2726
2964
|
}
|
|
2727
2965
|
}
|
|
2728
|
-
catch (
|
|
2966
|
+
catch (e_28_1) { e_28 = { error: e_28_1 }; }
|
|
2729
2967
|
finally {
|
|
2730
2968
|
try {
|
|
2731
2969
|
if (normalized_2_1 && !normalized_2_1.done && (_a = normalized_2.return)) _a.call(normalized_2);
|
|
2732
2970
|
}
|
|
2733
|
-
finally { if (
|
|
2971
|
+
finally { if (e_28) throw e_28.error; }
|
|
2734
2972
|
}
|
|
2735
2973
|
var centralOffset = cursor;
|
|
2736
2974
|
try {
|
|
@@ -2757,12 +2995,12 @@ var buildZipStore = function (entries) {
|
|
|
2757
2995
|
cursor += entry.nameBytes.length;
|
|
2758
2996
|
}
|
|
2759
2997
|
}
|
|
2760
|
-
catch (
|
|
2998
|
+
catch (e_29_1) { e_29 = { error: e_29_1 }; }
|
|
2761
2999
|
finally {
|
|
2762
3000
|
try {
|
|
2763
3001
|
if (normalized_3_1 && !normalized_3_1.done && (_b = normalized_3.return)) _b.call(normalized_3);
|
|
2764
3002
|
}
|
|
2765
|
-
finally { if (
|
|
3003
|
+
finally { if (e_29) throw e_29.error; }
|
|
2766
3004
|
}
|
|
2767
3005
|
var centralSize = cursor - centralOffset;
|
|
2768
3006
|
cursor = writeUint32(view, cursor, 0x06054b50);
|
|
@@ -2963,7 +3201,7 @@ var formatOdsSheetName = function (sheet) {
|
|
|
2963
3201
|
return normalized;
|
|
2964
3202
|
};
|
|
2965
3203
|
var groupEmbedsBySheet = function (embeds) {
|
|
2966
|
-
var
|
|
3204
|
+
var e_30, _a;
|
|
2967
3205
|
var _b, _c, _d, _e, _f, _g, _h;
|
|
2968
3206
|
var result = new Map();
|
|
2969
3207
|
try {
|
|
@@ -2989,17 +3227,17 @@ var groupEmbedsBySheet = function (embeds) {
|
|
|
2989
3227
|
result.set(embed.position.sheetId, list);
|
|
2990
3228
|
}
|
|
2991
3229
|
}
|
|
2992
|
-
catch (
|
|
3230
|
+
catch (e_30_1) { e_30 = { error: e_30_1 }; }
|
|
2993
3231
|
finally {
|
|
2994
3232
|
try {
|
|
2995
3233
|
if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
|
|
2996
3234
|
}
|
|
2997
|
-
finally { if (
|
|
3235
|
+
finally { if (e_30) throw e_30.error; }
|
|
2998
3236
|
}
|
|
2999
3237
|
return result;
|
|
3000
3238
|
};
|
|
3001
3239
|
var groupChartsBySheet = function (charts) {
|
|
3002
|
-
var
|
|
3240
|
+
var e_31, _a;
|
|
3003
3241
|
var _b, _c, _d, _e, _f, _g;
|
|
3004
3242
|
var result = new Map();
|
|
3005
3243
|
try {
|
|
@@ -3022,18 +3260,18 @@ var groupChartsBySheet = function (charts) {
|
|
|
3022
3260
|
result.set(chart.position.sheetId, list);
|
|
3023
3261
|
}
|
|
3024
3262
|
}
|
|
3025
|
-
catch (
|
|
3263
|
+
catch (e_31_1) { e_31 = { error: e_31_1 }; }
|
|
3026
3264
|
finally {
|
|
3027
3265
|
try {
|
|
3028
3266
|
if (_j && !_j.done && (_a = _h.return)) _a.call(_h);
|
|
3029
3267
|
}
|
|
3030
|
-
finally { if (
|
|
3268
|
+
finally { if (e_31) throw e_31.error; }
|
|
3031
3269
|
}
|
|
3032
3270
|
return result;
|
|
3033
3271
|
};
|
|
3034
3272
|
var buildEmbedFramesXml = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
3035
|
-
var frames, embeds_1, embeds_1_1, placement, dataUrl, buffer, mediaPath, widthPx, heightPx, offsetXPx, offsetYPx, width, height, origin_1, offsetX, offsetY, anchorRef, anchorCell, anchorAttr, endColumn, endRow, endRef, endCell, endCellAttr, endX, endY,
|
|
3036
|
-
var
|
|
3273
|
+
var frames, embeds_1, embeds_1_1, placement, dataUrl, buffer, mediaPath, widthPx, heightPx, offsetXPx, offsetYPx, width, height, origin_1, offsetX, offsetY, anchorRef, anchorCell, anchorAttr, endColumn, endRow, endRef, endCell, endCellAttr, endX, endY, e_32_1;
|
|
3274
|
+
var e_32, _c;
|
|
3037
3275
|
var _d, _e, _f, _g;
|
|
3038
3276
|
var embeds = _b.embeds, mediaEntries = _b.mediaEntries, sheetName = _b.sheetName, sheet = _b.sheet;
|
|
3039
3277
|
return __generator(this, function (_h) {
|
|
@@ -3110,14 +3348,14 @@ var buildEmbedFramesXml = function (_a) { return __awaiter(void 0, [_a], void 0,
|
|
|
3110
3348
|
return [3 /*break*/, 2];
|
|
3111
3349
|
case 5: return [3 /*break*/, 8];
|
|
3112
3350
|
case 6:
|
|
3113
|
-
|
|
3114
|
-
|
|
3351
|
+
e_32_1 = _h.sent();
|
|
3352
|
+
e_32 = { error: e_32_1 };
|
|
3115
3353
|
return [3 /*break*/, 8];
|
|
3116
3354
|
case 7:
|
|
3117
3355
|
try {
|
|
3118
3356
|
if (embeds_1_1 && !embeds_1_1.done && (_c = embeds_1.return)) _c.call(embeds_1);
|
|
3119
3357
|
}
|
|
3120
|
-
finally { if (
|
|
3358
|
+
finally { if (e_32) throw e_32.error; }
|
|
3121
3359
|
return [7 /*endfinally*/];
|
|
3122
3360
|
case 8: return [2 /*return*/, frames];
|
|
3123
3361
|
}
|
|
@@ -3200,7 +3438,7 @@ var resolveAnchorEndpoint = function (_a) {
|
|
|
3200
3438
|
return { index: index, offset: offset };
|
|
3201
3439
|
};
|
|
3202
3440
|
var buildChartObjectXml = function (chart, sheetNameById) {
|
|
3203
|
-
var _a, _b, _c, _d, _e;
|
|
3441
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3204
3442
|
var spec = chart.spec;
|
|
3205
3443
|
var series = (_a = spec === null || spec === void 0 ? void 0 : spec.series) !== null && _a !== void 0 ? _a : [];
|
|
3206
3444
|
if (!series.length)
|
|
@@ -3225,7 +3463,26 @@ var buildChartObjectXml = function (chart, sheetNameById) {
|
|
|
3225
3463
|
scatter: "chart:scatter",
|
|
3226
3464
|
area: "chart:area",
|
|
3227
3465
|
};
|
|
3228
|
-
|
|
3466
|
+
// 3-D / surface classes degrade to a 2-D `chartType` with the authored
|
|
3467
|
+
// class kept as `sourceChartType` (BAR_3D, LINE_3D, PIE_3D, AREA_3D,
|
|
3468
|
+
// SURFACE, SURFACE_3D). ODF expresses the same thing as
|
|
3469
|
+
// `chart:three-dimensional="true"` on the plot-area style (plus the
|
|
3470
|
+
// `chart:surface` class for surfaces), so the flag round-trips.
|
|
3471
|
+
var sourceChartType = String((_e = spec.sourceChartType) !== null && _e !== void 0 ? _e : "").toUpperCase();
|
|
3472
|
+
var isSurface = sourceChartType === "SURFACE" || sourceChartType === "SURFACE_3D";
|
|
3473
|
+
// A plain SURFACE is Excel's contour (top-down) view, so only SURFACE_3D
|
|
3474
|
+
// carries the three-dimensional flag.
|
|
3475
|
+
var threeDimensional = sourceChartType === "SURFACE_3D" ||
|
|
3476
|
+
sourceChartType === "BAR_3D" ||
|
|
3477
|
+
sourceChartType === "LINE_3D" ||
|
|
3478
|
+
sourceChartType === "PIE_3D" ||
|
|
3479
|
+
sourceChartType === "AREA_3D";
|
|
3480
|
+
var chartClass = isSurface
|
|
3481
|
+
? "chart:surface"
|
|
3482
|
+
: ((_f = typeMap[spec.chartType]) !== null && _f !== void 0 ? _f : "chart:bar");
|
|
3483
|
+
var plotStyleProps = threeDimensional
|
|
3484
|
+
? "<style:chart-properties chart:three-dimensional=\"true\"/>"
|
|
3485
|
+
: "";
|
|
3229
3486
|
var title = spec.title
|
|
3230
3487
|
? "<chart:title><text:p>".concat(escapeXml(String(spec.title)), "</text:p></chart:title>")
|
|
3231
3488
|
: "";
|
|
@@ -3310,7 +3567,7 @@ var buildChartObjectXml = function (chart, sheetNameById) {
|
|
|
3310
3567
|
var legendXml = chartClass === "chart:circle"
|
|
3311
3568
|
? ""
|
|
3312
3569
|
: "<chart:legend chart:legend-position=\"end\" chart:legend-align=\"center\" chart:style-name=\"legend1\"/>";
|
|
3313
|
-
return "".concat(XML_DECLARATION, "<office:document-content xmlns:office=\"").concat(ODS_NS.office, "\" xmlns:chart=\"").concat(ODS_NS.chart, "\" xmlns:table=\"").concat(ODS_NS.table, "\" xmlns:text=\"").concat(ODS_NS.text, "\" xmlns:style=\"").concat(ODS_NS.style, "\" xmlns:draw=\"").concat(ODS_NS.draw, "\" xmlns:svg=\"").concat(ODS_NS.svg, "\" xmlns:fo=\"").concat(ODS_NS.fo, "\" office:version=\"1.2\"><office:automatic-styles>").concat(gradientDefsXml, "<style:style style:name=\"ch1\" style:family=\"chart\"><style:graphic-properties draw:fill=\"solid\" draw:fill-color=\"#ffffff\"/></style:style><style:style style:name=\"plot1\" style:family=\"chart\"
|
|
3570
|
+
return "".concat(XML_DECLARATION, "<office:document-content xmlns:office=\"").concat(ODS_NS.office, "\" xmlns:chart=\"").concat(ODS_NS.chart, "\" xmlns:table=\"").concat(ODS_NS.table, "\" xmlns:text=\"").concat(ODS_NS.text, "\" xmlns:style=\"").concat(ODS_NS.style, "\" xmlns:draw=\"").concat(ODS_NS.draw, "\" xmlns:svg=\"").concat(ODS_NS.svg, "\" xmlns:fo=\"").concat(ODS_NS.fo, "\" office:version=\"1.2\"><office:automatic-styles>").concat(gradientDefsXml, "<style:style style:name=\"ch1\" style:family=\"chart\"><style:graphic-properties draw:fill=\"solid\" draw:fill-color=\"#ffffff\"/></style:style><style:style style:name=\"plot1\" style:family=\"chart\">").concat(plotStyleProps, "<style:graphic-properties draw:fill=\"solid\" draw:fill-color=\"#ffffff\" svg:stroke-color=\"#b3b3b3\"/></style:style><style:style style:name=\"wall1\" style:family=\"chart\"><style:graphic-properties draw:fill=\"solid\" draw:fill-color=\"#ffffff\" svg:stroke-color=\"#b3b3b3\" svg:stroke-width=\"0.01cm\"/></style:style><style:style style:name=\"floor1\" style:family=\"chart\"><style:graphic-properties draw:fill=\"none\" svg:stroke-color=\"#b3b3b3\"/></style:style><style:style style:name=\"legend1\" style:family=\"chart\"><style:graphic-properties draw:fill=\"none\" svg:stroke-color=\"#b3b3b3\"/><style:text-properties fo:font-size=\"10pt\"/></style:style><style:style style:name=\"axisx\" style:family=\"chart\"><style:chart-properties chart:display-label=\"true\" chart:tick-marks-major-inner=\"false\" chart:tick-marks-major-outer=\"true\"/><style:graphic-properties svg:stroke-color=\"#b3b3b3\"/><style:text-properties fo:font-size=\"9pt\"/></style:style><style:style style:name=\"axisy\" style:family=\"chart\"><style:chart-properties chart:display-label=\"true\" chart:tick-marks-major-inner=\"false\" chart:tick-marks-major-outer=\"true\"/><style:graphic-properties svg:stroke-color=\"#b3b3b3\"/><style:text-properties fo:font-size=\"9pt\"/></style:style>").concat(seriesStyles, "</office:automatic-styles><office:body><office:chart><chart:chart chart:class=\"").concat(chartClass, "\" chart:style-name=\"ch1\">").concat(title).concat(legendXml, "<chart:plot-area chart:style-name=\"plot1\"").concat(plotAreaAttrs, ">").concat(axisXml).concat(seriesXml).concat(wallFloor, "</chart:plot-area></chart:chart></office:chart></office:body></office:document-content>");
|
|
3314
3571
|
};
|
|
3315
3572
|
var buildChartRangeAddress = function (range, sheetNameById) {
|
|
3316
3573
|
var sheetName = sheetNameById.get(range.sheetId);
|
|
@@ -3364,7 +3621,7 @@ var buildChartLabelAddressFromRange = function (range, sheetNameById) {
|
|
|
3364
3621
|
};
|
|
3365
3622
|
var buildChartFramesXml = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
3366
3623
|
var frames, chartObjects, index, charts_1, charts_1_1, placement, chartXml, folder, widthPx, heightPx, offsetXPx, offsetYPx, width, height, origin_2, offsetX, offsetY, anchorRef, anchorCell, anchorAttr, endColumn, endRow, endRef, endCell, endCellAttr, endX, endY;
|
|
3367
|
-
var
|
|
3624
|
+
var e_33, _c;
|
|
3368
3625
|
var _d, _e, _f, _g;
|
|
3369
3626
|
var charts = _b.charts, sheet = _b.sheet, sheetName = _b.sheetName, sheetNameById = _b.sheetNameById, startIndex = _b.startIndex;
|
|
3370
3627
|
return __generator(this, function (_h) {
|
|
@@ -3425,12 +3682,12 @@ var buildChartFramesXml = function (_a) { return __awaiter(void 0, [_a], void 0,
|
|
|
3425
3682
|
index += 1;
|
|
3426
3683
|
}
|
|
3427
3684
|
}
|
|
3428
|
-
catch (
|
|
3685
|
+
catch (e_33_1) { e_33 = { error: e_33_1 }; }
|
|
3429
3686
|
finally {
|
|
3430
3687
|
try {
|
|
3431
3688
|
if (charts_1_1 && !charts_1_1.done && (_c = charts_1.return)) _c.call(charts_1);
|
|
3432
3689
|
}
|
|
3433
|
-
finally { if (
|
|
3690
|
+
finally { if (e_33) throw e_33.error; }
|
|
3434
3691
|
}
|
|
3435
3692
|
return [2 /*return*/, { frames: frames, chartObjects: chartObjects, nextIndex: index }];
|
|
3436
3693
|
});
|