@rowsncolumns/toolkit 24.4.2 → 24.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +15 -2
- package/dist/cjs/excel-parser/interface.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/base/index.d.ts +2 -0
- package/dist/cjs/excel-parser/plugins/base/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/base/index.js +3 -0
- 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 +55 -1
- package/dist/cjs/excel-parser/plugins/xls/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xls/index.js +518 -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 +33 -14
- package/dist/cjs/excel-parser/plugins/xlsx/chartex.d.ts +37 -0
- package/dist/cjs/excel-parser/plugins/xlsx/chartex.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/chartex.js +244 -0
- 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/form-controls.d.ts +70 -0
- package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -0
- package/dist/cjs/excel-parser/plugins/xlsx/form-controls.js +295 -0
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +35 -2
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.js +737 -257
- 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 +15 -1
- package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/styles.js +102 -6
- package/dist/cjs/excel-parser/registry.d.ts +7 -0
- package/dist/cjs/excel-parser/registry.d.ts.map +1 -1
- package/dist/cjs/excel-parser/registry.js +29 -0
- package/dist/cjs/excel-parser/types.d.ts +17 -2
- package/dist/cjs/excel-parser/types.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.d.ts +3 -0
- package/dist/cjs/excel-parser/workbook.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.js +24 -14
- package/dist/cjs/excel-parser/worker.js +131 -131
- 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 +215 -39
- package/dist/cjs/exporter/xlsx/chartex-builder.d.ts +36 -0
- package/dist/cjs/exporter/xlsx/chartex-builder.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/chartex-builder.js +109 -0
- package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts +61 -0
- package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts.map +1 -0
- package/dist/cjs/exporter/xlsx/form-controls-builder.js +197 -0
- 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 +991 -297
- 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 +15 -2
- package/dist/esm/excel-parser/interface.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/base/index.d.ts +2 -0
- package/dist/esm/excel-parser/plugins/base/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/base/index.js +3 -0
- 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 +55 -1
- package/dist/esm/excel-parser/plugins/xls/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xls/index.js +441 -3
- 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 +30 -9
- package/dist/esm/excel-parser/plugins/xlsx/chartex.d.ts +37 -0
- package/dist/esm/excel-parser/plugins/xlsx/chartex.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/chartex.js +199 -0
- 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/form-controls.d.ts +70 -0
- package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -0
- package/dist/esm/excel-parser/plugins/xlsx/form-controls.js +246 -0
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +35 -2
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.js +454 -32
- 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 +15 -1
- package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/styles.js +92 -2
- package/dist/esm/excel-parser/registry.d.ts +7 -0
- package/dist/esm/excel-parser/registry.d.ts.map +1 -1
- package/dist/esm/excel-parser/registry.js +19 -0
- package/dist/esm/excel-parser/types.d.ts +17 -2
- package/dist/esm/excel-parser/types.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.d.ts +3 -0
- package/dist/esm/excel-parser/workbook.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.js +19 -10
- package/dist/esm/excel-parser/worker.js +12 -18
- 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 -28
- package/dist/esm/exporter/xlsx/chartex-builder.d.ts +36 -0
- package/dist/esm/exporter/xlsx/chartex-builder.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/chartex-builder.js +97 -0
- package/dist/esm/exporter/xlsx/form-controls-builder.d.ts +61 -0
- package/dist/esm/exporter/xlsx/form-controls-builder.d.ts.map +1 -0
- package/dist/esm/exporter/xlsx/form-controls-builder.js +173 -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 +675 -64
- 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
- package/xlsx.d.ts +14 -0
|
@@ -5,13 +5,14 @@ import { XMLParser } from "fast-xml-parser";
|
|
|
5
5
|
import { get } from "lodash-es";
|
|
6
6
|
import { parseRgce } from "./rgce-parser";
|
|
7
7
|
import { StreamingZipParser } from "../../zip-parser-streaming";
|
|
8
|
-
import { createFilterSpecsFromAutoFilter, excelColumnWidthToPixels, getRangeFromAddressRef, } from "../../helpers";
|
|
8
|
+
import { createFilterSpecsFromAutoFilter, excelColumnWidthToPixels, getRangeFromAddressRef, parseTableColumnTotals, } from "../../helpers";
|
|
9
9
|
import { defaultSpreadsheetTheme } from "../../theme-default";
|
|
10
10
|
import { BaseWorkbookPlugin } from "../base/index";
|
|
11
11
|
import { processChart } from "../xlsx/charts";
|
|
12
12
|
import { processAnchors } from "../xlsx/drawing";
|
|
13
13
|
import { readAllRecordHeaders } from "./biff-record-reader";
|
|
14
14
|
import { standardExcelFormatCodeById } from "../xlsx/numfmt";
|
|
15
|
+
import { DATE_1904_OFFSET_DAYS, isEpochShiftedFormat } from "../xlsx/styles";
|
|
15
16
|
import { extractThemeColors, extractThemeFonts, generateDarkThemeColors, } from "../xlsx/theme";
|
|
16
17
|
var RT = {
|
|
17
18
|
BrtCellRk: 0x0002,
|
|
@@ -300,10 +301,17 @@ var parseBrtShrFmla = function (payload) {
|
|
|
300
301
|
var parseWsView = function (payload) {
|
|
301
302
|
var reader = new Reader(payload);
|
|
302
303
|
var flags = reader.readUInt16LE();
|
|
303
|
-
//
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
// MS-XLSB 2.4.865 BrtWsView flag word: A fWnProt (0x0001), B fDspFmla
|
|
305
|
+
// (0x0002), C fDspGrid (0x0004), D fDspRwCol (0x0008), E fDspZeros
|
|
306
|
+
// (0x0010), F fRightToLeft (0x0020), G fSelected (0x0040), … Excel writes
|
|
307
|
+
// 0x039c for a plain sheet and 0x0398 for `showGridLines="0"`: gridlines
|
|
308
|
+
// are bit C, not bit B (which is "show formulas" and is normally clear).
|
|
309
|
+
var showGridLines = (flags & 0x0004) !== 0;
|
|
310
|
+
// OOXML `<sheetView rightToLeft="1">`.
|
|
311
|
+
var rightToLeft = (flags & 0x0020) !== 0;
|
|
312
|
+
return { showGridLines: showGridLines, rightToLeft: rightToLeft };
|
|
306
313
|
};
|
|
314
|
+
export var parseBrtWsViewPayload = parseWsView;
|
|
307
315
|
var parsePane = function (payload) {
|
|
308
316
|
var reader = new Reader(payload);
|
|
309
317
|
var xSplit = reader.readFloat64LE();
|
|
@@ -962,8 +970,8 @@ var resolveXf = function (styles, xfIndex) {
|
|
|
962
970
|
indent: (_e = xf.indent) !== null && _e !== void 0 ? _e : parent.indent,
|
|
963
971
|
};
|
|
964
972
|
};
|
|
965
|
-
var toCellData = function (parsed, styles, sharedStrings, enableCellXfsRegistry, enableSharedStrings, cellXfs) {
|
|
966
|
-
var _a, _b, _c, _d, _e;
|
|
973
|
+
var toCellData = function (parsed, styles, sharedStrings, enableCellXfsRegistry, enableSharedStrings, cellXfs, use1904) {
|
|
974
|
+
var _a, _b, _c, _d, _e, _f;
|
|
967
975
|
var xf = resolveXf(styles, parsed.styleRef);
|
|
968
976
|
var format = {};
|
|
969
977
|
var pattern = xf
|
|
@@ -1053,8 +1061,14 @@ var toCellData = function (parsed, styles, sharedStrings, enableCellXfsRegistry,
|
|
|
1053
1061
|
: {})), { ue: ue, ev: { sv: text } }), (parsed.formula ? {} : { fv: text }));
|
|
1054
1062
|
}
|
|
1055
1063
|
if (parsed.kind === "n") {
|
|
1056
|
-
|
|
1057
|
-
|
|
1064
|
+
// A 1904-system workbook (`BrtWbProp.fDate1904`) stores date serials
|
|
1065
|
+
// 1462 days below the engine's 1900 system; date-formatted numbers are
|
|
1066
|
+
// converted on the way in, like the XLSX importer does.
|
|
1067
|
+
var value = Number(parsed.value) +
|
|
1068
|
+
(use1904 && isEpochShiftedFormat((_d = format.numberFormat) === null || _d === void 0 ? void 0 : _d.type)
|
|
1069
|
+
? DATE_1904_OFFSET_DAYS
|
|
1070
|
+
: 0);
|
|
1071
|
+
var pattern_1 = (_f = (_e = format.numberFormat) === null || _e === void 0 ? void 0 : _e.pattern) !== null && _f !== void 0 ? _f : "GENERAL";
|
|
1058
1072
|
var fv = ssfFormat(pattern_1, value);
|
|
1059
1073
|
// If there's a formula, use it in ue.fv, otherwise use the numeric value
|
|
1060
1074
|
var ue = parsed.formula ? { fv: "=".concat(parsed.formula) } : { nv: value };
|
|
@@ -1299,6 +1313,7 @@ var XlsbPlugin = /** @class */ (function (_super) {
|
|
|
1299
1313
|
sheet.rowMetadata = stats.rowMetadata;
|
|
1300
1314
|
sheet.columnMetadata = stats.columnMetadata;
|
|
1301
1315
|
sheet.showGridLines = stats.showGridLines;
|
|
1316
|
+
sheet.rightToLeft = stats.rightToLeft;
|
|
1302
1317
|
sheet.frozenRowCount = stats.frozenRowCount;
|
|
1303
1318
|
sheet.frozenColumnCount = stats.frozenColumnCount;
|
|
1304
1319
|
sheet.basicFilterRange = stats.basicFilterRange;
|
|
@@ -1731,12 +1746,13 @@ var XlsbPlugin = /** @class */ (function (_super) {
|
|
|
1731
1746
|
columns = columnDefsArray.map(function (colDef) {
|
|
1732
1747
|
var _a;
|
|
1733
1748
|
var name = ((_a = colDef === null || colDef === void 0 ? void 0 : colDef.a$) === null || _a === void 0 ? void 0 : _a.name) || "";
|
|
1749
|
+
var totals = parseTableColumnTotals(colDef);
|
|
1734
1750
|
var calculatedColumnFormula = get(colDef, "calculatedColumnFormula") ||
|
|
1735
1751
|
get(colDef, "x:calculatedColumnFormula");
|
|
1736
1752
|
if (calculatedColumnFormula) {
|
|
1737
|
-
return { name: name, formula: calculatedColumnFormula };
|
|
1753
|
+
return __assign(__assign({ name: name }, totals), { formula: calculatedColumnFormula });
|
|
1738
1754
|
}
|
|
1739
|
-
return { name: name };
|
|
1755
|
+
return __assign({ name: name }, totals);
|
|
1740
1756
|
});
|
|
1741
1757
|
autoFilter = (_d = tableDefinition.autoFilter) !== null && _d !== void 0 ? _d : tableDefinition["x:autoFilter"];
|
|
1742
1758
|
filterSpecs = createFilterSpecsFromAutoFilter(autoFilter);
|
|
@@ -1785,7 +1801,7 @@ var XlsbPlugin = /** @class */ (function (_super) {
|
|
|
1785
1801
|
};
|
|
1786
1802
|
XlsbPlugin.prototype.scanSheetStats = function (path) {
|
|
1787
1803
|
return __awaiter(this, void 0, void 0, function () {
|
|
1788
|
-
var binary, records, currentRow, maxRow, maxCol, prevCol, merges, rowMetadata, columnMetadata, showGridLines, frozenRowCount, frozenColumnCount, basicFilterRange, tablePartRelIds, records_5, records_5_1, record, payload, view, pane, relId, parsedRow, parsedCol, col, dimensionProps, merge, parsed;
|
|
1804
|
+
var binary, records, currentRow, maxRow, maxCol, prevCol, merges, rowMetadata, columnMetadata, showGridLines, rightToLeft, frozenRowCount, frozenColumnCount, basicFilterRange, tablePartRelIds, records_5, records_5_1, record, payload, view, pane, relId, parsedRow, parsedCol, col, dimensionProps, merge, parsed;
|
|
1789
1805
|
var e_14, _a;
|
|
1790
1806
|
var _this = this;
|
|
1791
1807
|
return __generator(this, function (_b) {
|
|
@@ -1809,6 +1825,8 @@ var XlsbPlugin = /** @class */ (function (_super) {
|
|
|
1809
1825
|
if (record.type === RT.BrtWsView) {
|
|
1810
1826
|
view = parseWsView(payload);
|
|
1811
1827
|
showGridLines = view.showGridLines;
|
|
1828
|
+
if (view.rightToLeft)
|
|
1829
|
+
rightToLeft = true;
|
|
1812
1830
|
continue;
|
|
1813
1831
|
}
|
|
1814
1832
|
if (record.type === RT.BrtPane) {
|
|
@@ -1898,6 +1916,7 @@ var XlsbPlugin = /** @class */ (function (_super) {
|
|
|
1898
1916
|
rowMetadata: rowMetadata,
|
|
1899
1917
|
columnMetadata: columnMetadata,
|
|
1900
1918
|
showGridLines: showGridLines,
|
|
1919
|
+
rightToLeft: rightToLeft,
|
|
1901
1920
|
frozenRowCount: frozenRowCount,
|
|
1902
1921
|
frozenColumnCount: frozenColumnCount,
|
|
1903
1922
|
basicFilterRange: basicFilterRange,
|
|
@@ -1962,9 +1981,9 @@ var XlsbPlugin = /** @class */ (function (_super) {
|
|
|
1962
1981
|
sheet.basicFilterRange.startColumnIndex &&
|
|
1963
1982
|
t.range.endColumnIndex === sheet.basicFilterRange.endColumnIndex;
|
|
1964
1983
|
})) === null || _d === void 0 ? void 0 : _d.filterSpecs;
|
|
1965
|
-
sheets.push(__assign(__assign(__assign(__assign({ sheetId: sheet.sheetId, title: sheet.title, hidden: sheet.hidden, rowCount: Math.max(minRowCount, sheet.rowCount), columnCount: Math.max(minColumnCount, sheet.columnCount), rowMetadata: sheet.rowMetadata, columnMetadata: sheet.columnMetadata, merges: sheet.merges }, (sheet.showGridLines !== undefined
|
|
1984
|
+
sheets.push(__assign(__assign(__assign(__assign(__assign({ sheetId: sheet.sheetId, title: sheet.title, hidden: sheet.hidden, rowCount: Math.max(minRowCount, sheet.rowCount), columnCount: Math.max(minColumnCount, sheet.columnCount), rowMetadata: sheet.rowMetadata, columnMetadata: sheet.columnMetadata, merges: sheet.merges }, (sheet.showGridLines !== undefined
|
|
1966
1985
|
? { showGridLines: sheet.showGridLines }
|
|
1967
|
-
: {})), (sheet.frozenRowCount !== undefined && sheet.frozenRowCount > 0
|
|
1986
|
+
: {})), (sheet.rightToLeft ? { rightToLeft: true } : {})), (sheet.frozenRowCount !== undefined && sheet.frozenRowCount > 0
|
|
1968
1987
|
? { frozenRowCount: sheet.frozenRowCount }
|
|
1969
1988
|
: {})), (sheet.frozenColumnCount !== undefined && sheet.frozenColumnCount > 0
|
|
1970
1989
|
? { frozenColumnCount: sheet.frozenColumnCount }
|
|
@@ -2156,7 +2175,7 @@ var XlsbPlugin = /** @class */ (function (_super) {
|
|
|
2156
2175
|
row = { values: [] };
|
|
2157
2176
|
rows.set(parsed.row, row);
|
|
2158
2177
|
}
|
|
2159
|
-
row.values[parsed.col] = toCellData(parsed, this_2.styles, this_2.sharedStrings, enableCellXfsRegistry, enableSharedStrings, this_2.cellXfs);
|
|
2178
|
+
row.values[parsed.col] = toCellData(parsed, this_2.styles, this_2.sharedStrings, enableCellXfsRegistry, enableSharedStrings, this_2.cellXfs, this_2.use1904);
|
|
2160
2179
|
};
|
|
2161
2180
|
try {
|
|
2162
2181
|
for (records_7 = (e_19 = void 0, __values(records)), records_7_1 = records_7.next(); !records_7_1.done; records_7_1 = records_7.next()) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { EmbeddedChart, SheetRange } from "@rowsncolumns/spreadsheet";
|
|
2
|
+
import type { StreamingZipParser } from "../../zip-parser-streaming";
|
|
3
|
+
import { type ResolveSheetId, type SheetDimensions } from "./charts";
|
|
4
|
+
/**
|
|
5
|
+
* Excel 2016+ "chartex" charts (`xl/charts/chartEx{N}.xml`, namespace
|
|
6
|
+
* `http://schemas.microsoft.com/office/drawing/2014/chartex`): treemap,
|
|
7
|
+
* sunburst, histogram / pareto, box & whisker, waterfall, funnel. They are
|
|
8
|
+
* anchored through an `mc:AlternateContent` whose `Choice` graphic frame
|
|
9
|
+
* carries `<cx:chart r:id>` instead of `<c:chart>`, and their data lives in
|
|
10
|
+
* `<cx:chartData><cx:data>` dimensions (`strDim type="cat"` for the
|
|
11
|
+
* hierarchy, `numDim type="size"|"val"` for the numbers) referenced by the
|
|
12
|
+
* series through `<cx:dataId>`.
|
|
13
|
+
*
|
|
14
|
+
* The exporter counterpart is `exporter/xlsx/chartex-builder.ts`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const CHART_EX_REL_TYPE = "http://schemas.microsoft.com/office/2014/relationships/chartEx";
|
|
17
|
+
export declare const CHART_EX_GRAPHIC_URI = "http://schemas.microsoft.com/office/drawing/2014/chartex";
|
|
18
|
+
/**
|
|
19
|
+
* `<cx:chart r:id>` inside an anchor's `mc:AlternateContent` choice (Excel
|
|
20
|
+
* also writes a plain `xdr:graphicFrame` for some producers — both forms are
|
|
21
|
+
* checked). Returns the `cx:chart` node or undefined for non-chartex anchors.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getChartExReferenceFromAnchor(anchor: any): any;
|
|
24
|
+
/**
|
|
25
|
+
* Split a multi-column hierarchy range (Excel lays the treemap hierarchy out
|
|
26
|
+
* as columns, top level first, leaf last) into `parentLabels` (one entry per
|
|
27
|
+
* parent column) and `labels` (the leaf column).
|
|
28
|
+
*/
|
|
29
|
+
export declare const splitHierarchyRange: (range: SheetRange) => {
|
|
30
|
+
parentLabels: SheetRange[];
|
|
31
|
+
labels: SheetRange;
|
|
32
|
+
};
|
|
33
|
+
/** Parse a `cx:chartSpace` DOM into an `EmbeddedChart` spec (null when unsupported). */
|
|
34
|
+
export declare function parseChartExSpec(chartSpaceDom: any, sheetId: number, resolveSheetId?: ResolveSheetId): EmbeddedChart["spec"] | null;
|
|
35
|
+
/** Resolve + parse one chartex part referenced from a drawing anchor. */
|
|
36
|
+
export declare function processChartEx(chartTarget: string, drawingPath: string, anchor: any, sheetId: number, zipParser: StreamingZipParser, xmlParser: any, sheetDimensions?: SheetDimensions, resolveSheetId?: ResolveSheetId): Promise<EmbeddedChart | null>;
|
|
37
|
+
//# sourceMappingURL=chartex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartex.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/chartex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACb,UAAU,EACX,MAAM,2BAA2B,CAAC;AAInC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,iBAAiB,mEACoC,CAAC;AACnE,eAAO,MAAM,oBAAoB,6DAC2B,CAAC;AAyB7D;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAoB9D;AA8BD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,UAAU,KAChB;IAAE,YAAY,EAAE,UAAU,EAAE,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAalD,CAAC;AAWF,wFAAwF;AACxF,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,GAAG,EAClB,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,cAAc,GAC9B,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI,CA0D9B;AAED,yEAAyE;AACzE,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,kBAAkB,EAC7B,SAAS,EAAE,GAAG,EACd,eAAe,CAAC,EAAE,eAAe,EACjC,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAsB/B"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator, __read, __spreadArray, __values } from "tslib";
|
|
2
|
+
import { generateSelectionsFromFormula, uuid } from "@rowsncolumns/utils";
|
|
3
|
+
import { get } from "lodash-es";
|
|
4
|
+
import { extractChartPosition, } from "./charts";
|
|
5
|
+
/**
|
|
6
|
+
* Excel 2016+ "chartex" charts (`xl/charts/chartEx{N}.xml`, namespace
|
|
7
|
+
* `http://schemas.microsoft.com/office/drawing/2014/chartex`): treemap,
|
|
8
|
+
* sunburst, histogram / pareto, box & whisker, waterfall, funnel. They are
|
|
9
|
+
* anchored through an `mc:AlternateContent` whose `Choice` graphic frame
|
|
10
|
+
* carries `<cx:chart r:id>` instead of `<c:chart>`, and their data lives in
|
|
11
|
+
* `<cx:chartData><cx:data>` dimensions (`strDim type="cat"` for the
|
|
12
|
+
* hierarchy, `numDim type="size"|"val"` for the numbers) referenced by the
|
|
13
|
+
* series through `<cx:dataId>`.
|
|
14
|
+
*
|
|
15
|
+
* The exporter counterpart is `exporter/xlsx/chartex-builder.ts`.
|
|
16
|
+
*/
|
|
17
|
+
export var CHART_EX_REL_TYPE = "http://schemas.microsoft.com/office/2014/relationships/chartEx";
|
|
18
|
+
export var CHART_EX_GRAPHIC_URI = "http://schemas.microsoft.com/office/drawing/2014/chartex";
|
|
19
|
+
var asArray = function (value) {
|
|
20
|
+
return value == null ? [] : Array.isArray(value) ? value : [value];
|
|
21
|
+
};
|
|
22
|
+
/** Read a child by local name, tolerating any namespace prefix. */
|
|
23
|
+
var child = function (node, localName) {
|
|
24
|
+
var e_1, _a;
|
|
25
|
+
if (!node || typeof node !== "object")
|
|
26
|
+
return undefined;
|
|
27
|
+
if (node[localName] !== undefined)
|
|
28
|
+
return node[localName];
|
|
29
|
+
try {
|
|
30
|
+
for (var _b = __values(Object.keys(node)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
31
|
+
var key = _c.value;
|
|
32
|
+
var colon = key.indexOf(":");
|
|
33
|
+
if (colon >= 0 && key.slice(colon + 1) === localName)
|
|
34
|
+
return node[key];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
38
|
+
finally {
|
|
39
|
+
try {
|
|
40
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
41
|
+
}
|
|
42
|
+
finally { if (e_1) throw e_1.error; }
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
};
|
|
46
|
+
var textOf = function (node) {
|
|
47
|
+
if (node == null)
|
|
48
|
+
return undefined;
|
|
49
|
+
if (typeof node === "object") {
|
|
50
|
+
var inner = node.t$;
|
|
51
|
+
return inner == null ? undefined : String(inner);
|
|
52
|
+
}
|
|
53
|
+
return String(node);
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* `<cx:chart r:id>` inside an anchor's `mc:AlternateContent` choice (Excel
|
|
57
|
+
* also writes a plain `xdr:graphicFrame` for some producers — both forms are
|
|
58
|
+
* checked). Returns the `cx:chart` node or undefined for non-chartex anchors.
|
|
59
|
+
*/
|
|
60
|
+
export function getChartExReferenceFromAnchor(anchor) {
|
|
61
|
+
var e_2, _a, e_3, _b, e_4, _c;
|
|
62
|
+
var frames = [];
|
|
63
|
+
try {
|
|
64
|
+
for (var _d = __values(asArray(child(anchor, "AlternateContent"))), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
65
|
+
var alternate = _e.value;
|
|
66
|
+
try {
|
|
67
|
+
for (var _f = (e_3 = void 0, __values(asArray(child(alternate, "Choice")))), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
68
|
+
var choice = _g.value;
|
|
69
|
+
frames.push.apply(frames, __spreadArray([], __read(asArray(child(choice, "graphicFrame"))), false));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
73
|
+
finally {
|
|
74
|
+
try {
|
|
75
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
76
|
+
}
|
|
77
|
+
finally { if (e_3) throw e_3.error; }
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
82
|
+
finally {
|
|
83
|
+
try {
|
|
84
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
85
|
+
}
|
|
86
|
+
finally { if (e_2) throw e_2.error; }
|
|
87
|
+
}
|
|
88
|
+
frames.push.apply(frames, __spreadArray([], __read(asArray(child(anchor, "graphicFrame"))), false));
|
|
89
|
+
try {
|
|
90
|
+
for (var frames_1 = __values(frames), frames_1_1 = frames_1.next(); !frames_1_1.done; frames_1_1 = frames_1.next()) {
|
|
91
|
+
var frame = frames_1_1.value;
|
|
92
|
+
var graphicData = child(child(frame, "graphic"), "graphicData");
|
|
93
|
+
if (!graphicData)
|
|
94
|
+
continue;
|
|
95
|
+
var uri = get(graphicData, "a$.uri");
|
|
96
|
+
var cxChart = child(graphicData, "chart");
|
|
97
|
+
if (uri === CHART_EX_GRAPHIC_URI && cxChart)
|
|
98
|
+
return cxChart;
|
|
99
|
+
// A `cx:`-prefixed chart element without the uri attribute (defensive).
|
|
100
|
+
if (cxChart && Object.keys(graphicData).some(function (k) { return k.startsWith("cx:"); })) {
|
|
101
|
+
return cxChart;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
106
|
+
finally {
|
|
107
|
+
try {
|
|
108
|
+
if (frames_1_1 && !frames_1_1.done && (_c = frames_1.return)) _c.call(frames_1);
|
|
109
|
+
}
|
|
110
|
+
finally { if (e_4) throw e_4.error; }
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
/** `layoutId` → engine chart type. Unknown layouts are not imported. */
|
|
115
|
+
var CHART_TYPE_BY_LAYOUT = {
|
|
116
|
+
treemap: "treemap",
|
|
117
|
+
sunburst: "sunburst",
|
|
118
|
+
waterfall: "waterfall",
|
|
119
|
+
funnel: "funnel",
|
|
120
|
+
boxWhisker: "boxplot",
|
|
121
|
+
// `clusteredColumn` is a histogram / pareto only when it carries `<cx:binning>`.
|
|
122
|
+
};
|
|
123
|
+
var sourcesFromRef = function (ref, hostSheetId, resolveSheetId) {
|
|
124
|
+
if (!ref)
|
|
125
|
+
return [];
|
|
126
|
+
var selections = generateSelectionsFromFormula("=".concat(ref));
|
|
127
|
+
return selections.map(function (sel) {
|
|
128
|
+
var _a;
|
|
129
|
+
return (__assign(__assign({}, sel.range), { sheetId: (_a = (sel.sheetName ? resolveSheetId === null || resolveSheetId === void 0 ? void 0 : resolveSheetId(sel.sheetName) : undefined)) !== null && _a !== void 0 ? _a : hostSheetId }));
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
var chartData = function (sources) {
|
|
133
|
+
return ({ sources: sources });
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Split a multi-column hierarchy range (Excel lays the treemap hierarchy out
|
|
137
|
+
* as columns, top level first, leaf last) into `parentLabels` (one entry per
|
|
138
|
+
* parent column) and `labels` (the leaf column).
|
|
139
|
+
*/
|
|
140
|
+
export var splitHierarchyRange = function (range) {
|
|
141
|
+
var parentLabels = [];
|
|
142
|
+
for (var c = range.startColumnIndex; c < range.endColumnIndex; c++) {
|
|
143
|
+
parentLabels.push(__assign(__assign({}, range), { startColumnIndex: c, endColumnIndex: c }));
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
parentLabels: parentLabels,
|
|
147
|
+
labels: __assign(__assign({}, range), { startColumnIndex: range.endColumnIndex, endColumnIndex: range.endColumnIndex }),
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
var dimensionRef = function (data, dimTag, type) {
|
|
151
|
+
var _a, _b;
|
|
152
|
+
var dims = asArray(child(data, dimTag)).filter(function (dim) { return get(dim, "a$.type") === type; });
|
|
153
|
+
var dim = (_a = dims[0]) !== null && _a !== void 0 ? _a : (dimTag === "numDim" ? asArray(child(data, dimTag))[0] : undefined);
|
|
154
|
+
var f = child(dim, "f");
|
|
155
|
+
return ((_b = textOf(Array.isArray(f) ? f[0] : f)) === null || _b === void 0 ? void 0 : _b.trim()) || undefined;
|
|
156
|
+
};
|
|
157
|
+
/** Parse a `cx:chartSpace` DOM into an `EmbeddedChart` spec (null when unsupported). */
|
|
158
|
+
export function parseChartExSpec(chartSpaceDom, sheetId, resolveSheetId) {
|
|
159
|
+
var _a, _b, _c, _d, _e;
|
|
160
|
+
var chartSpace = (_a = child(chartSpaceDom, "chartSpace")) !== null && _a !== void 0 ? _a : chartSpaceDom;
|
|
161
|
+
var chart = child(chartSpace, "chart");
|
|
162
|
+
if (!chart)
|
|
163
|
+
return null;
|
|
164
|
+
var region = child(child(chart, "plotArea"), "plotAreaRegion");
|
|
165
|
+
var series = asArray(child(region, "series"))[0];
|
|
166
|
+
if (!series)
|
|
167
|
+
return null;
|
|
168
|
+
var layoutId = String((_b = get(series, "a$.layoutId")) !== null && _b !== void 0 ? _b : "");
|
|
169
|
+
// Excel nests `<cx:binning>` in `<cx:layoutPr>`; tolerate it directly on the series too.
|
|
170
|
+
var binning = (_c = child(child(series, "layoutPr"), "binning")) !== null && _c !== void 0 ? _c : child(series, "binning");
|
|
171
|
+
var chartType = layoutId === "clusteredColumn" && binning
|
|
172
|
+
? "histogram"
|
|
173
|
+
: CHART_TYPE_BY_LAYOUT[layoutId];
|
|
174
|
+
if (!chartType)
|
|
175
|
+
return null;
|
|
176
|
+
var dataId = String((_d = get(child(series, "dataId"), "a$.val")) !== null && _d !== void 0 ? _d : "0");
|
|
177
|
+
var data = (_e = asArray(child(child(chartSpace, "chartData"), "data")).find(function (d) { return String(get(d, "a$.id")) === dataId; })) !== null && _e !== void 0 ? _e : asArray(child(child(chartSpace, "chartData"), "data"))[0];
|
|
178
|
+
if (!data)
|
|
179
|
+
return null;
|
|
180
|
+
var title = textOf(child(child(child(child(chart, "title"), "tx"), "txData"), "v"));
|
|
181
|
+
var catRef = dimensionRef(data, "strDim", "cat");
|
|
182
|
+
var catSources = sourcesFromRef(catRef, sheetId, resolveSheetId);
|
|
183
|
+
if (chartType === "treemap" || chartType === "sunburst") {
|
|
184
|
+
var sizeRef = dimensionRef(data, "numDim", "size");
|
|
185
|
+
var sizeSources = sourcesFromRef(sizeRef, sheetId, resolveSheetId);
|
|
186
|
+
if (!catSources.length || !sizeSources.length)
|
|
187
|
+
return null;
|
|
188
|
+
var hierarchy = splitHierarchyRange(catSources[0]);
|
|
189
|
+
return __assign(__assign({ chartType: chartType }, (title ? { title: title } : {})), { labels: [chartData([hierarchy.labels])], parentLabels: hierarchy.parentLabels.map(function (range) { return chartData([range]); }), sizeData: [chartData(sizeSources)] });
|
|
190
|
+
}
|
|
191
|
+
var valRef = dimensionRef(data, "numDim", "val");
|
|
192
|
+
var valSources = sourcesFromRef(valRef, sheetId, resolveSheetId);
|
|
193
|
+
if (!valSources.length)
|
|
194
|
+
return null;
|
|
195
|
+
var spec = __assign(__assign(__assign({ chartType: chartType }, (title ? { title: title } : {})), { series: [chartData(valSources)] }), (catSources.length ? { domains: [chartData(catSources)] } : {}));
|
|
196
|
+
if (chartType === "histogram") {
|
|
197
|
+
var binCount = Number(get(child(binning, "binCount"), "a$.val"));
|
|
198
|
+
if (Number.isFinite(binCount) && binCount > 0)
|
|
199
|
+
spec.binCount = binCount;
|
|
200
|
+
}
|
|
201
|
+
return spec;
|
|
202
|
+
}
|
|
203
|
+
/** Resolve + parse one chartex part referenced from a drawing anchor. */
|
|
204
|
+
export function processChartEx(chartTarget, drawingPath, anchor, sheetId, zipParser, xmlParser, sheetDimensions, resolveSheetId) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
+
var chartPath, drawingDir, content, _a, spec, position;
|
|
207
|
+
return __generator(this, function (_b) {
|
|
208
|
+
switch (_b.label) {
|
|
209
|
+
case 0:
|
|
210
|
+
chartPath = chartTarget;
|
|
211
|
+
drawingDir = drawingPath.substring(0, drawingPath.lastIndexOf("/"));
|
|
212
|
+
if (chartPath.startsWith("/")) {
|
|
213
|
+
chartPath = chartPath.slice(1);
|
|
214
|
+
}
|
|
215
|
+
else if (chartPath.startsWith("../")) {
|
|
216
|
+
chartPath = "xl/".concat(chartPath.replace("../", ""));
|
|
217
|
+
}
|
|
218
|
+
else if (!chartPath.startsWith("xl/")) {
|
|
219
|
+
chartPath = "".concat(drawingDir, "/").concat(chartPath);
|
|
220
|
+
}
|
|
221
|
+
_b.label = 1;
|
|
222
|
+
case 1:
|
|
223
|
+
_b.trys.push([1, 3, , 4]);
|
|
224
|
+
return [4 /*yield*/, zipParser.getText(chartPath)];
|
|
225
|
+
case 2:
|
|
226
|
+
content = _b.sent();
|
|
227
|
+
return [3 /*break*/, 4];
|
|
228
|
+
case 3:
|
|
229
|
+
_a = _b.sent();
|
|
230
|
+
return [2 /*return*/, null];
|
|
231
|
+
case 4:
|
|
232
|
+
if (!content)
|
|
233
|
+
return [2 /*return*/, null];
|
|
234
|
+
spec = parseChartExSpec(xmlParser.parse(content), sheetId, resolveSheetId);
|
|
235
|
+
if (!spec)
|
|
236
|
+
return [2 /*return*/, null];
|
|
237
|
+
position = extractChartPosition(anchor, sheetId, sheetDimensions);
|
|
238
|
+
if (!position)
|
|
239
|
+
return [2 /*return*/, null];
|
|
240
|
+
return [2 /*return*/, { chartId: uuid(), spec: spec, position: position }];
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
}
|
|
@@ -17,6 +17,16 @@ export declare function extractChartDataRange(plotArea: any, chartType: string,
|
|
|
17
17
|
export declare function extractHiddenDimensionStrategy(chart: any): HIDDEN_DIMENSION_STRATEGY | undefined;
|
|
18
18
|
export declare function extractChartTitle(chart: any): string;
|
|
19
19
|
export declare function determineChartType(chart: any): "bar" | "column" | "line" | "pie" | "doughnut" | "area" | "radar" | "stock" | "scatter" | "bubble" | "treemap" | "sunburst" | "histogram" | "boxplot" | "waterfall" | "funnel";
|
|
20
|
+
/**
|
|
21
|
+
* The authored 3-D / surface chart class, when the plot area's chart
|
|
22
|
+
* element is one of Excel's 3-D variants. These degrade to their 2-D
|
|
23
|
+
* `chartType` (bar3DChart → bar/column, line3DChart → line, pie3DChart →
|
|
24
|
+
* pie, area3DChart / surfaceChart / surface3DChart → area) and the
|
|
25
|
+
* original class is preserved verbatim as `sourceChartType`, matching the
|
|
26
|
+
* Rust importer, so the renderer's echarts-gl pipeline and the exporter's
|
|
27
|
+
* 3-D writer can restore it. Undefined for plain 2-D charts.
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractThreeDSourceChartType(plotArea: any): "BAR_3D" | "LINE_3D" | "PIE_3D" | "AREA_3D" | "SURFACE" | "SURFACE_3D" | undefined;
|
|
20
30
|
/**
|
|
21
31
|
* Phase 5.5 — pull binCount out of the c15:histogramChart extension
|
|
22
32
|
* marker. Returns undefined if absent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charts.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/charts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EAET,aAAa,EACb,sBAAsB,EACtB,yBAAyB,EACzB,UAAU,EACX,MAAM,2BAA2B,CAAC;AAInC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC;AAkDnF,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,kBAAkB,EAC7B,SAAS,EAAE,GAAG,EACd,eAAe,CAAC,EAAE,eAAe,EACjC,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"charts.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/charts.ts"],"names":[],"mappings":"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"}
|
|
@@ -50,7 +50,7 @@ function toInt(value) {
|
|
|
50
50
|
}
|
|
51
51
|
export function processChart(chartTarget, drawingPath, anchor, sheetId, zipParser, xmlParser, sheetDimensions, resolveSheetId) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
-
var chartPath, drawingDir, chartContent, chartXml, chart, chartSpaceRoot, roundedCornersRaw, roundedCornersVal, roundedCorners, chartId, title, titleTextFormat, chartType, plotArea, series, domains, dataRange, bubbleSizes, scatterStyle, hiddenDimensionStrategy, position, legend, dataLabels, _a, valueAxisOptions, secondaryValueAxisOptions, categoryAxisOptions, doughnutHoleSize, ofPieOptions, radarStyle, binCount, barLayout, err_1;
|
|
53
|
+
var chartPath, drawingDir, chartContent, chartXml, chart, chartSpaceRoot, roundedCornersRaw, roundedCornersVal, roundedCorners, chartId, title, titleTextFormat, chartType, plotArea, series, domains, dataRange, bubbleSizes, scatterStyle, hiddenDimensionStrategy, position, legend, dataLabels, _a, valueAxisOptions, secondaryValueAxisOptions, categoryAxisOptions, doughnutHoleSize, ofPieOptions, threeDSourceChartType, radarStyle, binCount, barLayout, err_1;
|
|
54
54
|
var _b;
|
|
55
55
|
return __generator(this, function (_c) {
|
|
56
56
|
switch (_c.label) {
|
|
@@ -119,6 +119,7 @@ export function processChart(chartTarget, drawingPath, anchor, sheetId, zipParse
|
|
|
119
119
|
_a = extractAxisOptions(plotArea), valueAxisOptions = _a.valueAxisOptions, secondaryValueAxisOptions = _a.secondaryValueAxisOptions, categoryAxisOptions = _a.categoryAxisOptions;
|
|
120
120
|
doughnutHoleSize = chartType === "doughnut" ? extractDoughnutHoleSize(plotArea) : undefined;
|
|
121
121
|
ofPieOptions = chartType === "pie" ? extractOfPieOptions(plotArea) : undefined;
|
|
122
|
+
threeDSourceChartType = extractThreeDSourceChartType(plotArea);
|
|
122
123
|
radarStyle = chartType === "radar" ? extractRadarStyle(plotArea) : undefined;
|
|
123
124
|
binCount = chartType === "histogram"
|
|
124
125
|
? extractC15HistogramBinCount(plotArea)
|
|
@@ -128,7 +129,7 @@ export function processChart(chartTarget, drawingPath, anchor, sheetId, zipParse
|
|
|
128
129
|
: undefined;
|
|
129
130
|
return [2 /*return*/, {
|
|
130
131
|
chartId: chartId,
|
|
131
|
-
spec: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ title: title }, (titleTextFormat ? { titleTextFormat: titleTextFormat } : {})), { chartType: chartType, domains: domains, series: series, dataRange: dataRange, hiddenDimensionStrategy: hiddenDimensionStrategy }), (chartType === "scatter" || chartType === "bubble"
|
|
132
|
+
spec: __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ title: title }, (titleTextFormat ? { titleTextFormat: titleTextFormat } : {})), { chartType: chartType, domains: domains, series: series, dataRange: dataRange, hiddenDimensionStrategy: hiddenDimensionStrategy }), (chartType === "scatter" || chartType === "bubble"
|
|
132
133
|
? { bubbleLabels: [] }
|
|
133
134
|
: {})), (bubbleSizes && bubbleSizes.length ? { bubbleSizes: bubbleSizes } : {})), (scatterStyle
|
|
134
135
|
? { scatterStyle: scatterStyle }
|
|
@@ -137,7 +138,9 @@ export function processChart(chartTarget, drawingPath, anchor, sheetId, zipParse
|
|
|
137
138
|
: {})), (categoryAxisOptions ? { categoryAxisOptions: categoryAxisOptions } : {})), (typeof doughnutHoleSize === "number"
|
|
138
139
|
? { doughnutHoleSize: doughnutHoleSize }
|
|
139
140
|
: {})), (ofPieOptions
|
|
140
|
-
? __assign({ sourceChartType: "OF_PIE" }, ofPieOptions) : {})), (
|
|
141
|
+
? __assign({ sourceChartType: "OF_PIE" }, ofPieOptions) : {})), (threeDSourceChartType && !ofPieOptions
|
|
142
|
+
? { sourceChartType: threeDSourceChartType }
|
|
143
|
+
: {})), (radarStyle ? { radarStyle: radarStyle } : {})), (typeof binCount === "number" ? { binCount: binCount } : {})), ((barLayout === null || barLayout === void 0 ? void 0 : barLayout.stackedType)
|
|
141
144
|
? { stackedType: barLayout.stackedType }
|
|
142
145
|
: {})), (typeof (barLayout === null || barLayout === void 0 ? void 0 : barLayout.overlap) === "number"
|
|
143
146
|
? { overlap: barLayout.overlap }
|
|
@@ -208,6 +211,12 @@ function getSeriesElements(plotArea, chartType) {
|
|
|
208
211
|
"areaChart.ser",
|
|
209
212
|
"c:area3DChart.c:ser",
|
|
210
213
|
"area3DChart.ser",
|
|
214
|
+
// Surface / contour charts degrade to area (sourceChartType
|
|
215
|
+
// SURFACE / SURFACE_3D); their series carry the same cat/val shape.
|
|
216
|
+
"c:surfaceChart.c:ser",
|
|
217
|
+
"surfaceChart.ser",
|
|
218
|
+
"c:surface3DChart.c:ser",
|
|
219
|
+
"surface3DChart.ser",
|
|
211
220
|
]);
|
|
212
221
|
case "radar":
|
|
213
222
|
return getWithFallback(plotArea, ["c:radarChart.c:ser", "radarChart.ser"]);
|
|
@@ -552,6 +561,12 @@ export function determineChartType(chart) {
|
|
|
552
561
|
"areaChart",
|
|
553
562
|
"c:area3DChart",
|
|
554
563
|
"area3DChart",
|
|
564
|
+
// Surface / contour degrade to area — the same 2-D base the Rust
|
|
565
|
+
// importer and the renderer's surface pipeline use.
|
|
566
|
+
"c:surfaceChart",
|
|
567
|
+
"surfaceChart",
|
|
568
|
+
"c:surface3DChart",
|
|
569
|
+
"surface3DChart",
|
|
555
570
|
]))
|
|
556
571
|
return "area";
|
|
557
572
|
if (getWithFallback(plotArea, ["c:radarChart", "radarChart"]))
|
|
@@ -566,6 +581,31 @@ export function determineChartType(chart) {
|
|
|
566
581
|
return "bubble";
|
|
567
582
|
return "column"; // default
|
|
568
583
|
}
|
|
584
|
+
/**
|
|
585
|
+
* The authored 3-D / surface chart class, when the plot area's chart
|
|
586
|
+
* element is one of Excel's 3-D variants. These degrade to their 2-D
|
|
587
|
+
* `chartType` (bar3DChart → bar/column, line3DChart → line, pie3DChart →
|
|
588
|
+
* pie, area3DChart / surfaceChart / surface3DChart → area) and the
|
|
589
|
+
* original class is preserved verbatim as `sourceChartType`, matching the
|
|
590
|
+
* Rust importer, so the renderer's echarts-gl pipeline and the exporter's
|
|
591
|
+
* 3-D writer can restore it. Undefined for plain 2-D charts.
|
|
592
|
+
*/
|
|
593
|
+
export function extractThreeDSourceChartType(plotArea) {
|
|
594
|
+
var has = function (paths) { return Boolean(getWithFallback(plotArea, paths)); };
|
|
595
|
+
if (has(["c:bar3DChart", "bar3DChart"]))
|
|
596
|
+
return "BAR_3D";
|
|
597
|
+
if (has(["c:line3DChart", "line3DChart"]))
|
|
598
|
+
return "LINE_3D";
|
|
599
|
+
if (has(["c:pie3DChart", "pie3DChart"]))
|
|
600
|
+
return "PIE_3D";
|
|
601
|
+
if (has(["c:area3DChart", "area3DChart"]))
|
|
602
|
+
return "AREA_3D";
|
|
603
|
+
if (has(["c:surface3DChart", "surface3DChart"]))
|
|
604
|
+
return "SURFACE_3D";
|
|
605
|
+
if (has(["c:surfaceChart", "surfaceChart"]))
|
|
606
|
+
return "SURFACE";
|
|
607
|
+
return undefined;
|
|
608
|
+
}
|
|
569
609
|
/**
|
|
570
610
|
* Phase 5.5 — detect the c15 extension marker our exporter writes on
|
|
571
611
|
* the plotArea. Returns the originating chart type (histogram /
|
|
@@ -744,7 +784,16 @@ var CHART_TYPE_CONTAINERS = [
|
|
|
744
784
|
chartType: "line",
|
|
745
785
|
},
|
|
746
786
|
{
|
|
747
|
-
paths: [
|
|
787
|
+
paths: [
|
|
788
|
+
"c:areaChart",
|
|
789
|
+
"areaChart",
|
|
790
|
+
"c:area3DChart",
|
|
791
|
+
"area3DChart",
|
|
792
|
+
"c:surfaceChart",
|
|
793
|
+
"surfaceChart",
|
|
794
|
+
"c:surface3DChart",
|
|
795
|
+
"surface3DChart",
|
|
796
|
+
],
|
|
748
797
|
chartType: "area",
|
|
749
798
|
},
|
|
750
799
|
{
|
|
@@ -1896,13 +1945,23 @@ function extractDataLabelsOptions(plotArea, chartType) {
|
|
|
1896
1945
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1897
1946
|
// Look for <c:dLbls> inside the chartType-specific container. We pick
|
|
1898
1947
|
// the first one we find — chart-level labels apply to all series.
|
|
1948
|
+
// The 3-D classes (bar3DChart / line3DChart / pie3DChart / area3DChart)
|
|
1949
|
+
// degrade to the same `chartType` and carry `<c:dLbls>` in the same slot
|
|
1950
|
+
// of their group, so they are looked up alongside the 2-D container.
|
|
1899
1951
|
var containerKeys = {
|
|
1900
|
-
bar: ["c:barChart", "barChart"],
|
|
1901
|
-
column: ["c:barChart", "barChart"],
|
|
1902
|
-
line: ["c:lineChart", "lineChart"],
|
|
1903
|
-
pie: [
|
|
1952
|
+
bar: ["c:barChart", "barChart", "c:bar3DChart", "bar3DChart"],
|
|
1953
|
+
column: ["c:barChart", "barChart", "c:bar3DChart", "bar3DChart"],
|
|
1954
|
+
line: ["c:lineChart", "lineChart", "c:line3DChart", "line3DChart"],
|
|
1955
|
+
pie: [
|
|
1956
|
+
"c:pieChart",
|
|
1957
|
+
"pieChart",
|
|
1958
|
+
"c:ofPieChart",
|
|
1959
|
+
"ofPieChart",
|
|
1960
|
+
"c:pie3DChart",
|
|
1961
|
+
"pie3DChart",
|
|
1962
|
+
],
|
|
1904
1963
|
doughnut: ["c:doughnutChart", "doughnutChart"],
|
|
1905
|
-
area: ["c:areaChart", "areaChart"],
|
|
1964
|
+
area: ["c:areaChart", "areaChart", "c:area3DChart", "area3DChart"],
|
|
1906
1965
|
};
|
|
1907
1966
|
var keys = (_b = containerKeys[chartType]) !== null && _b !== void 0 ? _b : [];
|
|
1908
1967
|
var container;
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
import type { EmbeddedObject, EmbedShapeSpec } from "@rowsncolumns/spreadsheet";
|
|
1
|
+
import type { EmbeddedObject, EmbedImageSpec, EmbedShapeSpec } from "@rowsncolumns/spreadsheet";
|
|
2
2
|
import { type XMLParser } from "fast-xml-parser";
|
|
3
3
|
import { type StreamingZipParser } from "../../zip-parser-streaming";
|
|
4
4
|
export type EmbeddedObjectWithPosition = EmbeddedObject & {
|
|
5
5
|
isInsideCell?: boolean;
|
|
6
6
|
};
|
|
7
|
+
/** `processAnchors` anchor-type tags, keyed by the drawing element name. */
|
|
8
|
+
declare const ANCHOR_KIND_BY_ELEMENT: {
|
|
9
|
+
readonly oneCellAnchor: "oneCellAnchor";
|
|
10
|
+
readonly twoCellAnchor: "twoCellAnchors";
|
|
11
|
+
readonly absoluteAnchor: "absoluteAnchors";
|
|
12
|
+
};
|
|
13
|
+
type AnchorElementName = keyof typeof ANCHOR_KIND_BY_ELEMENT;
|
|
14
|
+
/**
|
|
15
|
+
* The `<xdr:wsDr>` anchors in document order — Excel's z-order (first is
|
|
16
|
+
* the back-most object). The unordered parse keeps document order within one
|
|
17
|
+
* element name but groups the three anchor kinds apart, so the kind sequence
|
|
18
|
+
* is read off the raw part and the parsed nodes are dealt out in that order.
|
|
19
|
+
* Anchors the scan does not account for (namespace quirks) trail in their
|
|
20
|
+
* parsed order, so nothing is ever dropped.
|
|
21
|
+
*/
|
|
22
|
+
export declare function anchorsInDocumentOrder(drawing: any, drawingXml: string): Array<{
|
|
23
|
+
kind: (typeof ANCHOR_KIND_BY_ELEMENT)[AnchorElementName];
|
|
24
|
+
node: any;
|
|
25
|
+
}>;
|
|
7
26
|
/**
|
|
8
27
|
* Process different types of image anchors
|
|
9
28
|
* @param anchors The anchor elements from the drawing
|
|
@@ -15,6 +34,13 @@ export type EmbeddedObjectWithPosition = EmbeddedObject & {
|
|
|
15
34
|
* @returns An array of image objects with their properties and binary data
|
|
16
35
|
*/
|
|
17
36
|
export declare function processAnchors(anchors: any, anchorType: string, drawingPath: string, sheetId: number, zipParser: StreamingZipParser, xmlParser: XMLParser): Promise<EmbeddedObjectWithPosition[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Picture-format adjustments off an `<xdr:pic>`: `<a:blipFill><a:srcRect>`
|
|
39
|
+
* (crop), `<a:blip><a:lum bright contrast>` (brightness / contrast) and
|
|
40
|
+
* `<a:blip><a:alphaModFix amt>` (opacity → `transparency`). Only present
|
|
41
|
+
* values are returned so an untouched picture stays a bare image spec.
|
|
42
|
+
*/
|
|
43
|
+
export declare function parsePictureAdjustments(picture: any): Pick<EmbedImageSpec, "crop" | "brightness" | "contrast" | "transparency">;
|
|
18
44
|
/**
|
|
19
45
|
* Whether an `<xdr:sp>` should import as a drawing shape (`EmbedShapeSpec`)
|
|
20
46
|
* rather than a textbox. Text boxes are excluded explicitly (`txBox="1"`), and
|
|
@@ -36,4 +62,5 @@ export declare function parseShapeSpec(shape: any): EmbedShapeSpec;
|
|
|
36
62
|
* @returns Boolean indicating if the image is inside a cell
|
|
37
63
|
*/
|
|
38
64
|
export declare function determineIfOneCellInsideCell(fromColOff: number, fromRowOff: number, fLocksWithSheet: string, cx: number, cy: number): boolean;
|
|
65
|
+
export {};
|
|
39
66
|
//# sourceMappingURL=drawing.d.ts.map
|