@rowsncolumns/toolkit 24.4.4 → 24.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/autofilter-condition.d.ts +45 -1
- package/dist/cjs/autofilter-condition.d.ts.map +1 -1
- package/dist/cjs/autofilter-condition.js +135 -12
- package/dist/cjs/excel-parser/helpers.d.ts +15 -1
- package/dist/cjs/excel-parser/helpers.d.ts.map +1 -1
- package/dist/cjs/excel-parser/helpers.js +119 -5
- package/dist/cjs/excel-parser/interface.d.ts +3 -1
- package/dist/cjs/excel-parser/interface.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/index.js +186 -97
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts +15 -0
- package/dist/cjs/excel-parser/plugins/ods/styles.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/ods/styles.js +80 -6
- package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsb/index.js +107 -103
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts +77 -1
- package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/charts.js +920 -122
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts +7 -1
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/drawing.js +24 -9
- package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts +24 -3
- package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/form-controls.js +25 -3
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +24 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.js +561 -394
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts +8 -2
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/pivots.js +312 -21
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts +6 -0
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/relationships.js +9 -0
- package/dist/cjs/excel-parser/plugins/xlsx/theme.d.ts +1 -1
- package/dist/cjs/excel-parser/types.d.ts +9 -1
- package/dist/cjs/excel-parser/types.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.d.ts +1 -0
- package/dist/cjs/excel-parser/workbook.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.js +5 -0
- package/dist/cjs/excel-parser/worker.js +2 -0
- package/dist/cjs/exporter/ods/ods-export.d.ts.map +1 -1
- package/dist/cjs/exporter/ods/ods-export.js +255 -80
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts +7 -1
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/chart-builder.js +902 -119
- package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts +16 -3
- package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/form-controls-builder.js +30 -8
- package/dist/cjs/exporter/xlsx/pivot-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/pivot-builder.js +206 -162
- package/dist/cjs/exporter/xlsx/style-builder.d.ts +8 -2
- package/dist/cjs/exporter/xlsx/style-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/style-builder.js +25 -0
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts +2 -2
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/xlsx-export.js +728 -452
- package/dist/esm/autofilter-condition.d.ts +45 -1
- package/dist/esm/autofilter-condition.d.ts.map +1 -1
- package/dist/esm/autofilter-condition.js +131 -11
- package/dist/esm/excel-parser/helpers.d.ts +15 -1
- package/dist/esm/excel-parser/helpers.d.ts.map +1 -1
- package/dist/esm/excel-parser/helpers.js +94 -4
- package/dist/esm/excel-parser/interface.d.ts +3 -1
- package/dist/esm/excel-parser/interface.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/index.js +105 -22
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts +15 -0
- package/dist/esm/excel-parser/plugins/ods/styles.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/ods/styles.js +79 -5
- package/dist/esm/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsb/index.js +15 -7
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts +77 -1
- package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/charts.js +708 -16
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts +7 -1
- package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/drawing.js +23 -0
- package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts +24 -3
- package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/form-controls.js +21 -3
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +24 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.js +192 -54
- package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts +8 -2
- package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/pivots.js +220 -4
- package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts +6 -0
- package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/relationships.js +9 -0
- package/dist/esm/excel-parser/plugins/xlsx/theme.d.ts +1 -1
- package/dist/esm/excel-parser/types.d.ts +9 -1
- package/dist/esm/excel-parser/types.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.d.ts +1 -0
- package/dist/esm/excel-parser/workbook.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.js +4 -0
- package/dist/esm/excel-parser/worker.js +2 -0
- package/dist/esm/exporter/ods/ods-export.d.ts.map +1 -1
- package/dist/esm/exporter/ods/ods-export.js +238 -72
- package/dist/esm/exporter/xlsx/chart-builder.d.ts +7 -1
- package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/chart-builder.js +674 -58
- package/dist/esm/exporter/xlsx/form-controls-builder.d.ts +16 -3
- package/dist/esm/exporter/xlsx/form-controls-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/form-controls-builder.js +29 -8
- package/dist/esm/exporter/xlsx/pivot-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/pivot-builder.js +187 -139
- package/dist/esm/exporter/xlsx/style-builder.d.ts +8 -2
- package/dist/esm/exporter/xlsx/style-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/style-builder.js +28 -0
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts +2 -2
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/xlsx-export.js +451 -197
- package/package.json +11 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ods-export.d.ts","sourceRoot":"","sources":["../../../../exporter/ods/ods-export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,wBAAwB,EAMxB,SAAS,EAET,2BAA2B,EAC3B,QAAQ,EACT,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAGV,qBAAqB,EAErB,aAAa,EACb,cAAc,EAGd,UAAU,
|
|
1
|
+
{"version":3,"file":"ods-export.d.ts","sourceRoot":"","sources":["../../../../exporter/ods/ods-export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,wBAAwB,EAMxB,SAAS,EAET,2BAA2B,EAC3B,QAAQ,EACT,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAGV,qBAAqB,EAErB,aAAa,EACb,cAAc,EAGd,UAAU,EAEV,KAAK,EAGL,gBAAgB,EAChB,SAAS,EAGV,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,4BAA4B,CAAC;AA+HzE,MAAM,MAAM,cAAc,CACxB,CAAC,SAAS,KAAK,EACf,CAAC,SAAS,QAAQ,EAClB,CAAC,SAAS,QAAQ,IAChB;IACF,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,kBAAkB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAC7C,eAAe,CAAC,EAAE,wBAAwB,EAAE,CAAC;IAC7C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,2BAA2B,CAAC,EAAE,2BAA2B,CAAC;IAC1D,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1C,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAiYF,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,KAAK,EACf,CAAC,SAAS,QAAQ,EAClB,CAAC,SAAS,QAAQ,EAClB,qRAgBC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,yBA6JzB,CAAC"}
|
|
@@ -1753,6 +1753,18 @@ var buildNumberStyleXml = function (name, format) {
|
|
|
1753
1753
|
if (!format)
|
|
1754
1754
|
return "";
|
|
1755
1755
|
var type = format.type;
|
|
1756
|
+
// The authored pattern decides the symbol, its side, the decimals and the
|
|
1757
|
+
// thousands separator (the same numeric grammar the chart axes convert);
|
|
1758
|
+
// the per-type defaults below only cover a format without a pattern.
|
|
1759
|
+
if (format.pattern &&
|
|
1760
|
+
(type === "PERCENT" ||
|
|
1761
|
+
type === "CURRENCY" ||
|
|
1762
|
+
type === "ACCOUNTING" ||
|
|
1763
|
+
type === "NUMBER")) {
|
|
1764
|
+
var fromPattern = numericPatternToOdsStyle(name, format.pattern);
|
|
1765
|
+
if (fromPattern)
|
|
1766
|
+
return fromPattern;
|
|
1767
|
+
}
|
|
1756
1768
|
if (type === "PERCENT") {
|
|
1757
1769
|
return "<number:percentage-style style:name=\"".concat(name, "\"><number:number number:min-integer-digits=\"1\" number:decimal-places=\"2\"/></number:percentage-style>");
|
|
1758
1770
|
}
|
|
@@ -2392,39 +2404,68 @@ var buildNamedRangesXml = function (namedRanges, sheetNameById, namedRangeNames)
|
|
|
2392
2404
|
};
|
|
2393
2405
|
var buildFilterXml = function (filterSpecs, range, rows, headerRow, totalRow) {
|
|
2394
2406
|
var e_22, _a, e_23, _b, e_24, _c;
|
|
2395
|
-
var _d, _e, _f;
|
|
2407
|
+
var _d, _e, _f, _g;
|
|
2396
2408
|
if (headerRow === void 0) { headerRow = true; }
|
|
2397
2409
|
if (totalRow === void 0) { totalRow = false; }
|
|
2398
2410
|
if (!(filterSpecs === null || filterSpecs === void 0 ? void 0 : filterSpecs.length))
|
|
2399
2411
|
return "";
|
|
2400
2412
|
var conditions = [];
|
|
2413
|
+
var filterConditionXml = function (columnIndex, mapped) {
|
|
2414
|
+
var attrs = [
|
|
2415
|
+
"table:field-number=\"".concat(columnIndex, "\""),
|
|
2416
|
+
"table:operator=\"".concat(mapped.operator, "\""),
|
|
2417
|
+
];
|
|
2418
|
+
if (mapped.value !== undefined) {
|
|
2419
|
+
attrs.push("table:value=\"".concat(escapeXml(mapped.value), "\""));
|
|
2420
|
+
}
|
|
2421
|
+
if (mapped.value2 !== undefined) {
|
|
2422
|
+
attrs.push("table:value2=\"".concat(escapeXml(mapped.value2), "\""));
|
|
2423
|
+
}
|
|
2424
|
+
return "<table:filter-condition ".concat(attrs.join(" "), "/>");
|
|
2425
|
+
};
|
|
2401
2426
|
try {
|
|
2402
2427
|
for (var filterSpecs_1 = __values(filterSpecs), filterSpecs_1_1 = filterSpecs_1.next(); !filterSpecs_1_1.done; filterSpecs_1_1 = filterSpecs_1.next()) {
|
|
2403
2428
|
var spec = filterSpecs_1_1.value;
|
|
2404
2429
|
var criteria = spec.filterCriteria;
|
|
2405
|
-
// A condition filter (greater-than / contains / between / blank /
|
|
2406
|
-
// precedence over a value list, and is emitted as
|
|
2407
|
-
// <table:filter-condition>.
|
|
2430
|
+
// A condition filter (greater-than / contains / between / blank / Top 10
|
|
2431
|
+
// / …) takes precedence over a value list, and is emitted as an
|
|
2432
|
+
// operator-based <table:filter-condition>. Excel's Custom AutoFilter
|
|
2433
|
+
// second clause joins it inside <table:filter-or> (Or) or beside it in
|
|
2434
|
+
// the enclosing <table:filter-and> (And). Otherwise fall back to
|
|
2435
|
+
// value-list entries.
|
|
2408
2436
|
var condition = criteria === null || criteria === void 0 ? void 0 : criteria.condition;
|
|
2409
2437
|
var mapped = (condition === null || condition === void 0 ? void 0 : condition.type)
|
|
2410
2438
|
? mapConditionToFilterCondition(condition.type, (_d = condition.values) !== null && _d !== void 0 ? _d : [])
|
|
2411
2439
|
: undefined;
|
|
2412
2440
|
if (mapped) {
|
|
2413
|
-
var
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2441
|
+
var first = filterConditionXml(spec.columnIndex, mapped);
|
|
2442
|
+
var condition2 = criteria === null || criteria === void 0 ? void 0 : criteria.condition2;
|
|
2443
|
+
var mapped2 = (condition2 === null || condition2 === void 0 ? void 0 : condition2.type)
|
|
2444
|
+
? mapConditionToFilterCondition(condition2.type, (_e = condition2.values) !== null && _e !== void 0 ? _e : [])
|
|
2445
|
+
: undefined;
|
|
2446
|
+
if (mapped2) {
|
|
2447
|
+
var second = filterConditionXml(spec.columnIndex, mapped2);
|
|
2448
|
+
conditions.push((criteria === null || criteria === void 0 ? void 0 : criteria.conditionJoin) === "OR"
|
|
2449
|
+
? "<table:filter-or>".concat(first).concat(second, "</table:filter-or>")
|
|
2450
|
+
: "".concat(first).concat(second));
|
|
2419
2451
|
}
|
|
2420
|
-
|
|
2421
|
-
|
|
2452
|
+
else {
|
|
2453
|
+
if (condition2 === null || condition2 === void 0 ? void 0 : condition2.type) {
|
|
2454
|
+
conditions.push(unsupportedConditionComment(spec.columnIndex, condition2.type));
|
|
2455
|
+
}
|
|
2456
|
+
conditions.push(first);
|
|
2422
2457
|
}
|
|
2423
|
-
conditions.push("<table:filter-condition ".concat(attrs.join(" "), "/>"));
|
|
2424
2458
|
continue;
|
|
2425
2459
|
}
|
|
2426
|
-
|
|
2427
|
-
|
|
2460
|
+
if (condition === null || condition === void 0 ? void 0 : condition.type) {
|
|
2461
|
+
// A criterion ODF cannot express (relative-date periods, above /
|
|
2462
|
+
// below average, custom formulas): degrade explicitly instead of
|
|
2463
|
+
// flattening the column into an all-values list.
|
|
2464
|
+
conditions.push(unsupportedConditionComment(spec.columnIndex, condition.type));
|
|
2465
|
+
continue;
|
|
2466
|
+
}
|
|
2467
|
+
var visibleValues = (_f = criteria === null || criteria === void 0 ? void 0 : criteria.visibleValues) !== null && _f !== void 0 ? _f : getFilterVisibleValues(spec, range, rows, headerRow, totalRow);
|
|
2468
|
+
var hiddenValues = (_g = criteria === null || criteria === void 0 ? void 0 : criteria.hiddenValues) !== null && _g !== void 0 ? _g : [];
|
|
2428
2469
|
try {
|
|
2429
2470
|
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()) {
|
|
2430
2471
|
var value = visibleValues_1_1.value;
|
|
@@ -2464,6 +2505,14 @@ var buildFilterXml = function (filterSpecs, range, rows, headerRow, totalRow) {
|
|
|
2464
2505
|
return "";
|
|
2465
2506
|
return "<table:filter><table:filter-and>".concat(conditions.join(""), "</table:filter-and></table:filter>");
|
|
2466
2507
|
};
|
|
2508
|
+
/**
|
|
2509
|
+
* An XML comment recording a criterion ODF has no shape for (a dynamic
|
|
2510
|
+
* period such as DATE_THIS_MONTH, above/below average, a custom formula).
|
|
2511
|
+
* Readers ignore it; the column exports with no criterion on that clause.
|
|
2512
|
+
*/
|
|
2513
|
+
var unsupportedConditionComment = function (columnIndex, type) {
|
|
2514
|
+
return "<!-- rnc: ".concat(type.replace(/-/g, ""), " filter on field ").concat(columnIndex, " has no ODF equivalent; exported without that criterion -->");
|
|
2515
|
+
};
|
|
2467
2516
|
var buildSortXml = function (sortSpecs) {
|
|
2468
2517
|
if (!(sortSpecs === null || sortSpecs === void 0 ? void 0 : sortSpecs.length))
|
|
2469
2518
|
return "";
|
|
@@ -2522,6 +2571,16 @@ var mapConditionToFilterCondition = function (type, values) {
|
|
|
2522
2571
|
return { operator: "non-empty" };
|
|
2523
2572
|
case "BOOLEAN":
|
|
2524
2573
|
return { operator: "=", value: "TRUE" };
|
|
2574
|
+
// Excel's "Top 10…" AutoFilter — ODF 1.2 `table:operator` has native
|
|
2575
|
+
// top / bottom values / percent forms.
|
|
2576
|
+
case "NUMBER_TOP_N":
|
|
2577
|
+
return { operator: "top values", value: first !== null && first !== void 0 ? first : "" };
|
|
2578
|
+
case "NUMBER_BOTTOM_N":
|
|
2579
|
+
return { operator: "bottom values", value: first !== null && first !== void 0 ? first : "" };
|
|
2580
|
+
case "NUMBER_TOP_PERCENT":
|
|
2581
|
+
return { operator: "top percent", value: first !== null && first !== void 0 ? first : "" };
|
|
2582
|
+
case "NUMBER_BOTTOM_PERCENT":
|
|
2583
|
+
return { operator: "bottom percent", value: first !== null && first !== void 0 ? first : "" };
|
|
2525
2584
|
default:
|
|
2526
2585
|
return undefined;
|
|
2527
2586
|
}
|
|
@@ -3221,6 +3280,7 @@ var groupEmbedsBySheet = function (embeds) {
|
|
|
3221
3280
|
offsetY: (_e = overlay.offsetYPixels) !== null && _e !== void 0 ? _e : 0,
|
|
3222
3281
|
width: (_f = overlay.widthPixels) !== null && _f !== void 0 ? _f : 120,
|
|
3223
3282
|
height: (_g = overlay.heightPixels) !== null && _g !== void 0 ? _g : 120,
|
|
3283
|
+
overlay: overlay,
|
|
3224
3284
|
};
|
|
3225
3285
|
var list = (_h = result.get(embed.position.sheetId)) !== null && _h !== void 0 ? _h : [];
|
|
3226
3286
|
list.push(placement);
|
|
@@ -3270,7 +3330,7 @@ var groupChartsBySheet = function (charts) {
|
|
|
3270
3330
|
return result;
|
|
3271
3331
|
};
|
|
3272
3332
|
var buildEmbedFramesXml = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
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,
|
|
3333
|
+
var frames, embeds_1, embeds_1_1, placement, dataUrl, buffer, mediaPath, widthPx, heightPx, offsetXPx, offsetYPx, width, height, origin_1, offsetX, offsetY, anchorRef, anchorCell, anchorAttr, endAttrs, e_32_1;
|
|
3274
3334
|
var e_32, _c;
|
|
3275
3335
|
var _d, _e, _f, _g;
|
|
3276
3336
|
var embeds = _b.embeds, mediaEntries = _b.mediaEntries, sheetName = _b.sheetName, sheet = _b.sheet;
|
|
@@ -3319,29 +3379,17 @@ var buildEmbedFramesXml = function (_a) { return __awaiter(void 0, [_a], void 0,
|
|
|
3319
3379
|
anchorAttr = anchorCell
|
|
3320
3380
|
? " table:anchor-cell-address=\"".concat(escapeXmlAddress(anchorCell), "\"")
|
|
3321
3381
|
: "";
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
span: heightPx,
|
|
3332
|
-
getSize: function (index) { return getRowHeightPx(sheet, index); },
|
|
3333
|
-
});
|
|
3334
|
-
endRef = cellToAddress({
|
|
3335
|
-
rowIndex: endRow.index,
|
|
3336
|
-
columnIndex: endColumn.index,
|
|
3382
|
+
endAttrs = buildFrameEndCellAttrs({
|
|
3383
|
+
sheet: sheet,
|
|
3384
|
+
overlay: placement.overlay,
|
|
3385
|
+
rowIndex: placement.rowIndex,
|
|
3386
|
+
columnIndex: placement.columnIndex,
|
|
3387
|
+
offsetXPx: offsetXPx,
|
|
3388
|
+
offsetYPx: offsetYPx,
|
|
3389
|
+
widthPx: widthPx,
|
|
3390
|
+
heightPx: heightPx,
|
|
3337
3391
|
});
|
|
3338
|
-
|
|
3339
|
-
endCellAttr = endCell
|
|
3340
|
-
? " table:end-cell-address=\"".concat(escapeXmlAddress(endCell), "\"")
|
|
3341
|
-
: "";
|
|
3342
|
-
endX = pxToCm(endColumn.offset).toFixed(2);
|
|
3343
|
-
endY = pxToCm(endRow.offset).toFixed(2);
|
|
3344
|
-
frames.push("<draw:frame draw:name=\"Image".concat(mediaEntries.length, "\" svg:width=\"").concat(width, "cm\" svg:height=\"").concat(height, "cm\" svg:x=\"").concat(offsetX, "cm\" svg:y=\"").concat(offsetY, "cm\" table:anchor-type=\"cell\"").concat(anchorAttr).concat(endCellAttr, " table:end-x=\"").concat(endX, "cm\" table:end-y=\"").concat(endY, "cm\"><draw:image xlink:href=\"").concat(mediaPath, "\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/></draw:frame>"));
|
|
3392
|
+
frames.push("<draw:frame draw:name=\"Image".concat(mediaEntries.length, "\" svg:width=\"").concat(width, "cm\" svg:height=\"").concat(height, "cm\" svg:x=\"").concat(offsetX, "cm\" svg:y=\"").concat(offsetY, "cm\" table:anchor-type=\"cell\"").concat(anchorAttr).concat(endAttrs, "><draw:image xlink:href=\"").concat(mediaPath, "\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/></draw:frame>"));
|
|
3345
3393
|
_h.label = 4;
|
|
3346
3394
|
case 4:
|
|
3347
3395
|
embeds_1_1 = embeds_1.next();
|
|
@@ -3417,6 +3465,46 @@ var getCellOriginPx = function (sheet, rowIndex, columnIndex) {
|
|
|
3417
3465
|
}
|
|
3418
3466
|
return { x: x, y: y };
|
|
3419
3467
|
};
|
|
3468
|
+
/**
|
|
3469
|
+
* `table:end-cell-address` + `table:end-x/y` for a frame — ODS's shape of
|
|
3470
|
+
* Excel's "Move and size with cells": the persisted second anchor when the
|
|
3471
|
+
* object carries one, else the cell its pixel extent reaches. ODS has no
|
|
3472
|
+
* placement mode, so "Move but don't size" / "Don't move or size" frames
|
|
3473
|
+
* degrade to a fixed-size cell-anchored frame (no end cell) — the closest
|
|
3474
|
+
* ODS reading; the mode itself is not round-tripped through ODS (#668 C-06).
|
|
3475
|
+
*/
|
|
3476
|
+
var buildFrameEndCellAttrs = function (_a) {
|
|
3477
|
+
var _b, _c, _d;
|
|
3478
|
+
var sheet = _a.sheet, overlay = _a.overlay, rowIndex = _a.rowIndex, columnIndex = _a.columnIndex, offsetXPx = _a.offsetXPx, offsetYPx = _a.offsetYPx, widthPx = _a.widthPx, heightPx = _a.heightPx;
|
|
3479
|
+
if (((_b = overlay === null || overlay === void 0 ? void 0 : overlay.placement) !== null && _b !== void 0 ? _b : "moveAndSize") !== "moveAndSize")
|
|
3480
|
+
return "";
|
|
3481
|
+
var endColumn = (overlay === null || overlay === void 0 ? void 0 : overlay.toCell)
|
|
3482
|
+
? { index: overlay.toCell.columnIndex, offset: (_c = overlay.toOffsetXPixels) !== null && _c !== void 0 ? _c : 0 }
|
|
3483
|
+
: resolveAnchorEndpoint({
|
|
3484
|
+
startIndex: columnIndex,
|
|
3485
|
+
startOffset: offsetXPx,
|
|
3486
|
+
span: widthPx,
|
|
3487
|
+
getSize: function (index) { return getColumnWidthPx(sheet, index); },
|
|
3488
|
+
});
|
|
3489
|
+
var endRow = (overlay === null || overlay === void 0 ? void 0 : overlay.toCell)
|
|
3490
|
+
? { index: overlay.toCell.rowIndex, offset: (_d = overlay.toOffsetYPixels) !== null && _d !== void 0 ? _d : 0 }
|
|
3491
|
+
: resolveAnchorEndpoint({
|
|
3492
|
+
startIndex: rowIndex,
|
|
3493
|
+
startOffset: offsetYPx,
|
|
3494
|
+
span: heightPx,
|
|
3495
|
+
getSize: function (index) { return getRowHeightPx(sheet, index); },
|
|
3496
|
+
});
|
|
3497
|
+
var endRef = cellToAddress({
|
|
3498
|
+
rowIndex: endRow.index,
|
|
3499
|
+
columnIndex: endColumn.index,
|
|
3500
|
+
});
|
|
3501
|
+
var endCellAttr = endRef
|
|
3502
|
+
? " table:end-cell-address=\"".concat(escapeXmlAddress(endRef), "\"")
|
|
3503
|
+
: "";
|
|
3504
|
+
var endX = pxToCm(endColumn.offset).toFixed(2);
|
|
3505
|
+
var endY = pxToCm(endRow.offset).toFixed(2);
|
|
3506
|
+
return "".concat(endCellAttr, " table:end-x=\"").concat(endX, "cm\" table:end-y=\"").concat(endY, "cm\"");
|
|
3507
|
+
};
|
|
3420
3508
|
var resolveAnchorEndpoint = function (_a) {
|
|
3421
3509
|
var startIndex = _a.startIndex, startOffset = _a.startOffset, span = _a.span, getSize = _a.getSize;
|
|
3422
3510
|
var remaining = Math.max(0, span);
|
|
@@ -3437,8 +3525,14 @@ var resolveAnchorEndpoint = function (_a) {
|
|
|
3437
3525
|
}
|
|
3438
3526
|
return { index: index, offset: offset };
|
|
3439
3527
|
};
|
|
3528
|
+
/** `ChartSpec.emptyCells` → ODF `chart:treat-empty-cells`. */
|
|
3529
|
+
var ODS_TREAT_EMPTY_CELLS = {
|
|
3530
|
+
gaps: "leave-gap",
|
|
3531
|
+
zero: "use-zero",
|
|
3532
|
+
connect: "ignore",
|
|
3533
|
+
};
|
|
3440
3534
|
var buildChartObjectXml = function (chart, sheetNameById) {
|
|
3441
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3535
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3442
3536
|
var spec = chart.spec;
|
|
3443
3537
|
var series = (_a = spec === null || spec === void 0 ? void 0 : spec.series) !== null && _a !== void 0 ? _a : [];
|
|
3444
3538
|
if (!series.length)
|
|
@@ -3460,6 +3554,7 @@ var buildChartObjectXml = function (chart, sheetNameById) {
|
|
|
3460
3554
|
column: "chart:bar",
|
|
3461
3555
|
line: "chart:line",
|
|
3462
3556
|
pie: "chart:circle",
|
|
3557
|
+
doughnut: "chart:ring",
|
|
3463
3558
|
scatter: "chart:scatter",
|
|
3464
3559
|
area: "chart:area",
|
|
3465
3560
|
};
|
|
@@ -3480,20 +3575,52 @@ var buildChartObjectXml = function (chart, sheetNameById) {
|
|
|
3480
3575
|
var chartClass = isSurface
|
|
3481
3576
|
? "chart:surface"
|
|
3482
3577
|
: ((_f = typeMap[spec.chartType]) !== null && _f !== void 0 ? _f : "chart:bar");
|
|
3483
|
-
|
|
3484
|
-
|
|
3578
|
+
// Pie and doughnut (ODF `chart:ring`) share the slice model — no axes,
|
|
3579
|
+
// walls or legend block, and the per-series slice offset.
|
|
3580
|
+
var isCircular = chartClass === "chart:circle" || chartClass === "chart:ring";
|
|
3581
|
+
// Excel's "Show empty cells as" has a native ODF shape on the plot-area
|
|
3582
|
+
// style (`chart:treat-empty-cells`: leave-gap / use-zero / ignore, the
|
|
3583
|
+
// last being "continue the line"); "Show #N/A as an empty cell" has none
|
|
3584
|
+
// and degrades on ODS export.
|
|
3585
|
+
var treatEmptyCells = ODS_TREAT_EMPTY_CELLS[String((_g = spec.emptyCells) !== null && _g !== void 0 ? _g : "")];
|
|
3586
|
+
var plotChartProps = [
|
|
3587
|
+
threeDimensional ? "chart:three-dimensional=\"true\"" : "",
|
|
3588
|
+
treatEmptyCells ? "chart:treat-empty-cells=\"".concat(treatEmptyCells, "\"") : "",
|
|
3589
|
+
].filter(Boolean);
|
|
3590
|
+
var plotStyleProps = plotChartProps.length
|
|
3591
|
+
? "<style:chart-properties ".concat(plotChartProps.join(" "), "/>")
|
|
3485
3592
|
: "";
|
|
3486
3593
|
var title = spec.title
|
|
3487
3594
|
? "<chart:title><text:p>".concat(escapeXml(String(spec.title)), "</text:p></chart:title>")
|
|
3488
3595
|
: "";
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
"
|
|
3495
|
-
|
|
3496
|
-
|
|
3596
|
+
// Axis tick-label formats. Excel's explicit `<c:numFmt sourceLinked="0">`
|
|
3597
|
+
// is an ODF data style on the axis style with the link to the source
|
|
3598
|
+
// severed (`chart:link-data-style-to-source="false"`); without one the
|
|
3599
|
+
// axis keeps ODF's default and stays linked to its source cells.
|
|
3600
|
+
var axisStyle = function (name, options) {
|
|
3601
|
+
var dataStyleName = "".concat(name, "N");
|
|
3602
|
+
var pattern = options === null || options === void 0 ? void 0 : options.numberFormatPattern;
|
|
3603
|
+
var numberStyle = typeof pattern === "string" && pattern.trim()
|
|
3604
|
+
? buildAxisNumberStyleXml(dataStyleName, pattern)
|
|
3605
|
+
: undefined;
|
|
3606
|
+
var dataStyleAttr = numberStyle
|
|
3607
|
+
? " style:data-style-name=\"".concat(dataStyleName, "\"")
|
|
3608
|
+
: "";
|
|
3609
|
+
var linkAttr = numberStyle
|
|
3610
|
+
? " chart:link-data-style-to-source=\"false\""
|
|
3611
|
+
: "";
|
|
3612
|
+
return {
|
|
3613
|
+
numberStyle: numberStyle !== null && numberStyle !== void 0 ? numberStyle : "",
|
|
3614
|
+
style: "<style:style style:name=\"".concat(name, "\" style:family=\"chart\"").concat(dataStyleAttr, "><style:chart-properties chart:display-label=\"true\" chart:tick-marks-major-inner=\"false\" chart:tick-marks-major-outer=\"true\"").concat(linkAttr, "/><style:graphic-properties svg:stroke-color=\"#b3b3b3\"/><style:text-properties fo:font-size=\"9pt\"/></style:style>"),
|
|
3615
|
+
};
|
|
3616
|
+
};
|
|
3617
|
+
var axisX = axisStyle("axisx", spec.categoryAxisOptions);
|
|
3618
|
+
var axisY = axisStyle("axisy", spec.valueAxisOptions);
|
|
3619
|
+
// Change Colors palette when set (ODF has no chart-style id — it
|
|
3620
|
+
// degrades to the resolved series colours); else the default cycle.
|
|
3621
|
+
var seriesPalette = Array.isArray(spec.palette) && spec.palette.length > 0
|
|
3622
|
+
? spec.palette
|
|
3623
|
+
: ["#4285f4", "#ea4335", "#fbbc04", "#34a853", "#ff6d01", "#46bdc6"];
|
|
3497
3624
|
// Series chart styles + (optional) gradient defs. When a series
|
|
3498
3625
|
// carries an explicit gradient we emit a `<draw:gradient>` def
|
|
3499
3626
|
// alongside it and reference the def via `draw:fill-gradient-name`
|
|
@@ -3501,6 +3628,14 @@ var buildChartObjectXml = function (chart, sheetNameById) {
|
|
|
3501
3628
|
// for `draw:angle` (so a 90° XLSX gradient is `900` here) and
|
|
3502
3629
|
// `linear` / `radial` for the two flavors we round-trip.
|
|
3503
3630
|
var gradientDefs = [];
|
|
3631
|
+
// Exploded pie / doughnut — ODF keeps the slice offset on the series
|
|
3632
|
+
// style (`chart:pie-offset`, a percentage of the radius) like OOXML's
|
|
3633
|
+
// per-series `<c:explosion>`.
|
|
3634
|
+
var explosion = isCircular &&
|
|
3635
|
+
typeof spec.explosion === "number" &&
|
|
3636
|
+
spec.explosion > 0
|
|
3637
|
+
? "<style:chart-properties chart:pie-offset=\"".concat(Math.round(spec.explosion), "\"/>")
|
|
3638
|
+
: "";
|
|
3504
3639
|
var seriesStyles = seriesRanges
|
|
3505
3640
|
.map(function (_range, index) {
|
|
3506
3641
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -3527,10 +3662,10 @@ var buildChartObjectXml = function (chart, sheetNameById) {
|
|
|
3527
3662
|
var angle = Math.round(((_f = gradient.degree) !== null && _f !== void 0 ? _f : 0) * 10);
|
|
3528
3663
|
gradientDefs.push("<draw:gradient draw:name=\"".concat(gradName, "\" draw:style=\"linear\" draw:start-color=\"").concat(startColor, "\" draw:end-color=\"").concat(endColor, "\" draw:start-intensity=\"100%\" draw:end-intensity=\"100%\" draw:angle=\"").concat(angle, "\"/>"));
|
|
3529
3664
|
}
|
|
3530
|
-
return "<style:style style:name=\"series".concat(index, "\" style:family=\"chart\"
|
|
3665
|
+
return "<style:style style:name=\"series".concat(index, "\" style:family=\"chart\">").concat(explosion, "<style:graphic-properties svg:stroke-color=\"").concat(startColor, "\" svg:stroke-width=\"0.08cm\" draw:fill=\"gradient\" draw:fill-gradient-name=\"").concat(gradName, "\"/></style:style>");
|
|
3531
3666
|
}
|
|
3532
3667
|
var fillColor = (seriesData === null || seriesData === void 0 ? void 0 : seriesData.color) || color;
|
|
3533
|
-
return "<style:style style:name=\"series".concat(index, "\" style:family=\"chart\"
|
|
3668
|
+
return "<style:style style:name=\"series".concat(index, "\" style:family=\"chart\">").concat(explosion, "<style:graphic-properties svg:stroke-color=\"").concat(fillColor, "\" svg:stroke-width=\"0.08cm\" draw:fill=\"none\"/></style:style>");
|
|
3534
3669
|
})
|
|
3535
3670
|
.join("");
|
|
3536
3671
|
var gradientDefsXml = gradientDefs.join("");
|
|
@@ -3553,7 +3688,7 @@ var buildChartObjectXml = function (chart, sheetNameById) {
|
|
|
3553
3688
|
return "<chart:series chart:class=\"".concat(chartClass, "\" chart:style-name=\"series").concat(index, "\" chart:values-cell-range-address=\"").concat(escapeXmlAddress(range), "\"").concat(labelAttr, ">").concat(pointsXml, "</chart:series>");
|
|
3554
3689
|
})
|
|
3555
3690
|
.join("");
|
|
3556
|
-
var axisXml =
|
|
3691
|
+
var axisXml = isCircular
|
|
3557
3692
|
? ""
|
|
3558
3693
|
: "<chart:axis chart:dimension=\"x\" chart:name=\"primary-x\" chart:style-name=\"axisx\"><chart:title/></chart:axis><chart:axis chart:dimension=\"y\" chart:name=\"primary-y\" chart:style-name=\"axisy\"><chart:title/></chart:axis>";
|
|
3559
3694
|
var categoriesAttr = domainRange
|
|
@@ -3561,14 +3696,66 @@ var buildChartObjectXml = function (chart, sheetNameById) {
|
|
|
3561
3696
|
: "";
|
|
3562
3697
|
var labelMode = domainRange ? "both" : hasSeriesLabels ? "row" : "none";
|
|
3563
3698
|
var plotAreaAttrs = " chart:data-source-has-labels=\"".concat(labelMode, "\"").concat(categoriesAttr);
|
|
3564
|
-
var wallFloor =
|
|
3699
|
+
var wallFloor = isCircular
|
|
3565
3700
|
? ""
|
|
3566
3701
|
: "<chart:wall chart:style-name=\"wall1\"/><chart:floor chart:style-name=\"floor1\"/>";
|
|
3567
|
-
var legendXml =
|
|
3702
|
+
var legendXml = isCircular
|
|
3568
3703
|
? ""
|
|
3569
3704
|
: "<chart:legend chart:legend-position=\"end\" chart:legend-align=\"center\" chart:style-name=\"legend1\"/>";
|
|
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
|
|
3705
|
+
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, "\" xmlns:number=\"").concat(ODS_NS.number, "\" office:version=\"1.2\"><office:automatic-styles>").concat(axisX.numberStyle).concat(axisY.numberStyle).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>").concat(axisX.style).concat(axisY.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>");
|
|
3571
3706
|
};
|
|
3707
|
+
/**
|
|
3708
|
+
* A numeric format pattern as an ODF data style — shared by cell number
|
|
3709
|
+
* formats and the chart axes' tick-label patterns. Only the numeric grammar
|
|
3710
|
+
* converts — digit placeholders, grouping, decimals, `%`, and a quoted /
|
|
3711
|
+
* bare currency literal before or after the digits (as a
|
|
3712
|
+
* `number:currency-style`; whitespace between the symbol and the digits is
|
|
3713
|
+
* kept as a `number:text` so `€ #,##0.00` and `€#,##0.00` stay distinct).
|
|
3714
|
+
* Dates, fractions, scientific and text patterns have no shape the ODS
|
|
3715
|
+
* parser reads back, so they return `undefined` and the caller degrades
|
|
3716
|
+
* (the axis stays linked to its source, a cell falls back to its type's
|
|
3717
|
+
* default style — both stated in the compatibility table).
|
|
3718
|
+
*/
|
|
3719
|
+
var numericPatternToOdsStyle = function (name, pattern) {
|
|
3720
|
+
var _a;
|
|
3721
|
+
// The first (positive) section; a `[$€-2]` currency token keeps its symbol
|
|
3722
|
+
// as a literal, the other bracket tokens (colours, conditions) drop.
|
|
3723
|
+
var section = pattern
|
|
3724
|
+
.split(";")[0]
|
|
3725
|
+
.replace(/\[\$([^\]-]*)(?:-[^\]]*)?\]/g, '"$1"')
|
|
3726
|
+
.replace(/\[[^\]]*\]/g, "")
|
|
3727
|
+
.trim();
|
|
3728
|
+
var match = section.match(/^((?:"[^"]*"|\\.|[^#0?.,%"\\])*)([#0?][#0?,]*(?:\.[#0?]+)?)((?:"[^"]*"|\\.|[^#0?"\\])*)$/);
|
|
3729
|
+
if (!match)
|
|
3730
|
+
return undefined;
|
|
3731
|
+
var unquote = function (literal) {
|
|
3732
|
+
return literal.replace(/"([^"]*)"/g, "$1").replace(/\\(.)/g, "$1");
|
|
3733
|
+
};
|
|
3734
|
+
var rawPrefix = unquote(match[1]);
|
|
3735
|
+
var rawSuffix = unquote(match[3]);
|
|
3736
|
+
var prefix = rawPrefix.trim();
|
|
3737
|
+
var digits = match[2];
|
|
3738
|
+
var suffix = rawSuffix.trim();
|
|
3739
|
+
var _b = __read(digits.split("."), 2), _c = _b[0], integerPart = _c === void 0 ? "" : _c, _d = _b[1], fractionPart = _d === void 0 ? "" : _d;
|
|
3740
|
+
var numberXml = "<number:number number:min-integer-digits=\"".concat(((_a = integerPart.match(/0/g)) !== null && _a !== void 0 ? _a : []).length, "\" number:decimal-places=\"").concat(fractionPart.length, "\" number:grouping=\"").concat(integerPart.includes(","), "\"/>");
|
|
3741
|
+
if (suffix.includes("%")) {
|
|
3742
|
+
return "<number:percentage-style style:name=\"".concat(name, "\">").concat(numberXml, "<number:text>%</number:text></number:percentage-style>");
|
|
3743
|
+
}
|
|
3744
|
+
var gap = function (literal) {
|
|
3745
|
+
return /\s$/.test(literal) || /^\s/.test(literal)
|
|
3746
|
+
? "<number:text> </number:text>"
|
|
3747
|
+
: "";
|
|
3748
|
+
};
|
|
3749
|
+
if (prefix) {
|
|
3750
|
+
return "<number:currency-style style:name=\"".concat(name, "\"><number:currency-symbol>").concat(escapeXml(prefix), "</number:currency-symbol>").concat(gap(rawPrefix)).concat(numberXml, "</number:currency-style>");
|
|
3751
|
+
}
|
|
3752
|
+
if (suffix) {
|
|
3753
|
+
return "<number:currency-style style:name=\"".concat(name, "\">").concat(numberXml).concat(gap(rawSuffix), "<number:currency-symbol>").concat(escapeXml(suffix), "</number:currency-symbol></number:currency-style>");
|
|
3754
|
+
}
|
|
3755
|
+
return "<number:number-style style:name=\"".concat(name, "\">").concat(numberXml, "</number:number-style>");
|
|
3756
|
+
};
|
|
3757
|
+
/** A chart axis' explicit tick-label pattern as an ODF data style (see `numericPatternToOdsStyle`). */
|
|
3758
|
+
var buildAxisNumberStyleXml = numericPatternToOdsStyle;
|
|
3572
3759
|
var buildChartRangeAddress = function (range, sheetNameById) {
|
|
3573
3760
|
var sheetName = sheetNameById.get(range.sheetId);
|
|
3574
3761
|
if (!sheetName)
|
|
@@ -3620,11 +3807,11 @@ var buildChartLabelAddressFromRange = function (range, sheetNameById) {
|
|
|
3620
3807
|
return "".concat(escapeSheetName(sheetName), ".").concat(labelRef);
|
|
3621
3808
|
};
|
|
3622
3809
|
var buildChartFramesXml = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
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,
|
|
3810
|
+
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, endAttrs;
|
|
3624
3811
|
var e_33, _c;
|
|
3625
|
-
var _d, _e, _f, _g;
|
|
3812
|
+
var _d, _e, _f, _g, _h;
|
|
3626
3813
|
var charts = _b.charts, sheet = _b.sheet, sheetName = _b.sheetName, sheetNameById = _b.sheetNameById, startIndex = _b.startIndex;
|
|
3627
|
-
return __generator(this, function (
|
|
3814
|
+
return __generator(this, function (_j) {
|
|
3628
3815
|
if (!charts.length) {
|
|
3629
3816
|
return [2 /*return*/, { frames: [], chartObjects: [], nextIndex: startIndex }];
|
|
3630
3817
|
}
|
|
@@ -3656,29 +3843,17 @@ var buildChartFramesXml = function (_a) { return __awaiter(void 0, [_a], void 0,
|
|
|
3656
3843
|
anchorAttr = anchorCell
|
|
3657
3844
|
? " table:anchor-cell-address=\"".concat(escapeXmlAddress(anchorCell), "\"")
|
|
3658
3845
|
: "";
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
span: heightPx,
|
|
3669
|
-
getSize: function (index) { return getRowHeightPx(sheet, index); },
|
|
3670
|
-
});
|
|
3671
|
-
endRef = cellToAddress({
|
|
3672
|
-
rowIndex: endRow.index,
|
|
3673
|
-
columnIndex: endColumn.index,
|
|
3846
|
+
endAttrs = buildFrameEndCellAttrs({
|
|
3847
|
+
sheet: sheet,
|
|
3848
|
+
overlay: (_h = placement.chart.position) === null || _h === void 0 ? void 0 : _h.overlayPosition,
|
|
3849
|
+
rowIndex: placement.rowIndex,
|
|
3850
|
+
columnIndex: placement.columnIndex,
|
|
3851
|
+
offsetXPx: offsetXPx,
|
|
3852
|
+
offsetYPx: offsetYPx,
|
|
3853
|
+
widthPx: widthPx,
|
|
3854
|
+
heightPx: heightPx,
|
|
3674
3855
|
});
|
|
3675
|
-
|
|
3676
|
-
endCellAttr = endCell
|
|
3677
|
-
? " table:end-cell-address=\"".concat(escapeXmlAddress(endCell), "\"")
|
|
3678
|
-
: "";
|
|
3679
|
-
endX = pxToCm(endColumn.offset).toFixed(2);
|
|
3680
|
-
endY = pxToCm(endRow.offset).toFixed(2);
|
|
3681
|
-
frames.push("<draw:frame draw:name=\"Chart".concat(index, "\" svg:width=\"").concat(width, "cm\" svg:height=\"").concat(height, "cm\" svg:x=\"").concat(offsetX, "cm\" svg:y=\"").concat(offsetY, "cm\" table:anchor-type=\"cell\"").concat(anchorAttr).concat(endCellAttr, " table:end-x=\"").concat(endX, "cm\" table:end-y=\"").concat(endY, "cm\"><draw:object xlink:href=\"").concat(folder, "\" xlink:type=\"simple\"/></draw:frame>"));
|
|
3856
|
+
frames.push("<draw:frame draw:name=\"Chart".concat(index, "\" svg:width=\"").concat(width, "cm\" svg:height=\"").concat(height, "cm\" svg:x=\"").concat(offsetX, "cm\" svg:y=\"").concat(offsetY, "cm\" table:anchor-type=\"cell\"").concat(anchorAttr).concat(endAttrs, "><draw:object xlink:href=\"").concat(folder, "\" xlink:type=\"simple\"/></draw:frame>"));
|
|
3682
3857
|
index += 1;
|
|
3683
3858
|
}
|
|
3684
3859
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { EmbeddedChart } from "@rowsncolumns/spreadsheet";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a chart's `pivotTableId` to the `<c:pivotSource><c:name>` Excel
|
|
4
|
+
* expects (`[Workbook]Sheet!PivotTable1`); `undefined` when the pivot is
|
|
5
|
+
* not exported, in which case the chart is written as a plain chart.
|
|
6
|
+
*/
|
|
7
|
+
export type ResolvePivotSourceName = (pivotTableId: string | number) => string | undefined;
|
|
8
|
+
export declare const buildChartXml: (input: EmbeddedChart, sheetNameById: Map<number, string>, resolvePivotSourceName?: ResolvePivotSourceName) => string | undefined;
|
|
3
9
|
//# sourceMappingURL=chart-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/chart-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"chart-builder.d.ts","sourceRoot":"","sources":["../../../../exporter/xlsx/chart-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,aAAa,EAEd,MAAM,2BAA2B,CAAC;AA63CnC;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACnC,YAAY,EAAE,MAAM,GAAG,MAAM,KAC1B,MAAM,GAAG,SAAS,CAAC;AAExB,eAAO,MAAM,aAAa,GACxB,OAAO,aAAa,EACpB,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,yBAAyB,sBAAsB,KAC9C,MAAM,GAAG,SAqqBX,CAAC"}
|