@rowsncolumns/toolkit 24.5.3 → 24.5.5
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.js +6 -2
- 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 +70 -16
- package/dist/cjs/excel-parser/interface.d.ts +9 -1
- package/dist/cjs/excel-parser/interface.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/conditional-formatting.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/conditional-formatting.js +61 -6
- package/dist/cjs/excel-parser/plugins/xlsx/data-validations.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/data-validations.js +13 -2
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +8 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/index.js +159 -26
- package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts +17 -2
- package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
- package/dist/cjs/excel-parser/plugins/xlsx/styles.js +25 -14
- package/dist/cjs/excel-parser/types.d.ts +5 -1
- package/dist/cjs/excel-parser/types.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.d.ts +1 -0
- package/dist/cjs/excel-parser/workbook.d.ts.map +1 -1
- package/dist/cjs/excel-parser/workbook.js +4 -0
- package/dist/cjs/excel-parser/worker.js +3 -0
- package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/chart-builder.js +167 -53
- package/dist/cjs/exporter/xlsx/future-functions.d.ts +6 -7
- package/dist/cjs/exporter/xlsx/future-functions.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/future-functions.js +5 -261
- package/dist/cjs/exporter/xlsx/style-builder.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/style-builder.js +62 -19
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts +10 -2
- package/dist/cjs/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/cjs/exporter/xlsx/xlsx-export.js +409 -160
- package/dist/cjs/helpers/excel-formula-prefixes.d.ts +51 -0
- package/dist/cjs/helpers/excel-formula-prefixes.d.ts.map +1 -0
- package/dist/cjs/helpers/excel-formula-prefixes.js +548 -0
- package/dist/cjs/helpers.d.ts +2 -0
- package/dist/cjs/helpers.d.ts.map +1 -1
- package/dist/cjs/helpers.js +21 -12
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/autofilter-condition.js +6 -2
- 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 +65 -3
- package/dist/esm/excel-parser/interface.d.ts +9 -1
- package/dist/esm/excel-parser/interface.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/conditional-formatting.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/conditional-formatting.js +42 -1
- package/dist/esm/excel-parser/plugins/xlsx/data-validations.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/data-validations.js +11 -2
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +8 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/index.js +109 -4
- package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts +17 -2
- package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts.map +1 -1
- package/dist/esm/excel-parser/plugins/xlsx/styles.js +20 -8
- package/dist/esm/excel-parser/types.d.ts +5 -1
- package/dist/esm/excel-parser/types.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.d.ts +1 -0
- package/dist/esm/excel-parser/workbook.d.ts.map +1 -1
- package/dist/esm/excel-parser/workbook.js +3 -0
- package/dist/esm/excel-parser/worker.js +3 -0
- package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/chart-builder.js +80 -0
- package/dist/esm/exporter/xlsx/future-functions.d.ts +6 -7
- package/dist/esm/exporter/xlsx/future-functions.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/future-functions.js +5 -261
- package/dist/esm/exporter/xlsx/style-builder.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/style-builder.js +56 -18
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts +10 -2
- package/dist/esm/exporter/xlsx/xlsx-export.d.ts.map +1 -1
- package/dist/esm/exporter/xlsx/xlsx-export.js +343 -108
- package/dist/esm/helpers/excel-formula-prefixes.d.ts +51 -0
- package/dist/esm/helpers/excel-formula-prefixes.d.ts.map +1 -0
- package/dist/esm/helpers/excel-formula-prefixes.js +531 -0
- package/dist/esm/helpers.d.ts +2 -0
- package/dist/esm/helpers.d.ts.map +1 -1
- package/dist/esm/helpers.js +23 -12
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../autofilter-condition.ts","../../csv-export.ts","../../csv-import-worker.ts","../../csv-import.ts","../../excel-export.ts","../../excel-import-session.ts","../../excel-import-worker.ts","../../helpers.ts","../../index.ts","../../indexed-colors.ts","../../ods-export.ts","../../parse.ts","../../power-query.ts","../../print-settings.ts","../../server.ts","../../theme1.ts","../../types.ts","../../vitest.config.ts","../../xlsx.d.ts","../../csv-parser/helpers.ts","../../csv-parser/types.ts","../../csv-parser/worker.ts","../../excel-parser/builtin-numfmts.ts","../../excel-parser/cfb-decryptor.ts","../../excel-parser/cfb-encryptor.ts","../../excel-parser/dv-cell-stamp.ts","../../excel-parser/helpers.ts","../../excel-parser/interface.ts","../../excel-parser/registry.ts","../../excel-parser/style-registry.ts","../../excel-parser/theme-default.ts","../../excel-parser/types.ts","../../excel-parser/utils.ts","../../excel-parser/workbook.ts","../../excel-parser/worker.ts","../../excel-parser/zip-parser-streaming.ts","../../excel-parser/zip-parser.ts","../../excel-parser/plugins/base/index.ts","../../excel-parser/plugins/ods/conditional-formatting.ts","../../excel-parser/plugins/ods/data-validations.ts","../../excel-parser/plugins/ods/formula.ts","../../excel-parser/plugins/ods/index.ts","../../excel-parser/plugins/ods/sparklines.ts","../../excel-parser/plugins/ods/styles.ts","../../excel-parser/plugins/ods/types.ts","../../excel-parser/plugins/xls/index.ts","../../excel-parser/plugins/xlsb/biff-record-reader.ts","../../excel-parser/plugins/xlsb/index.ts","../../excel-parser/plugins/xlsb/rgce-parser.ts","../../excel-parser/plugins/xlsm/index.ts","../../excel-parser/plugins/xlsx/chartex.ts","../../excel-parser/plugins/xlsx/charts.ts","../../excel-parser/plugins/xlsx/conditional-formatting.ts","../../excel-parser/plugins/xlsx/data-validations.ts","../../excel-parser/plugins/xlsx/drawing.ts","../../excel-parser/plugins/xlsx/form-controls.ts","../../excel-parser/plugins/xlsx/index.ts","../../excel-parser/plugins/xlsx/numfmt.ts","../../excel-parser/plugins/xlsx/pivots.ts","../../excel-parser/plugins/xlsx/relationships.ts","../../excel-parser/plugins/xlsx/sheet-views.ts","../../excel-parser/plugins/xlsx/styles.ts","../../excel-parser/plugins/xlsx/theme.ts","../../excel-parser/plugins/xlsx/threaded-comments.ts","../../excel-parser/plugins/xlsx/value-type-detection.ts","../../exporter/invalid-data-validation.ts","../../exporter/ods/ods-export.ts","../../exporter/ods/sparkline-builder.ts","../../exporter/xlsx/chart-builder.ts","../../exporter/xlsx/chart-templates.ts","../../exporter/xlsx/chartex-builder.ts","../../exporter/xlsx/form-controls-builder.ts","../../exporter/xlsx/future-functions.ts","../../exporter/xlsx/pivot-builder.ts","../../exporter/xlsx/power-query-builder.ts","../../exporter/xlsx/slicer-builder.ts","../../exporter/xlsx/sparkline-builder.ts","../../exporter/xlsx/style-builder.ts","../../exporter/xlsx/threaded-comments-builder.ts","../../exporter/xlsx/xlsx-export.ts","../../helpers/implicit-intersection.ts","../../helpers/theme-xml-generator.ts"],"version":"5.8.3"}
|
|
1
|
+
{"root":["../../autofilter-condition.ts","../../csv-export.ts","../../csv-import-worker.ts","../../csv-import.ts","../../excel-export.ts","../../excel-import-session.ts","../../excel-import-worker.ts","../../helpers.ts","../../index.ts","../../indexed-colors.ts","../../ods-export.ts","../../parse.ts","../../power-query.ts","../../print-settings.ts","../../server.ts","../../theme1.ts","../../types.ts","../../vitest.config.ts","../../xlsx.d.ts","../../csv-parser/helpers.ts","../../csv-parser/types.ts","../../csv-parser/worker.ts","../../excel-parser/builtin-numfmts.ts","../../excel-parser/cfb-decryptor.ts","../../excel-parser/cfb-encryptor.ts","../../excel-parser/dv-cell-stamp.ts","../../excel-parser/helpers.ts","../../excel-parser/interface.ts","../../excel-parser/registry.ts","../../excel-parser/style-registry.ts","../../excel-parser/theme-default.ts","../../excel-parser/types.ts","../../excel-parser/utils.ts","../../excel-parser/workbook.ts","../../excel-parser/worker.ts","../../excel-parser/zip-parser-streaming.ts","../../excel-parser/zip-parser.ts","../../excel-parser/plugins/base/index.ts","../../excel-parser/plugins/ods/conditional-formatting.ts","../../excel-parser/plugins/ods/data-validations.ts","../../excel-parser/plugins/ods/formula.ts","../../excel-parser/plugins/ods/index.ts","../../excel-parser/plugins/ods/sparklines.ts","../../excel-parser/plugins/ods/styles.ts","../../excel-parser/plugins/ods/types.ts","../../excel-parser/plugins/xls/index.ts","../../excel-parser/plugins/xlsb/biff-record-reader.ts","../../excel-parser/plugins/xlsb/index.ts","../../excel-parser/plugins/xlsb/rgce-parser.ts","../../excel-parser/plugins/xlsm/index.ts","../../excel-parser/plugins/xlsx/chartex.ts","../../excel-parser/plugins/xlsx/charts.ts","../../excel-parser/plugins/xlsx/conditional-formatting.ts","../../excel-parser/plugins/xlsx/data-validations.ts","../../excel-parser/plugins/xlsx/drawing.ts","../../excel-parser/plugins/xlsx/form-controls.ts","../../excel-parser/plugins/xlsx/index.ts","../../excel-parser/plugins/xlsx/numfmt.ts","../../excel-parser/plugins/xlsx/pivots.ts","../../excel-parser/plugins/xlsx/relationships.ts","../../excel-parser/plugins/xlsx/sheet-views.ts","../../excel-parser/plugins/xlsx/styles.ts","../../excel-parser/plugins/xlsx/theme.ts","../../excel-parser/plugins/xlsx/threaded-comments.ts","../../excel-parser/plugins/xlsx/value-type-detection.ts","../../exporter/invalid-data-validation.ts","../../exporter/ods/ods-export.ts","../../exporter/ods/sparkline-builder.ts","../../exporter/xlsx/chart-builder.ts","../../exporter/xlsx/chart-templates.ts","../../exporter/xlsx/chartex-builder.ts","../../exporter/xlsx/form-controls-builder.ts","../../exporter/xlsx/future-functions.ts","../../exporter/xlsx/pivot-builder.ts","../../exporter/xlsx/power-query-builder.ts","../../exporter/xlsx/slicer-builder.ts","../../exporter/xlsx/sparkline-builder.ts","../../exporter/xlsx/style-builder.ts","../../exporter/xlsx/threaded-comments-builder.ts","../../exporter/xlsx/xlsx-export.ts","../../helpers/excel-formula-prefixes.ts","../../helpers/implicit-intersection.ts","../../helpers/theme-xml-generator.ts"],"version":"5.8.3"}
|
|
@@ -233,6 +233,10 @@ const singleCustomFilterToCondition = (filter) => {
|
|
|
233
233
|
const operator = filter.operator ?? "equal";
|
|
234
234
|
const val = String(filter.val ?? "");
|
|
235
235
|
// Text wildcards: equal/notEqual carrying * map back to contains/starts/ends.
|
|
236
|
+
// A NEGATED begins-with / ends-with (`notEqual` + `x*` / `*x`, Excel's "does
|
|
237
|
+
// not begin / end with") has no condition type of its own — it falls through
|
|
238
|
+
// to TEXT_NOT_EQ with the wildcard value verbatim, so the export writes
|
|
239
|
+
// `notEqual` + `x*` back unchanged instead of flipping it to `equal`.
|
|
236
240
|
if ((operator === "equal" || operator === "notEqual") && /[*?]/.test(val)) {
|
|
237
241
|
const negated = operator === "notEqual";
|
|
238
242
|
const lead = val.startsWith("*");
|
|
@@ -244,10 +248,10 @@ const singleCustomFilterToCondition = (filter) => {
|
|
|
244
248
|
values: [{ userEnteredValue: core }],
|
|
245
249
|
};
|
|
246
250
|
}
|
|
247
|
-
if (trail) {
|
|
251
|
+
if (trail && !negated) {
|
|
248
252
|
return { type: "TEXT_STARTS_WITH", values: [{ userEnteredValue: core }] };
|
|
249
253
|
}
|
|
250
|
-
if (lead) {
|
|
254
|
+
if (lead && !negated) {
|
|
251
255
|
return { type: "TEXT_ENDS_WITH", values: [{ userEnteredValue: core }] };
|
|
252
256
|
}
|
|
253
257
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { GridRange } from "@rowsncolumns/common-types";
|
|
2
|
-
import type { Column, FilterSpec, SortSpecs, TableTotalsRowFunction } from "@rowsncolumns/spreadsheet";
|
|
2
|
+
import type { Column, DateGroupFilter, FilterSpec, SortSpecs, TableTotalsRowFunction } from "@rowsncolumns/spreadsheet";
|
|
3
|
+
/** The engine's "(Blanks)" checklist entry — Excel's `<filters blank="1">`. */
|
|
4
|
+
export declare const BLANK_LABEL = "(Blanks)";
|
|
3
5
|
export declare const getRangeFromAddressRef: (ref: string) => GridRange | undefined;
|
|
4
6
|
/**
|
|
5
7
|
* OOXML `<col width>` (and `<sheetFormatPr defaultColWidth>`) → pixels.
|
|
@@ -24,6 +26,12 @@ export declare const isTableTotalsRowFunction: (value: unknown) => value is Tabl
|
|
|
24
26
|
* present so columns without a totals row stay `{ name }`.
|
|
25
27
|
*/
|
|
26
28
|
export declare const parseTableColumnTotals: (colDef: any) => Pick<Column, "totalsRowFunction" | "totalsRowLabel" | "totalsRowFormula">;
|
|
29
|
+
/**
|
|
30
|
+
* A `<dateGroupItem>`'s attributes → the criteria's date-group entry, or
|
|
31
|
+
* `undefined` without a year. `dateTimeGrouping` defaults to `day` like the
|
|
32
|
+
* schema.
|
|
33
|
+
*/
|
|
34
|
+
export declare function dateGroupFilterFromAttributes(attrs: Record<string, unknown> | undefined): DateGroupFilter | undefined;
|
|
27
35
|
export declare function createFilterSpecsFromAutoFilter(autoFilter: any,
|
|
28
36
|
/**
|
|
29
37
|
* Optional dxf resolver — called with (dxfId, cellColor) to return a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../excel-parser/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAEV,MAAM,EACN,UAAU,EACV,SAAS,EACT,sBAAsB,EACvB,MAAM,2BAA2B,CAAC;AAUnC,eAAO,MAAM,sBAAsB,GAAI,KAAK,MAAM,KAAG,SAAS,GAAG,SAIhE,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,UAMrD;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,UAMpC;AAmBD,eAAO,MAAM,wBAAwB,GACnC,OAAO,OAAO,KACb,KAAK,IAAI,sBACwD,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,GAAG,KACV,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,kBAAkB,CAmB1E,CAAC;AAqBF,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,GAAG;AACf;;;;GAIG;AACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../excel-parser/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAEV,MAAM,EACN,eAAe,EACf,UAAU,EACV,SAAS,EACT,sBAAsB,EACvB,MAAM,2BAA2B,CAAC;AAUnC,+EAA+E;AAC/E,eAAO,MAAM,WAAW,aAAa,CAAC;AAEtC,eAAO,MAAM,sBAAsB,GAAI,KAAK,MAAM,KAAG,SAAS,GAAG,SAIhE,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,UAMrD;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,UAMpC;AAmBD,eAAO,MAAM,wBAAwB,GACnC,OAAO,OAAO,KACb,KAAK,IAAI,sBACwD,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,GAAG,KACV,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,kBAAkB,CAmB1E,CAAC;AAqBF;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACzC,eAAe,GAAG,SAAS,CA8B7B;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,GAAG;AACf;;;;GAIG;AACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,gBAgI5E;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAgBtE;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,GAAG,EACd,KAAK,EAAE,SAAS,EAChB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,GAC1E,SAAS,EAAE,CA2Cb;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,wBAkB3D"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { customFiltersToCriteria, dynamicFilterToCondition, top10FilterToCondition, } from "../autofilter-condition";
|
|
2
2
|
import { addressToSelection } from "@rowsncolumns/utils";
|
|
3
|
+
/** The engine's "(Blanks)" checklist entry — Excel's `<filters blank="1">`. */
|
|
4
|
+
export const BLANK_LABEL = "(Blanks)";
|
|
3
5
|
export const getRangeFromAddressRef = (ref) => {
|
|
4
6
|
const selection = addressToSelection(ref);
|
|
5
7
|
if (!selection)
|
|
@@ -85,6 +87,44 @@ const getNodeText = (node) => {
|
|
|
85
87
|
}
|
|
86
88
|
return String(node);
|
|
87
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* A `<dateGroupItem>`'s attributes → the criteria's date-group entry, or
|
|
92
|
+
* `undefined` without a year. `dateTimeGrouping` defaults to `day` like the
|
|
93
|
+
* schema.
|
|
94
|
+
*/
|
|
95
|
+
export function dateGroupFilterFromAttributes(attrs) {
|
|
96
|
+
if (!attrs)
|
|
97
|
+
return undefined;
|
|
98
|
+
const int = (name) => {
|
|
99
|
+
const raw = attrs[name];
|
|
100
|
+
if (raw === undefined || raw === null || raw === "")
|
|
101
|
+
return undefined;
|
|
102
|
+
const n = parseInt(String(raw), 10);
|
|
103
|
+
return Number.isFinite(n) ? n : undefined;
|
|
104
|
+
};
|
|
105
|
+
const year = int("year");
|
|
106
|
+
if (year === undefined)
|
|
107
|
+
return undefined;
|
|
108
|
+
const grouping = attrs.dateTimeGrouping;
|
|
109
|
+
const dateTimeGrouping = typeof grouping === "string" &&
|
|
110
|
+
["year", "month", "day", "hour", "minute", "second"].includes(grouping)
|
|
111
|
+
? grouping
|
|
112
|
+
: "day";
|
|
113
|
+
const month = int("month");
|
|
114
|
+
const day = int("day");
|
|
115
|
+
const hour = int("hour");
|
|
116
|
+
const minute = int("minute");
|
|
117
|
+
const second = int("second");
|
|
118
|
+
return {
|
|
119
|
+
year,
|
|
120
|
+
...(month !== undefined ? { month } : {}),
|
|
121
|
+
...(day !== undefined ? { day } : {}),
|
|
122
|
+
...(hour !== undefined ? { hour } : {}),
|
|
123
|
+
...(minute !== undefined ? { minute } : {}),
|
|
124
|
+
...(second !== undefined ? { second } : {}),
|
|
125
|
+
dateTimeGrouping,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
88
128
|
export function createFilterSpecsFromAutoFilter(autoFilter,
|
|
89
129
|
/**
|
|
90
130
|
* Optional dxf resolver — called with (dxfId, cellColor) to return a
|
|
@@ -107,9 +147,31 @@ resolveDxfColor) {
|
|
|
107
147
|
// <filters><filter val=…/></filters>
|
|
108
148
|
const filtersObj = col.filters ?? col["x:filters"];
|
|
109
149
|
const filter = filtersObj?.filter ?? filtersObj?.["x:filter"];
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
150
|
+
const filtersAttrs = filtersObj?.a$ ?? filtersObj;
|
|
151
|
+
// `<filters blank="1">` — the checked "(Blanks)" entry is an attribute in
|
|
152
|
+
// Excel, never a `<filter val>`.
|
|
153
|
+
const showBlanks = filtersAttrs?.blank === "1" || filtersAttrs?.blank === "true";
|
|
154
|
+
if (filter || showBlanks) {
|
|
155
|
+
const filterArray = filter
|
|
156
|
+
? Array.isArray(filter)
|
|
157
|
+
? filter
|
|
158
|
+
: [filter]
|
|
159
|
+
: [];
|
|
160
|
+
const values = filterArray.map((f) => String(f.a$.val));
|
|
161
|
+
if (showBlanks)
|
|
162
|
+
values.push(BLANK_LABEL);
|
|
163
|
+
criteria.visibleValues = values;
|
|
164
|
+
}
|
|
165
|
+
// <filters><dateGroupItem year month day … dateTimeGrouping/></filters> —
|
|
166
|
+
// Excel's date-grouped checklist entries.
|
|
167
|
+
const dateGroupItem = filtersObj?.dateGroupItem ?? filtersObj?.["x:dateGroupItem"];
|
|
168
|
+
if (dateGroupItem) {
|
|
169
|
+
const items = Array.isArray(dateGroupItem) ? dateGroupItem : [dateGroupItem];
|
|
170
|
+
const dateGroups = items
|
|
171
|
+
.map((item) => dateGroupFilterFromAttributes(item?.a$ ?? item))
|
|
172
|
+
.filter((group) => group !== undefined);
|
|
173
|
+
if (dateGroups.length)
|
|
174
|
+
criteria.dateGroups = dateGroups;
|
|
113
175
|
}
|
|
114
176
|
// <colorFilter dxfId="…" cellColor="1|0"/>
|
|
115
177
|
const colorFilterNode = col.colorFilter ?? col["x:colorFilter"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConditionalFormatRule, DataValidationRuleRecord, EmbeddedChart, NamedRange, ProtectedRange, Sheet, Slicer, SpreadsheetTheme, TableView, CustomTableStyle } from "@rowsncolumns/spreadsheet";
|
|
1
|
+
import type { ConditionalFormatRule, DataValidationRuleRecord, EmbeddedChart, NamedRange, ProtectedRange, Sheet, Slicer, SpreadsheetTheme, TableView, CustomTableStyle, WorkbookProtection } from "@rowsncolumns/spreadsheet";
|
|
2
2
|
import type { CommentThread, IterativeCalculationOptions, NamedCellStyle, TextFormat, TextFormatRun } from "@rowsncolumns/common-types";
|
|
3
3
|
import type { EmbeddedObjectWithPosition, ExternalLink, ProcessSheetDataForSheetOptions, ProcessSheetDataResult, SheetCatalogEntry, WorkbookProperties } from "./types";
|
|
4
4
|
export interface IWorkbookPlugin {
|
|
@@ -97,6 +97,14 @@ export interface IWorkbookPlugin {
|
|
|
97
97
|
* Get iterative calculation settings if present in the workbook.
|
|
98
98
|
*/
|
|
99
99
|
getIterativeCalculationOptions(): IterativeCalculationOptions | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Workbook-level protection (`<workbookProtection>` in `xl/workbook.xml` —
|
|
102
|
+
* Excel's "Protect Workbook" structure / windows / revision locks with the
|
|
103
|
+
* source's password hash), or `undefined` when the workbook is unprotected.
|
|
104
|
+
* Optional so plugins without workbook protection still satisfy the
|
|
105
|
+
* interface; the workbook wrapper resolves to `undefined`.
|
|
106
|
+
*/
|
|
107
|
+
getWorkbookProtection?(): WorkbookProtection | undefined;
|
|
100
108
|
/**
|
|
101
109
|
* Whether the workbook uses the 1904 date epoch (`<workbookPr date1904="1"/>`).
|
|
102
110
|
* Date serials in a 1904-anchored workbook are shifted by 1462 days.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../excel-parser/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,cAAc,EACd,KAAK,EACL,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,gBAAgB,
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../excel-parser/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,cAAc,EACd,KAAK,EACL,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,aAAa,EACb,2BAA2B,EAC3B,cAAc,EACd,UAAU,EACV,aAAa,EACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,0BAA0B,EAC1B,YAAY,EACZ,+BAA+B,EAC/B,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnE;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;IAEhB;;OAEG;IACH,aAAa,IAAI,MAAM,CAAC;IAExB;;OAEG;IACH,SAAS,CACP,WAAW,CAAC,EAAE,MAAM,EACpB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAEnC;;;;OAIG;IAEH;;;;;OAKG;IACH,eAAe,CAAC,IAAI,iBAAiB,EAAE,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAEvE;;;OAGG;IACH,QAAQ,CAAC,CACP,OAAO,EA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AC;IAEhC;;;;;OAKG;IACH,cAAc,CAAC,IAAI,OAAO,CAAC,OAAO,2BAA2B,EAAE,UAAU,EAAE,CAAC,CAAC;IAE7E;;;;;OAKG;IACH,aAAa,CAAC,IAAI,OAAO,CAAC,OAAO,gBAAgB,EAAE,eAAe,GAAG,SAAS,CAAC,CAAC;IAEhF;;OAEG;IACH,gBAAgB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAE5C;;;OAGG;IACH,aAAa,CAAC,IAAI,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;CAC3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-formatting.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/conditional-formatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,
|
|
1
|
+
{"version":3,"file":"conditional-formatting.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/conditional-formatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAGhB,UAAU,EAGV,qBAAqB,EAGrB,YAAY,EAKZ,aAAa,EACd,MAAM,2BAA2B,CAAC;AA6NnC,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,UAAU,GACjB,aAAa,GAAG,SAAS,CAuC3B;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,UAAU,GACjB,YAAY,CAKd;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,GAAG,GACV,gBAAgB,GAAG,SAAS,CAgI9B;AA8KD;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,GAAG,EACd,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,GAAG,EACnB,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GACxC,qBAAqB,EAAE,CAsLzB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { get, set } from "lodash-es";
|
|
2
2
|
import { getRangeFromAddressRef } from "../../helpers";
|
|
3
|
-
import { extractColor } from "./styles";
|
|
3
|
+
import { extractColor, mapBorderStyle, mapBorderWidth, mapNumberFormatType, } from "./styles";
|
|
4
4
|
/**
|
|
5
5
|
* Parse cell format from dxf format definition. Theme color
|
|
6
6
|
* references (`<color theme="N" tint="T"/>`) are intentionally
|
|
@@ -57,6 +57,47 @@ function parseDxfFormat(dxf, indexedColors) {
|
|
|
57
57
|
if (dxf.fill && dxf.fill.patternFill && dxf.fill.patternFill.bgColor) {
|
|
58
58
|
format.backgroundColor = extractColor(dxf.fill.patternFill.bgColor, indexedColors);
|
|
59
59
|
}
|
|
60
|
+
// Border — a dxf carries its `<border>` inline (no borderId). Excel writes only
|
|
61
|
+
// the edges the rule sets; `style="none"` (or no style) is "no border here".
|
|
62
|
+
if (dxf.border) {
|
|
63
|
+
const borders = {};
|
|
64
|
+
const edgeToBorder = (edge) => {
|
|
65
|
+
const style = edge?.a$?.style;
|
|
66
|
+
if (!style || style === "none")
|
|
67
|
+
return undefined;
|
|
68
|
+
return {
|
|
69
|
+
style: mapBorderStyle(style),
|
|
70
|
+
width: mapBorderWidth(style),
|
|
71
|
+
color: edge.color ? extractColor(edge.color, indexedColors) : null,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
for (const side of ["top", "bottom", "left", "right"]) {
|
|
75
|
+
const border = edgeToBorder(dxf.border[side]);
|
|
76
|
+
if (border)
|
|
77
|
+
borders[side] = border;
|
|
78
|
+
}
|
|
79
|
+
const diagonal = edgeToBorder(dxf.border.diagonal);
|
|
80
|
+
if (diagonal) {
|
|
81
|
+
const isOn = (v) => v !== undefined && v !== "0" && v !== "false" && v !== false;
|
|
82
|
+
if (isOn(dxf.border.a$?.diagonalUp))
|
|
83
|
+
borders.diagonalUp = diagonal;
|
|
84
|
+
if (isOn(dxf.border.a$?.diagonalDown))
|
|
85
|
+
borders.diagonalDown = diagonal;
|
|
86
|
+
}
|
|
87
|
+
if (Object.keys(borders).length > 0) {
|
|
88
|
+
format.borders = borders;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Number format — inline `<numFmt numFmtId formatCode/>`; the code is authoritative
|
|
92
|
+
// (a dxf-only format need not appear in the workbook's `<numFmts>` table).
|
|
93
|
+
const formatCode = dxf.numFmt?.a$?.formatCode;
|
|
94
|
+
if (typeof formatCode === "string" && formatCode.length > 0) {
|
|
95
|
+
const numFmtId = parseInt(dxf.numFmt.a$?.numFmtId ?? "0", 10);
|
|
96
|
+
format.numberFormat = {
|
|
97
|
+
type: mapNumberFormatType(Number.isNaN(numFmtId) ? 0 : numFmtId, formatCode) ?? "GENERAL",
|
|
98
|
+
pattern: formatCode,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
60
101
|
return format;
|
|
61
102
|
}
|
|
62
103
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-validations.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/data-validations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,wBAAwB,EAEzB,MAAM,2BAA2B,CAAC;AASnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"data-validations.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/data-validations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,wBAAwB,EAEzB,MAAM,2BAA2B,CAAC;AASnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAoTvD,eAAO,MAAM,0BAA0B,GACrC,UAAU,eAAe,EACzB,SAAS,MAAM,EACf,YAAY,GAAG,EACf,YAAY,MAAM,+BAyRnB,CAAC"}
|
|
@@ -114,6 +114,15 @@ const mapErrorStyle = (style) => {
|
|
|
114
114
|
return "stop";
|
|
115
115
|
};
|
|
116
116
|
const NUMBER_VALIDATION_TYPES = new Set(["whole", "decimal", "time"]);
|
|
117
|
+
const NUMERIC_LITERAL_PATTERN = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
|
|
118
|
+
/**
|
|
119
|
+
* A `whole` / `decimal` / `date` / `time` bound is an OOXML formula — Excel
|
|
120
|
+
* writes `<formula1>$B$1</formula1>`, `TODAY()`, `DATE(2024,1,1)`, `LEN(A1)`,
|
|
121
|
+
* `MaxValue` with no leading `=`. Store it the way the rule editors and the
|
|
122
|
+
* expression builders read a formula operand (`=…`), keeping only a bare
|
|
123
|
+
* numeric literal (`10`, `0.5`, `45292`) as is.
|
|
124
|
+
*/
|
|
125
|
+
const toBoundOperand = (formula) => NUMERIC_LITERAL_PATTERN.test(formula) ? formula : `=${formula}`;
|
|
117
126
|
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
118
127
|
const parseListValues = (raw) => {
|
|
119
128
|
const trimmed = raw.trim();
|
|
@@ -473,8 +482,8 @@ export const getDataValidationsForSheet = (workbook, sheetId, sheet_data, sheetN
|
|
|
473
482
|
continue;
|
|
474
483
|
}
|
|
475
484
|
const values = [
|
|
476
|
-
{ userEnteredValue: formula1 },
|
|
477
|
-
...(formula2 ? [{ userEnteredValue: formula2 }] : []),
|
|
485
|
+
{ userEnteredValue: toBoundOperand(formula1) },
|
|
486
|
+
...(formula2 ? [{ userEnteredValue: toBoundOperand(formula2) }] : []),
|
|
478
487
|
];
|
|
479
488
|
dataValidations.push({
|
|
480
489
|
id: uuid(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CellFormat, ConditionalFormatRule, DataValidationRuleRecord, EmbeddedChart, EmbeddedObject, NamedRange, ProtectedRange, Sheet, Slicer, SpreadsheetTheme, TableView, CustomTableStyle } from "@rowsncolumns/spreadsheet";
|
|
1
|
+
import type { CellFormat, ConditionalFormatRule, DataValidationRuleRecord, EmbeddedChart, EmbeddedObject, NamedRange, ProtectedRange, Sheet, WorkbookProtection, Slicer, SpreadsheetTheme, TableView, CustomTableStyle } from "@rowsncolumns/spreadsheet";
|
|
2
2
|
import type { NamedCellStyle, CommentThread, TextFormat, TextFormatRun } from "@rowsncolumns/common-types";
|
|
3
3
|
import { XMLParser } from "fast-xml-parser";
|
|
4
4
|
import type { IWorkbookPlugin } from "../../interface";
|
|
@@ -125,6 +125,7 @@ export declare class XlsxPlugin extends BaseWorkbookPlugin implements IWorkbookP
|
|
|
125
125
|
private workSheets;
|
|
126
126
|
private calcPr;
|
|
127
127
|
private workbookPr;
|
|
128
|
+
private workbookProtectionXml;
|
|
128
129
|
private currentSheetTotalRows?;
|
|
129
130
|
/**
|
|
130
131
|
* Per-sheet feature presence recorded during the hyperlink SAX pass.
|
|
@@ -307,6 +308,12 @@ export declare class XlsxPlugin extends BaseWorkbookPlugin implements IWorkbookP
|
|
|
307
308
|
* 1904-anchored we treat it as 1900.
|
|
308
309
|
*/
|
|
309
310
|
getUse1904Epoch(): boolean;
|
|
311
|
+
/**
|
|
312
|
+
* `<workbookProtection …/>` → `WorkbookProtection`. The element's presence is
|
|
313
|
+
* what matters (Excel writes it only for a protected workbook); attributes
|
|
314
|
+
* are kept exactly as present so the exporter replays them verbatim.
|
|
315
|
+
*/
|
|
316
|
+
getWorkbookProtection(): WorkbookProtection | undefined;
|
|
310
317
|
getIterativeCalculationOptions(): IterativeCalculationOptions | undefined;
|
|
311
318
|
getSheetCount(): number;
|
|
312
319
|
getSheets(minRowCount?: number, minColumnCount?: number): Promise<[Sheet[], TableView[]]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,UAAU,EAEV,qBAAqB,EACrB,wBAAwB,EAExB,aAAa,EACb,cAAc,EAGd,UAAU,EAMV,cAAc,EACd,KAAK,EAEL,M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9B;;;;;;;OAOG;IACG,aAAa,IAAI,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAuHrD,wBAAwB,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAclE,gCAAgC,CAC9B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,qBAAqB,EAAE,CAAC;YASrB,kCAAkC;IAqB1C,kBAAkB,IAAI,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAc/D,0BAA0B,CACxB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,wBAAwB,EAAE,CAAC;YASxB,4BAA4B;IA2B1C;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE;IAOtD,cAAc;IAId;;;;;OAKG;IACG,aAAa,IAAI,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;IA0ExD,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YAIvB,qBAAqB;IAgWnC,OAAO,CAAC,qBAAqB;IAmH7B,OAAO,CAAC,YAAY;IAQpB;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAsHlD"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { addressToCell, addressToSelection, alpha2number, checkIfStringIsReference, findMatchingBandProperty, generateSelectionsFromFormula, getCellXfsKey, isAFormula, isBareFormulaExpression, isNil, uuid, } from "@rowsncolumns/utils";
|
|
2
|
+
import { normalizeImportedFormula } from "../../../helpers/excel-formula-prefixes";
|
|
2
3
|
import { XMLParser } from "fast-xml-parser";
|
|
3
4
|
import { get } from "lodash-es";
|
|
4
5
|
import { Parser as HtmlParser } from "htmlparser2";
|
|
5
|
-
import { createFilterSpecsFromAutoFilter, excelColumnWidthToPixels, findMax, createSortSpecsFromSortState, getRangeFromAddressRef, hiddenFilterButtonColumns, parseTableColumnTotals, } from "../../helpers";
|
|
6
|
+
import { BLANK_LABEL, createFilterSpecsFromAutoFilter, dateGroupFilterFromAttributes, excelColumnWidthToPixels, findMax, createSortSpecsFromSortState, getRangeFromAddressRef, hiddenFilterButtonColumns, parseTableColumnTotals, } from "../../helpers";
|
|
6
7
|
import { defaultSpreadsheetTheme } from "../../theme-default";
|
|
7
8
|
import { Unescape } from "../../utils";
|
|
8
9
|
import { compactPrintSettings, isBuiltinPrintName, isDefaultPageMargins, parsePrintAreaFormula, parsePrintTitlesFormula, PRINT_AREA_NAME, } from "../../../print-settings";
|
|
@@ -724,6 +725,7 @@ export class XlsxPlugin extends BaseWorkbookPlugin {
|
|
|
724
725
|
workSheets = [];
|
|
725
726
|
calcPr;
|
|
726
727
|
workbookPr;
|
|
728
|
+
workbookProtectionXml;
|
|
727
729
|
currentSheetTotalRows;
|
|
728
730
|
/**
|
|
729
731
|
* Per-sheet feature presence recorded during the hyperlink SAX pass.
|
|
@@ -1090,12 +1092,27 @@ export class XlsxPlugin extends BaseWorkbookPlugin {
|
|
|
1090
1092
|
const colId = parseInt(attrs.colId ?? "0", 10);
|
|
1091
1093
|
currentFilterColumn = Number.isNaN(colId) ? null : colId;
|
|
1092
1094
|
}
|
|
1095
|
+
// <filters blank="1"> — Excel writes the checked "(Blanks)" entry
|
|
1096
|
+
// as an attribute, never as a <filter val>.
|
|
1097
|
+
if (name === "filters" && currentFilterColumn !== null) {
|
|
1098
|
+
if (attrs.blank === "1" || attrs.blank === "true") {
|
|
1099
|
+
getOrCreateFilterColumn(currentFilterColumn).showBlanks = true;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1093
1102
|
if (name === "filter" && currentFilterColumn !== null) {
|
|
1094
1103
|
const val = attrs.val;
|
|
1095
1104
|
if (typeof val === "string") {
|
|
1096
1105
|
getOrCreateFilterColumn(currentFilterColumn).visibleValues.push(val);
|
|
1097
1106
|
}
|
|
1098
1107
|
}
|
|
1108
|
+
// <dateGroupItem year month day … dateTimeGrouping/> inside <filters>.
|
|
1109
|
+
if (name === "dateGroupItem" && currentFilterColumn !== null) {
|
|
1110
|
+
const group = dateGroupFilterFromAttributes(attrs);
|
|
1111
|
+
if (group) {
|
|
1112
|
+
const entry = getOrCreateFilterColumn(currentFilterColumn);
|
|
1113
|
+
(entry.dateGroups ??= []).push(group);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1099
1116
|
if (name === "colorFilter" && currentFilterColumn !== null) {
|
|
1100
1117
|
const entry = getOrCreateFilterColumn(currentFilterColumn);
|
|
1101
1118
|
const dxfIdRaw = attrs.dxfId;
|
|
@@ -1198,8 +1215,13 @@ export class XlsxPlugin extends BaseWorkbookPlugin {
|
|
|
1198
1215
|
}
|
|
1199
1216
|
const filterSpecs = Array.from(filterColumns.entries()).map(([columnIndex, raw]) => {
|
|
1200
1217
|
const criteria = {};
|
|
1201
|
-
if (raw.visibleValues.length) {
|
|
1202
|
-
criteria.visibleValues = raw.
|
|
1218
|
+
if (raw.visibleValues.length || raw.showBlanks) {
|
|
1219
|
+
criteria.visibleValues = raw.showBlanks
|
|
1220
|
+
? [...raw.visibleValues, BLANK_LABEL]
|
|
1221
|
+
: raw.visibleValues;
|
|
1222
|
+
}
|
|
1223
|
+
if (raw.dateGroups?.length) {
|
|
1224
|
+
criteria.dateGroups = raw.dateGroups;
|
|
1203
1225
|
}
|
|
1204
1226
|
if (raw.colorFilterDxfId !== undefined) {
|
|
1205
1227
|
const color = this.resolveDxfColor(raw.colorFilterDxfId, raw.colorFilterCellColor !== false);
|
|
@@ -1863,6 +1885,9 @@ export class XlsxPlugin extends BaseWorkbookPlugin {
|
|
|
1863
1885
|
this.workbookPr =
|
|
1864
1886
|
get(this.workbookXml, "workbook.workbookPr") ||
|
|
1865
1887
|
get(this.workbookXml, "x:workbook.x:workbookPr");
|
|
1888
|
+
this.workbookProtectionXml =
|
|
1889
|
+
get(this.workbookXml, "workbook.workbookProtection") ||
|
|
1890
|
+
get(this.workbookXml, "x:workbook.x:workbookProtection");
|
|
1866
1891
|
}
|
|
1867
1892
|
extractSheetsFromWorkbook(workbookXml) {
|
|
1868
1893
|
let workSheets = get(workbookXml, "workbook.sheets.sheet") ||
|
|
@@ -3228,10 +3253,32 @@ export class XlsxPlugin extends BaseWorkbookPlugin {
|
|
|
3228
3253
|
const defined_names = Array.isArray(definedName)
|
|
3229
3254
|
? definedName
|
|
3230
3255
|
: [definedName];
|
|
3256
|
+
const sheetElements = this._getSheets();
|
|
3257
|
+
// `localSheetId` indexes the `<sheets>` order; the model scopes a name by
|
|
3258
|
+
// the sheet's id (`scopeSheetId`) so renames and reorders don't move it.
|
|
3259
|
+
const scopeOf = (localSheetId) => {
|
|
3260
|
+
if (localSheetId === undefined || localSheetId === null)
|
|
3261
|
+
return {};
|
|
3262
|
+
const index = parseInt(String(localSheetId), 10);
|
|
3263
|
+
const sheetId = Number(sheetElements[index]?.a$?.sheetId);
|
|
3264
|
+
return Number.isFinite(sheetId) ? { scopeSheetId: sheetId } : {};
|
|
3265
|
+
};
|
|
3231
3266
|
for (const defined_name of defined_names) {
|
|
3232
3267
|
const name = defined_name.a$?.name;
|
|
3233
|
-
|
|
3268
|
+
// Defined names are stored with the same markers as cell formulas
|
|
3269
|
+
// (`_xlfn.LAMBDA(_xlpm.x,_xlpm.x*2)`); keep the displayed spelling.
|
|
3270
|
+
// The XML layer hands a numeric constant (`<definedName>0.2</definedName>`)
|
|
3271
|
+
// over as a number — keep every expression as text so a constant name
|
|
3272
|
+
// exports the way it was read.
|
|
3273
|
+
const rawExpression = defined_name.t$;
|
|
3274
|
+
const expressionText = rawExpression === undefined || rawExpression === null
|
|
3275
|
+
? ""
|
|
3276
|
+
: String(rawExpression);
|
|
3277
|
+
const expression = expressionText
|
|
3278
|
+
? normalizeImportedFormula(expressionText)
|
|
3279
|
+
: "";
|
|
3234
3280
|
const hidden = defined_name.a$.hidden === "1";
|
|
3281
|
+
const scope = scopeOf(defined_name.a$?.localSheetId);
|
|
3235
3282
|
// `_xlnm.Print_Area` / `_xlnm.Print_Titles` are sheet-scoped print
|
|
3236
3283
|
// facets, not user names: they land on `sheet.printSettings` (see
|
|
3237
3284
|
// `getSheets()`), never in `namedRanges` — a global copy would make
|
|
@@ -3267,6 +3314,7 @@ export class XlsxPlugin extends BaseWorkbookPlugin {
|
|
|
3267
3314
|
sheetId,
|
|
3268
3315
|
},
|
|
3269
3316
|
...(hidden ? { hidden: true } : {}),
|
|
3317
|
+
...scope,
|
|
3270
3318
|
});
|
|
3271
3319
|
pushedRange = true;
|
|
3272
3320
|
}
|
|
@@ -3283,6 +3331,7 @@ export class XlsxPlugin extends BaseWorkbookPlugin {
|
|
|
3283
3331
|
namedRangeId: uuid(),
|
|
3284
3332
|
value: isAFormula(expression) ? `=${expression}` : expression,
|
|
3285
3333
|
...(hidden ? { hidden: true } : {}),
|
|
3334
|
+
...scope,
|
|
3286
3335
|
});
|
|
3287
3336
|
}
|
|
3288
3337
|
}
|
|
@@ -3299,6 +3348,7 @@ export class XlsxPlugin extends BaseWorkbookPlugin {
|
|
|
3299
3348
|
? `=${expression}`
|
|
3300
3349
|
: expression,
|
|
3301
3350
|
...(hidden ? { hidden: true } : {}),
|
|
3351
|
+
...scope,
|
|
3302
3352
|
});
|
|
3303
3353
|
}
|
|
3304
3354
|
}
|
|
@@ -3322,6 +3372,16 @@ export class XlsxPlugin extends BaseWorkbookPlugin {
|
|
|
3322
3372
|
const v = this.workbookPr?.a$?.date1904;
|
|
3323
3373
|
return v === "1" || v === "true" || v === true;
|
|
3324
3374
|
}
|
|
3375
|
+
/**
|
|
3376
|
+
* `<workbookProtection …/>` → `WorkbookProtection`. The element's presence is
|
|
3377
|
+
* what matters (Excel writes it only for a protected workbook); attributes
|
|
3378
|
+
* are kept exactly as present so the exporter replays them verbatim.
|
|
3379
|
+
*/
|
|
3380
|
+
getWorkbookProtection() {
|
|
3381
|
+
if (!this.workbookProtectionXml)
|
|
3382
|
+
return undefined;
|
|
3383
|
+
return readWorkbookProtectionAttrs(this.workbookProtectionXml?.a$ ?? {});
|
|
3384
|
+
}
|
|
3325
3385
|
getIterativeCalculationOptions() {
|
|
3326
3386
|
const attrs = this.calcPr?.a$;
|
|
3327
3387
|
if (!attrs)
|
|
@@ -5079,6 +5139,51 @@ const SHEET_PROTECTION_FLAGS = [
|
|
|
5079
5139
|
"pivotTables",
|
|
5080
5140
|
"selectUnlockedCells",
|
|
5081
5141
|
];
|
|
5142
|
+
/** `CT_WorkbookProtection` boolean attributes (camelCase = model key). */
|
|
5143
|
+
const WORKBOOK_PROTECTION_FLAGS = [
|
|
5144
|
+
"lockStructure",
|
|
5145
|
+
"lockWindows",
|
|
5146
|
+
"lockRevision",
|
|
5147
|
+
];
|
|
5148
|
+
/** `CT_WorkbookProtection` string (hash / password) attributes. */
|
|
5149
|
+
const WORKBOOK_PROTECTION_TEXT_ATTRS = [
|
|
5150
|
+
"workbookPassword",
|
|
5151
|
+
"revisionsPassword",
|
|
5152
|
+
"workbookAlgorithmName",
|
|
5153
|
+
"workbookHashValue",
|
|
5154
|
+
"workbookSaltValue",
|
|
5155
|
+
"revisionsAlgorithmName",
|
|
5156
|
+
"revisionsHashValue",
|
|
5157
|
+
"revisionsSaltValue",
|
|
5158
|
+
];
|
|
5159
|
+
/**
|
|
5160
|
+
* `<workbookProtection …>` attributes → `WorkbookProtection`. Only attributes
|
|
5161
|
+
* present in the source are set (`"1"|"true"` → true, anything else → false),
|
|
5162
|
+
* so the element round-trips without inventing schema defaults; the password
|
|
5163
|
+
* hashes (legacy `workbookPassword` / `revisionsPassword` or the agile
|
|
5164
|
+
* quartets) ride along verbatim. Mirrors `rnc-import`'s `read_workbook_protection`.
|
|
5165
|
+
*/
|
|
5166
|
+
const readWorkbookProtectionAttrs = (attrs) => {
|
|
5167
|
+
const protection = {};
|
|
5168
|
+
for (const flag of WORKBOOK_PROTECTION_FLAGS) {
|
|
5169
|
+
const value = attrs[flag];
|
|
5170
|
+
if (value !== undefined) {
|
|
5171
|
+
protection[flag] = value === "1" || value === "true";
|
|
5172
|
+
}
|
|
5173
|
+
}
|
|
5174
|
+
for (const key of WORKBOOK_PROTECTION_TEXT_ATTRS) {
|
|
5175
|
+
if (attrs[key])
|
|
5176
|
+
protection[key] = attrs[key];
|
|
5177
|
+
}
|
|
5178
|
+
for (const key of ["workbookSpinCount", "revisionsSpinCount"]) {
|
|
5179
|
+
if (attrs[key] !== undefined) {
|
|
5180
|
+
const count = parseInt(attrs[key], 10);
|
|
5181
|
+
if (Number.isFinite(count))
|
|
5182
|
+
protection[key] = count;
|
|
5183
|
+
}
|
|
5184
|
+
}
|
|
5185
|
+
return protection;
|
|
5186
|
+
};
|
|
5082
5187
|
/**
|
|
5083
5188
|
* `<sheetProtection …>` attributes → `Sheet.sheetProtection`. Only attributes
|
|
5084
5189
|
* present in the source are set (`"1"|"true"` → true, anything else → false),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GridRange, NamedCellStyle } from "@rowsncolumns/common-types";
|
|
2
|
-
import type { CellData, Color, ExtendedValue, TextFormat } from "@rowsncolumns/spreadsheet";
|
|
1
|
+
import type { GridRange, Maybe, NamedCellStyle } from "@rowsncolumns/common-types";
|
|
2
|
+
import type { BorderStyle, CellData, Color, ExtendedValue, TextFormat } from "@rowsncolumns/spreadsheet";
|
|
3
3
|
import type { WorkBook } from "../../workbook";
|
|
4
4
|
import type { WorkbookStyles } from "./index";
|
|
5
5
|
type MergeCellContext = {
|
|
@@ -54,5 +54,20 @@ export declare function fontNodeToTextFormat(font: any, workbookStyles: Workbook
|
|
|
54
54
|
* Extract color information
|
|
55
55
|
*/
|
|
56
56
|
export declare function extractColor(colorObj: any, indexedColors?: Array<string | undefined>): Color | undefined | null;
|
|
57
|
+
/**
|
|
58
|
+
* Map Excel number format ID to our NumberFormatType
|
|
59
|
+
*/
|
|
60
|
+
export declare function mapNumberFormatType(numFmtId: number, formatCode: Maybe<string>): "GENERAL" | "NUMBER" | "CURRENCY" | "ACCOUNTING" | "DATE" | "TIME" | "DATE_TIME" | "PERCENT" | "FRACTION" | "SCIENTIFIC" | "TEXT";
|
|
61
|
+
/**
|
|
62
|
+
* Map Excel border style to our BorderStyle. Covers all 13 OOXML
|
|
63
|
+
* styles; the previous reduced set silently collapsed `hair` →
|
|
64
|
+
* `thin` and lost `mediumDashed` / `dashDot` / `dashDotDot` /
|
|
65
|
+
* `slantDashDot` entirely.
|
|
66
|
+
*/
|
|
67
|
+
export declare function mapBorderStyle(excelStyle: any): BorderStyle;
|
|
68
|
+
/**
|
|
69
|
+
* Map border width based on style
|
|
70
|
+
*/
|
|
71
|
+
export declare function mapBorderWidth(excelStyle: any): 1 | 2 | 3;
|
|
57
72
|
export {};
|
|
58
73
|
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../excel-parser/plugins/xlsx/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,KAAK,EACL,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAEV,WAAW,EACX,QAAQ,EAER,KAAK,EAEL,aAAa,EAIb,UAAU,EACX,MAAM,2BAA2B,CAAC;AAMnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAuD9C,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,SAAS,CAAC;IACjB,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC,CAAC;AAEF;;;;;GAKG;AAEH,6DAA6D;AAC7D,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,OACvB,CAAC;AAE1C,wBAAgB,q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