@cj-tech-master/excelts 4.0.4 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/modules/excel/cell.js +39 -1
- package/dist/browser/modules/excel/enums.d.ts +2 -1
- package/dist/browser/modules/excel/enums.js +2 -1
- package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +1 -0
- package/dist/browser/modules/excel/stream/workbook-writer.browser.js +19 -1
- package/dist/browser/modules/excel/table.d.ts +6 -2
- package/dist/browser/modules/excel/table.js +33 -5
- package/dist/browser/modules/excel/types.d.ts +5 -1
- package/dist/browser/modules/excel/utils/ooxml-paths.d.ts +2 -0
- package/dist/browser/modules/excel/utils/ooxml-paths.js +4 -2
- package/dist/browser/modules/excel/xlsx/rel-type.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/rel-type.js +2 -1
- package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +7 -0
- package/dist/browser/modules/excel/xlsx/xform/core/feature-property-bag-xform.d.ts +8 -0
- package/dist/browser/modules/excel/xlsx/xform/core/feature-property-bag-xform.js +36 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/cell-xform.js +5 -0
- package/dist/browser/modules/excel/xlsx/xform/style/style-xform.d.ts +2 -0
- package/dist/browser/modules/excel/xlsx/xform/style/style-xform.js +11 -0
- package/dist/browser/modules/excel/xlsx/xform/style/styles-xform.d.ts +2 -0
- package/dist/browser/modules/excel/xlsx/xform/style/styles-xform.js +28 -4
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +2 -0
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +19 -0
- package/dist/cjs/modules/excel/cell.js +39 -1
- package/dist/cjs/modules/excel/enums.js +2 -1
- package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +19 -1
- package/dist/cjs/modules/excel/table.js +33 -5
- package/dist/cjs/modules/excel/utils/ooxml-paths.js +4 -2
- package/dist/cjs/modules/excel/xlsx/rel-type.js +2 -1
- package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +7 -0
- package/dist/cjs/modules/excel/xlsx/xform/core/feature-property-bag-xform.js +39 -0
- package/dist/cjs/modules/excel/xlsx/xform/sheet/cell-xform.js +5 -0
- package/dist/cjs/modules/excel/xlsx/xform/style/style-xform.js +11 -0
- package/dist/cjs/modules/excel/xlsx/xform/style/styles-xform.js +28 -4
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +19 -0
- package/dist/esm/modules/excel/cell.js +39 -1
- package/dist/esm/modules/excel/enums.js +2 -1
- package/dist/esm/modules/excel/stream/workbook-writer.browser.js +19 -1
- package/dist/esm/modules/excel/table.js +33 -5
- package/dist/esm/modules/excel/utils/ooxml-paths.js +4 -2
- package/dist/esm/modules/excel/xlsx/rel-type.js +2 -1
- package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +7 -0
- package/dist/esm/modules/excel/xlsx/xform/core/feature-property-bag-xform.js +36 -0
- package/dist/esm/modules/excel/xlsx/xform/sheet/cell-xform.js +5 -0
- package/dist/esm/modules/excel/xlsx/xform/style/style-xform.js +11 -0
- package/dist/esm/modules/excel/xlsx/xform/style/styles-xform.js +28 -4
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +19 -0
- package/dist/iife/excelts.iife.js +165 -12
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +28 -28
- package/dist/types/modules/excel/enums.d.ts +2 -1
- package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +1 -0
- package/dist/types/modules/excel/table.d.ts +6 -2
- package/dist/types/modules/excel/types.d.ts +5 -1
- package/dist/types/modules/excel/utils/ooxml-paths.d.ts +2 -0
- package/dist/types/modules/excel/xlsx/rel-type.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/core/feature-property-bag-xform.d.ts +8 -0
- package/dist/types/modules/excel/xlsx/xform/style/style-xform.d.ts +2 -0
- package/dist/types/modules/excel/xlsx/xform/style/styles-xform.d.ts +2 -0
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +2 -0
- package/package.json +8 -8
|
@@ -189,6 +189,11 @@ class CellXform extends BaseXform {
|
|
|
189
189
|
xmlStream.addAttribute("t", "b");
|
|
190
190
|
xmlStream.leafNode("v", null, model.value ? "1" : "0");
|
|
191
191
|
break;
|
|
192
|
+
case Enums.ValueType.Checkbox:
|
|
193
|
+
// Checkboxes are stored as boolean values
|
|
194
|
+
xmlStream.addAttribute("t", "b");
|
|
195
|
+
xmlStream.leafNode("v", null, model.value ? "1" : "0");
|
|
196
|
+
break;
|
|
192
197
|
case Enums.ValueType.Error:
|
|
193
198
|
xmlStream.addAttribute("t", "e");
|
|
194
199
|
xmlStream.leafNode("v", null, model.value.error);
|
|
@@ -52,6 +52,17 @@ class StyleXform extends BaseXform {
|
|
|
52
52
|
if (model.protection) {
|
|
53
53
|
this.map.protection.render(xmlStream, model.protection);
|
|
54
54
|
}
|
|
55
|
+
// Add checkbox extLst if needed
|
|
56
|
+
if (model.checkbox && model.xfComplementIndex !== undefined) {
|
|
57
|
+
xmlStream.openNode("extLst");
|
|
58
|
+
xmlStream.openNode("ext", {
|
|
59
|
+
"xmlns:xfpb": "http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag",
|
|
60
|
+
uri: "{C7286773-470A-42A8-94C5-96B5CB345126}"
|
|
61
|
+
});
|
|
62
|
+
xmlStream.leafNode("xfpb:xfComplement", { i: model.xfComplementIndex });
|
|
63
|
+
xmlStream.closeNode();
|
|
64
|
+
xmlStream.closeNode();
|
|
65
|
+
}
|
|
55
66
|
xmlStream.closeNode();
|
|
56
67
|
}
|
|
57
68
|
parseOpen(node) {
|
|
@@ -82,6 +82,7 @@ class StylesXform extends BaseXform {
|
|
|
82
82
|
this._addFill({ type: "pattern", pattern: "none" });
|
|
83
83
|
this._addFill({ type: "pattern", pattern: "gray125" });
|
|
84
84
|
this.weakMap = new WeakMap();
|
|
85
|
+
this._hasCheckboxes = false;
|
|
85
86
|
}
|
|
86
87
|
render(xmlStream, model) {
|
|
87
88
|
const renderModel = model || this.model;
|
|
@@ -222,12 +223,15 @@ class StylesXform extends BaseXform {
|
|
|
222
223
|
// default (zero) font
|
|
223
224
|
this._addFont({ size: 11, color: { theme: 1 }, name: "Calibri", family: 2, scheme: "minor" });
|
|
224
225
|
}
|
|
225
|
-
|
|
226
|
-
|
|
226
|
+
const type = cellType || Enums.ValueType.Number;
|
|
227
|
+
// If we have seen this style object before, assume it has the same styleId.
|
|
228
|
+
// Do not cache by object identity for checkbox cells because the styleId must
|
|
229
|
+
// include checkbox-specific extLst, and the same style object may be reused
|
|
230
|
+
// for non-checkbox cells.
|
|
231
|
+
if (type !== Enums.ValueType.Checkbox && this.weakMap && this.weakMap.has(model)) {
|
|
227
232
|
return this.weakMap.get(model);
|
|
228
233
|
}
|
|
229
234
|
const style = {};
|
|
230
|
-
const type = cellType || Enums.ValueType.Number;
|
|
231
235
|
if (model.numFmt) {
|
|
232
236
|
style.numFmtId = this._addNumFmtStr(model.numFmt);
|
|
233
237
|
}
|
|
@@ -258,8 +262,17 @@ class StylesXform extends BaseXform {
|
|
|
258
262
|
if (model.protection) {
|
|
259
263
|
style.protection = model.protection;
|
|
260
264
|
}
|
|
265
|
+
if (type === Enums.ValueType.Checkbox) {
|
|
266
|
+
// Checkbox rendering relies on style extensions (extLst) and workbook-level parts.
|
|
267
|
+
// Force applyAlignment="1" (without emitting an <alignment/> node) by providing
|
|
268
|
+
// an empty alignment object when none is specified.
|
|
269
|
+
this._hasCheckboxes = true;
|
|
270
|
+
style.alignment = style.alignment || {};
|
|
271
|
+
style.checkbox = true;
|
|
272
|
+
style.xfComplementIndex = 0;
|
|
273
|
+
}
|
|
261
274
|
const styleId = this._addStyle(style);
|
|
262
|
-
if (this.weakMap) {
|
|
275
|
+
if (type !== Enums.ValueType.Checkbox && this.weakMap) {
|
|
263
276
|
this.weakMap.set(model, styleId);
|
|
264
277
|
}
|
|
265
278
|
return styleId;
|
|
@@ -322,6 +335,10 @@ class StylesXform extends BaseXform {
|
|
|
322
335
|
getDxfStyle(id) {
|
|
323
336
|
return this.model.dxfs[id];
|
|
324
337
|
}
|
|
338
|
+
// Check if workbook uses checkbox feature
|
|
339
|
+
get hasCheckboxes() {
|
|
340
|
+
return !!this._hasCheckboxes;
|
|
341
|
+
}
|
|
325
342
|
// =========================================================================
|
|
326
343
|
// Private Interface
|
|
327
344
|
_addStyle(style) {
|
|
@@ -457,12 +474,19 @@ class StylesXformMock extends StylesXform {
|
|
|
457
474
|
// the styleId is returned. Note: cellType is used when numFmt not defined
|
|
458
475
|
addStyleModel(model, cellType) {
|
|
459
476
|
switch (cellType) {
|
|
477
|
+
case Enums.ValueType.Checkbox:
|
|
478
|
+
// Checkbox rendering relies on style extensions (extLst) and workbook-level parts.
|
|
479
|
+
// The mock style manager intentionally does not build those structures.
|
|
480
|
+
throw new Error("Checkbox cells require styles to be enabled (useStyles: true)");
|
|
460
481
|
case Enums.ValueType.Date:
|
|
461
482
|
return this.dateStyleId;
|
|
462
483
|
default:
|
|
463
484
|
return 0;
|
|
464
485
|
}
|
|
465
486
|
}
|
|
487
|
+
get hasCheckboxes() {
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
466
490
|
get dateStyleId() {
|
|
467
491
|
if (!this._dateStyleId) {
|
|
468
492
|
const dateStyle = {
|
|
@@ -17,6 +17,7 @@ import { ContentTypesXform } from "./xform/core/content-types-xform.js";
|
|
|
17
17
|
import { AppXform } from "./xform/core/app-xform.js";
|
|
18
18
|
import { WorkbookXform } from "./xform/book/workbook-xform.js";
|
|
19
19
|
import { WorkSheetXform } from "./xform/sheet/worksheet-xform.js";
|
|
20
|
+
import { FeaturePropertyBagXform } from "./xform/core/feature-property-bag-xform.js";
|
|
20
21
|
import { DrawingXform } from "./xform/drawing/drawing-xform.js";
|
|
21
22
|
import { TableXform } from "./xform/table/table-xform.js";
|
|
22
23
|
import { PivotCacheRecordsXform } from "./xform/pivot-table/pivot-cache-records-xform.js";
|
|
@@ -203,6 +204,7 @@ class XLSX {
|
|
|
203
204
|
this.addTables(zip, model);
|
|
204
205
|
this.addPivotTables(zip, model);
|
|
205
206
|
await Promise.all([this.addThemes(zip, model), this.addStyles(zip, model)]);
|
|
207
|
+
await this.addFeaturePropertyBag(zip, model);
|
|
206
208
|
await this.addMedia(zip, model);
|
|
207
209
|
await Promise.all([this.addApp(zip, model), this.addCore(zip, model)]);
|
|
208
210
|
await this.addWorkbook(zip, model);
|
|
@@ -971,6 +973,14 @@ class XLSX {
|
|
|
971
973
|
Target: OOXML_REL_TARGETS.workbookSharedStrings
|
|
972
974
|
});
|
|
973
975
|
}
|
|
976
|
+
// Add FeaturePropertyBag relationship if checkboxes are used
|
|
977
|
+
if (model.hasCheckboxes) {
|
|
978
|
+
relationships.push({
|
|
979
|
+
Id: `rId${count++}`,
|
|
980
|
+
Type: XLSX.RelType.FeaturePropertyBag,
|
|
981
|
+
Target: OOXML_REL_TARGETS.workbookFeaturePropertyBag
|
|
982
|
+
});
|
|
983
|
+
}
|
|
974
984
|
(model.pivotTables || []).forEach((pivotTable) => {
|
|
975
985
|
pivotTable.rId = `rId${count++}`;
|
|
976
986
|
relationships.push({
|
|
@@ -992,6 +1002,13 @@ class XLSX {
|
|
|
992
1002
|
const xml = xform.toXml(relationships);
|
|
993
1003
|
zip.append(xml, { name: OOXML_PATHS.xlWorkbookRels });
|
|
994
1004
|
}
|
|
1005
|
+
async addFeaturePropertyBag(zip, model) {
|
|
1006
|
+
if (!model.hasCheckboxes) {
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
const xform = new FeaturePropertyBagXform();
|
|
1010
|
+
zip.append(xform.toXml({}), { name: OOXML_PATHS.xlFeaturePropertyBag });
|
|
1011
|
+
}
|
|
995
1012
|
async addSharedStrings(zip, model) {
|
|
996
1013
|
if (model.sharedStrings && model.sharedStrings.count) {
|
|
997
1014
|
zip.append(model.sharedStrings.xml, { name: OOXML_PATHS.xlSharedStrings });
|
|
@@ -1146,6 +1163,8 @@ class XLSX {
|
|
|
1146
1163
|
});
|
|
1147
1164
|
worksheetXform.prepare(worksheet, worksheetOptions);
|
|
1148
1165
|
});
|
|
1166
|
+
// ContentTypesXform expects this flag
|
|
1167
|
+
model.hasCheckboxes = model.styles.hasCheckboxes;
|
|
1149
1168
|
}
|
|
1150
1169
|
}
|
|
1151
1170
|
XLSX.RelType = RelType;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cj-tech-master/excelts v4.0
|
|
2
|
+
* @cj-tech-master/excelts v4.1.0
|
|
3
3
|
* TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.
|
|
4
4
|
* (c) 2026 cjnoname
|
|
5
5
|
* Released under the MIT License
|
|
@@ -448,6 +448,7 @@ var ExcelTS = (function(exports) {
|
|
|
448
448
|
ValueType$1[ValueType$1["Boolean"] = 9] = "Boolean";
|
|
449
449
|
ValueType$1[ValueType$1["Error"] = 10] = "Error";
|
|
450
450
|
ValueType$1[ValueType$1["JSON"] = 11] = "JSON";
|
|
451
|
+
ValueType$1[ValueType$1["Checkbox"] = 12] = "Checkbox";
|
|
451
452
|
return ValueType$1;
|
|
452
453
|
}({});
|
|
453
454
|
let FormulaType = /* @__PURE__ */ function(FormulaType$1) {
|
|
@@ -1336,6 +1337,40 @@ var ExcelTS = (function(exports) {
|
|
|
1336
1337
|
return this.model.value.toString();
|
|
1337
1338
|
}
|
|
1338
1339
|
};
|
|
1340
|
+
var CheckboxValue = class {
|
|
1341
|
+
constructor(cell, value) {
|
|
1342
|
+
this.model = {
|
|
1343
|
+
address: cell.address,
|
|
1344
|
+
type: Cell.Types.Checkbox,
|
|
1345
|
+
value: value.checkbox
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
get value() {
|
|
1349
|
+
return { checkbox: this.model.value };
|
|
1350
|
+
}
|
|
1351
|
+
set value(value) {
|
|
1352
|
+
this.model.value = value.checkbox;
|
|
1353
|
+
}
|
|
1354
|
+
get type() {
|
|
1355
|
+
return Cell.Types.Checkbox;
|
|
1356
|
+
}
|
|
1357
|
+
get effectiveType() {
|
|
1358
|
+
return Cell.Types.Boolean;
|
|
1359
|
+
}
|
|
1360
|
+
get address() {
|
|
1361
|
+
return this.model.address;
|
|
1362
|
+
}
|
|
1363
|
+
set address(value) {
|
|
1364
|
+
this.model.address = value;
|
|
1365
|
+
}
|
|
1366
|
+
toCsvString() {
|
|
1367
|
+
return this.model.value ? 1 : 0;
|
|
1368
|
+
}
|
|
1369
|
+
release() {}
|
|
1370
|
+
toString() {
|
|
1371
|
+
return this.model.value.toString();
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1339
1374
|
var ErrorValue$1 = class {
|
|
1340
1375
|
constructor(cell, value) {
|
|
1341
1376
|
this.model = {
|
|
@@ -1414,6 +1449,7 @@ var ExcelTS = (function(exports) {
|
|
|
1414
1449
|
if (typeof value === "boolean") return Cell.Types.Boolean;
|
|
1415
1450
|
if (value instanceof Date) return Cell.Types.Date;
|
|
1416
1451
|
if (typeof value === "object") {
|
|
1452
|
+
if ("checkbox" in value && typeof value.checkbox === "boolean") return Cell.Types.Checkbox;
|
|
1417
1453
|
if ("text" in value && value.text && "hyperlink" in value && value.hyperlink) return Cell.Types.Hyperlink;
|
|
1418
1454
|
if ("formula" in value && value.formula || "sharedFormula" in value && value.sharedFormula) return Cell.Types.Formula;
|
|
1419
1455
|
if ("richText" in value && value.richText) return Cell.Types.RichText;
|
|
@@ -1470,6 +1506,10 @@ var ExcelTS = (function(exports) {
|
|
|
1470
1506
|
{
|
|
1471
1507
|
t: Cell.Types.Error,
|
|
1472
1508
|
f: ErrorValue$1
|
|
1509
|
+
},
|
|
1510
|
+
{
|
|
1511
|
+
t: Cell.Types.Checkbox,
|
|
1512
|
+
f: CheckboxValue
|
|
1473
1513
|
}
|
|
1474
1514
|
].reduce((p, t) => {
|
|
1475
1515
|
p[t.t] = t.f;
|
|
@@ -2309,6 +2349,19 @@ var ExcelTS = (function(exports) {
|
|
|
2309
2349
|
this.worksheet = worksheet;
|
|
2310
2350
|
if (table) {
|
|
2311
2351
|
this.table = table;
|
|
2352
|
+
if (Array.isArray(table.rows) && table.rows.length === 0 && table.tableRef) {
|
|
2353
|
+
const decoded = colCache.decode(table.tableRef);
|
|
2354
|
+
if ("dimensions" in decoded) {
|
|
2355
|
+
const startRow = decoded.top + (table.headerRow === false ? 0 : 1);
|
|
2356
|
+
const endRow = decoded.bottom - (table.totalsRow === true ? 1 : 0);
|
|
2357
|
+
if (endRow >= startRow) for (let r = startRow; r <= endRow; r++) {
|
|
2358
|
+
const row = worksheet.getRow(r);
|
|
2359
|
+
const values = [];
|
|
2360
|
+
for (let c = decoded.left; c <= decoded.right; c++) values.push(row.getCell(c).value);
|
|
2361
|
+
table.rows.push(values);
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2312
2365
|
this.validate();
|
|
2313
2366
|
this.store();
|
|
2314
2367
|
}
|
|
@@ -2363,8 +2416,8 @@ var ExcelTS = (function(exports) {
|
|
|
2363
2416
|
const { row, col } = table.tl;
|
|
2364
2417
|
assert(row > 0, "Table must be on valid row");
|
|
2365
2418
|
assert(col > 0, "Table must be on valid col");
|
|
2366
|
-
const { width,
|
|
2367
|
-
table.autoFilterRef = colCache.encode(row, col, row
|
|
2419
|
+
const { width, tableHeight } = this;
|
|
2420
|
+
table.autoFilterRef = colCache.encode(row, col, row, col + width - 1);
|
|
2368
2421
|
table.tableRef = colCache.encode(row, col, row + tableHeight - 1, col + width - 1);
|
|
2369
2422
|
table.columns.forEach((column, i) => {
|
|
2370
2423
|
assert(!!column.name, `Column ${i} must have a name`);
|
|
@@ -2491,15 +2544,18 @@ var ExcelTS = (function(exports) {
|
|
|
2491
2544
|
}
|
|
2492
2545
|
}
|
|
2493
2546
|
this.store();
|
|
2547
|
+
this._cache = void 0;
|
|
2494
2548
|
}
|
|
2495
|
-
addRow(values, rowNumber) {
|
|
2549
|
+
addRow(values, rowNumber, options) {
|
|
2496
2550
|
this.cacheState();
|
|
2497
2551
|
if (rowNumber === void 0) this.table.rows.push(values);
|
|
2498
2552
|
else this.table.rows.splice(rowNumber, 0, values);
|
|
2553
|
+
if (options?.commit !== false) this.commit();
|
|
2499
2554
|
}
|
|
2500
|
-
removeRows(rowIndex, count = 1) {
|
|
2555
|
+
removeRows(rowIndex, count = 1, options) {
|
|
2501
2556
|
this.cacheState();
|
|
2502
2557
|
this.table.rows.splice(rowIndex, count);
|
|
2558
|
+
if (options?.commit !== false) this.commit();
|
|
2503
2559
|
}
|
|
2504
2560
|
getColumn(colIndex) {
|
|
2505
2561
|
const column = this.table.columns[colIndex];
|
|
@@ -8329,6 +8385,16 @@ var ExcelTS = (function(exports) {
|
|
|
8329
8385
|
*/
|
|
8330
8386
|
if (model.alignment) this.map.alignment.render(xmlStream, model.alignment);
|
|
8331
8387
|
if (model.protection) this.map.protection.render(xmlStream, model.protection);
|
|
8388
|
+
if (model.checkbox && model.xfComplementIndex !== void 0) {
|
|
8389
|
+
xmlStream.openNode("extLst");
|
|
8390
|
+
xmlStream.openNode("ext", {
|
|
8391
|
+
"xmlns:xfpb": "http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag",
|
|
8392
|
+
uri: "{C7286773-470A-42A8-94C5-96B5CB345126}"
|
|
8393
|
+
});
|
|
8394
|
+
xmlStream.leafNode("xfpb:xfComplement", { i: model.xfComplementIndex });
|
|
8395
|
+
xmlStream.closeNode();
|
|
8396
|
+
xmlStream.closeNode();
|
|
8397
|
+
}
|
|
8332
8398
|
xmlStream.closeNode();
|
|
8333
8399
|
}
|
|
8334
8400
|
parseOpen(node) {
|
|
@@ -8536,6 +8602,7 @@ var ExcelTS = (function(exports) {
|
|
|
8536
8602
|
pattern: "gray125"
|
|
8537
8603
|
});
|
|
8538
8604
|
this.weakMap = /* @__PURE__ */ new WeakMap();
|
|
8605
|
+
this._hasCheckboxes = false;
|
|
8539
8606
|
}
|
|
8540
8607
|
render(xmlStream, model) {
|
|
8541
8608
|
const renderModel = model || this.model;
|
|
@@ -8665,9 +8732,9 @@ var ExcelTS = (function(exports) {
|
|
|
8665
8732
|
family: 2,
|
|
8666
8733
|
scheme: "minor"
|
|
8667
8734
|
});
|
|
8668
|
-
if (this.weakMap && this.weakMap.has(model)) return this.weakMap.get(model);
|
|
8669
|
-
const style = {};
|
|
8670
8735
|
const type = cellType || Enums.ValueType.Number;
|
|
8736
|
+
if (type !== Enums.ValueType.Checkbox && this.weakMap && this.weakMap.has(model)) return this.weakMap.get(model);
|
|
8737
|
+
const style = {};
|
|
8671
8738
|
if (model.numFmt) style.numFmtId = this._addNumFmtStr(model.numFmt);
|
|
8672
8739
|
else switch (type) {
|
|
8673
8740
|
case Enums.ValueType.Number:
|
|
@@ -8683,8 +8750,14 @@ var ExcelTS = (function(exports) {
|
|
|
8683
8750
|
if (model.fill) style.fillId = this._addFill(model.fill);
|
|
8684
8751
|
if (model.alignment) style.alignment = model.alignment;
|
|
8685
8752
|
if (model.protection) style.protection = model.protection;
|
|
8753
|
+
if (type === Enums.ValueType.Checkbox) {
|
|
8754
|
+
this._hasCheckboxes = true;
|
|
8755
|
+
style.alignment = style.alignment || {};
|
|
8756
|
+
style.checkbox = true;
|
|
8757
|
+
style.xfComplementIndex = 0;
|
|
8758
|
+
}
|
|
8686
8759
|
const styleId = this._addStyle(style);
|
|
8687
|
-
if (this.weakMap) this.weakMap.set(model, styleId);
|
|
8760
|
+
if (type !== Enums.ValueType.Checkbox && this.weakMap) this.weakMap.set(model, styleId);
|
|
8688
8761
|
return styleId;
|
|
8689
8762
|
}
|
|
8690
8763
|
getStyleModel(id) {
|
|
@@ -8718,6 +8791,9 @@ var ExcelTS = (function(exports) {
|
|
|
8718
8791
|
getDxfStyle(id) {
|
|
8719
8792
|
return this.model.dxfs[id];
|
|
8720
8793
|
}
|
|
8794
|
+
get hasCheckboxes() {
|
|
8795
|
+
return !!this._hasCheckboxes;
|
|
8796
|
+
}
|
|
8721
8797
|
_addStyle(style) {
|
|
8722
8798
|
const xml = this.map.style.toXml(style);
|
|
8723
8799
|
let index = this.index.style[xml];
|
|
@@ -8864,10 +8940,14 @@ var ExcelTS = (function(exports) {
|
|
|
8864
8940
|
}
|
|
8865
8941
|
addStyleModel(model, cellType) {
|
|
8866
8942
|
switch (cellType) {
|
|
8943
|
+
case Enums.ValueType.Checkbox: throw new Error("Checkbox cells require styles to be enabled (useStyles: true)");
|
|
8867
8944
|
case Enums.ValueType.Date: return this.dateStyleId;
|
|
8868
8945
|
default: return 0;
|
|
8869
8946
|
}
|
|
8870
8947
|
}
|
|
8948
|
+
get hasCheckboxes() {
|
|
8949
|
+
return false;
|
|
8950
|
+
}
|
|
8871
8951
|
get dateStyleId() {
|
|
8872
8952
|
if (!this._dateStyleId) {
|
|
8873
8953
|
const dateStyle = { numFmtId: NumFmtXform.getDefaultFmtId("mm-dd-yy") };
|
|
@@ -9476,7 +9556,8 @@ var ExcelTS = (function(exports) {
|
|
|
9476
9556
|
xlWorkbookRels: "xl/_rels/workbook.xml.rels",
|
|
9477
9557
|
xlSharedStrings: "xl/sharedStrings.xml",
|
|
9478
9558
|
xlStyles: "xl/styles.xml",
|
|
9479
|
-
xlTheme1: "xl/theme/theme1.xml"
|
|
9559
|
+
xlTheme1: "xl/theme/theme1.xml",
|
|
9560
|
+
xlFeaturePropertyBag: "xl/featurePropertyBag/featurePropertyBag.xml"
|
|
9480
9561
|
};
|
|
9481
9562
|
const worksheetXmlRegex = /^xl\/worksheets\/sheet(\d+)[.]xml$/;
|
|
9482
9563
|
const worksheetRelsXmlRegex = /^xl\/worksheets\/_rels\/sheet(\d+)[.]xml[.]rels$/;
|
|
@@ -9622,7 +9703,8 @@ var ExcelTS = (function(exports) {
|
|
|
9622
9703
|
const OOXML_REL_TARGETS = {
|
|
9623
9704
|
workbookStyles: "styles.xml",
|
|
9624
9705
|
workbookSharedStrings: "sharedStrings.xml",
|
|
9625
|
-
workbookTheme1: "theme/theme1.xml"
|
|
9706
|
+
workbookTheme1: "theme/theme1.xml",
|
|
9707
|
+
workbookFeaturePropertyBag: "featurePropertyBag/featurePropertyBag.xml"
|
|
9626
9708
|
};
|
|
9627
9709
|
function pivotCacheDefinitionRelTargetFromWorkbook(n) {
|
|
9628
9710
|
return `pivotCache/pivotCacheDefinition${n}.xml`;
|
|
@@ -9719,6 +9801,10 @@ var ExcelTS = (function(exports) {
|
|
|
9719
9801
|
PartName: toContentTypesPartName(OOXML_PATHS.xlStyles),
|
|
9720
9802
|
ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"
|
|
9721
9803
|
});
|
|
9804
|
+
if (model.hasCheckboxes) xmlStream.leafNode("Override", {
|
|
9805
|
+
PartName: toContentTypesPartName(OOXML_PATHS.xlFeaturePropertyBag),
|
|
9806
|
+
ContentType: "application/vnd.ms-excel.featurepropertybag+xml"
|
|
9807
|
+
});
|
|
9722
9808
|
if (model.sharedStrings && model.sharedStrings.count) xmlStream.leafNode("Override", {
|
|
9723
9809
|
PartName: toContentTypesPartName(OOXML_PATHS.xlSharedStrings),
|
|
9724
9810
|
ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"
|
|
@@ -10327,7 +10413,8 @@ var ExcelTS = (function(exports) {
|
|
|
10327
10413
|
Table: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",
|
|
10328
10414
|
PivotCacheDefinition: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition",
|
|
10329
10415
|
PivotCacheRecords: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords",
|
|
10330
|
-
PivotTable: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"
|
|
10416
|
+
PivotTable: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable",
|
|
10417
|
+
FeaturePropertyBag: "http://schemas.microsoft.com/office/2022/11/relationships/FeaturePropertyBag"
|
|
10331
10418
|
};
|
|
10332
10419
|
|
|
10333
10420
|
//#endregion
|
|
@@ -10506,6 +10593,10 @@ var ExcelTS = (function(exports) {
|
|
|
10506
10593
|
xmlStream.addAttribute("t", "b");
|
|
10507
10594
|
xmlStream.leafNode("v", null, model.value ? "1" : "0");
|
|
10508
10595
|
break;
|
|
10596
|
+
case Enums.ValueType.Checkbox:
|
|
10597
|
+
xmlStream.addAttribute("t", "b");
|
|
10598
|
+
xmlStream.leafNode("v", null, model.value ? "1" : "0");
|
|
10599
|
+
break;
|
|
10509
10600
|
case Enums.ValueType.Error:
|
|
10510
10601
|
xmlStream.addAttribute("t", "e");
|
|
10511
10602
|
xmlStream.leafNode("v", null, model.value.error);
|
|
@@ -13433,6 +13524,42 @@ var ExcelTS = (function(exports) {
|
|
|
13433
13524
|
}
|
|
13434
13525
|
};
|
|
13435
13526
|
|
|
13527
|
+
//#endregion
|
|
13528
|
+
//#region src/modules/excel/xlsx/xform/core/feature-property-bag-xform.ts
|
|
13529
|
+
var FeaturePropertyBagXform = class extends BaseXform {
|
|
13530
|
+
render(xmlStream) {
|
|
13531
|
+
xmlStream.openXml({
|
|
13532
|
+
version: "1.0",
|
|
13533
|
+
encoding: "UTF-8",
|
|
13534
|
+
standalone: "yes"
|
|
13535
|
+
});
|
|
13536
|
+
xmlStream.openNode("FeaturePropertyBags", { xmlns: "http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag" });
|
|
13537
|
+
xmlStream.leafNode("bag", { type: "Checkbox" });
|
|
13538
|
+
xmlStream.openNode("bag", { type: "XFControls" });
|
|
13539
|
+
xmlStream.leafNode("bagId", { k: "CellControl" }, "0");
|
|
13540
|
+
xmlStream.closeNode();
|
|
13541
|
+
xmlStream.openNode("bag", { type: "XFComplement" });
|
|
13542
|
+
xmlStream.leafNode("bagId", { k: "XFControls" }, "1");
|
|
13543
|
+
xmlStream.closeNode();
|
|
13544
|
+
xmlStream.openNode("bag", {
|
|
13545
|
+
type: "XFComplements",
|
|
13546
|
+
extRef: "XFComplementsMapperExtRef"
|
|
13547
|
+
});
|
|
13548
|
+
xmlStream.openNode("a", { k: "MappedFeaturePropertyBags" });
|
|
13549
|
+
xmlStream.leafNode("bagId", {}, "2");
|
|
13550
|
+
xmlStream.closeNode();
|
|
13551
|
+
xmlStream.closeNode();
|
|
13552
|
+
xmlStream.closeNode();
|
|
13553
|
+
}
|
|
13554
|
+
parseOpen() {
|
|
13555
|
+
return false;
|
|
13556
|
+
}
|
|
13557
|
+
parseText() {}
|
|
13558
|
+
parseClose() {
|
|
13559
|
+
return false;
|
|
13560
|
+
}
|
|
13561
|
+
};
|
|
13562
|
+
|
|
13436
13563
|
//#endregion
|
|
13437
13564
|
//#region src/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.ts
|
|
13438
13565
|
var BaseCellAnchorXform = class extends BaseXform {
|
|
@@ -19606,6 +19733,7 @@ var ExcelTS = (function(exports) {
|
|
|
19606
19733
|
this.addTables(zip, model);
|
|
19607
19734
|
this.addPivotTables(zip, model);
|
|
19608
19735
|
await Promise.all([this.addThemes(zip, model), this.addStyles(zip, model)]);
|
|
19736
|
+
await this.addFeaturePropertyBag(zip, model);
|
|
19609
19737
|
await this.addMedia(zip, model);
|
|
19610
19738
|
await Promise.all([this.addApp(zip, model), this.addCore(zip, model)]);
|
|
19611
19739
|
await this.addWorkbook(zip, model);
|
|
@@ -20264,6 +20392,11 @@ var ExcelTS = (function(exports) {
|
|
|
20264
20392
|
Type: XLSX.RelType.SharedStrings,
|
|
20265
20393
|
Target: OOXML_REL_TARGETS.workbookSharedStrings
|
|
20266
20394
|
});
|
|
20395
|
+
if (model.hasCheckboxes) relationships.push({
|
|
20396
|
+
Id: `rId${count++}`,
|
|
20397
|
+
Type: XLSX.RelType.FeaturePropertyBag,
|
|
20398
|
+
Target: OOXML_REL_TARGETS.workbookFeaturePropertyBag
|
|
20399
|
+
});
|
|
20267
20400
|
(model.pivotTables || []).forEach((pivotTable) => {
|
|
20268
20401
|
pivotTable.rId = `rId${count++}`;
|
|
20269
20402
|
relationships.push({
|
|
@@ -20284,6 +20417,11 @@ var ExcelTS = (function(exports) {
|
|
|
20284
20417
|
const xml = new RelationshipsXform().toXml(relationships);
|
|
20285
20418
|
zip.append(xml, { name: OOXML_PATHS.xlWorkbookRels });
|
|
20286
20419
|
}
|
|
20420
|
+
async addFeaturePropertyBag(zip, model) {
|
|
20421
|
+
if (!model.hasCheckboxes) return;
|
|
20422
|
+
const xform$1 = new FeaturePropertyBagXform();
|
|
20423
|
+
zip.append(xform$1.toXml({}), { name: OOXML_PATHS.xlFeaturePropertyBag });
|
|
20424
|
+
}
|
|
20287
20425
|
async addSharedStrings(zip, model) {
|
|
20288
20426
|
if (model.sharedStrings && model.sharedStrings.count) zip.append(model.sharedStrings.xml, { name: OOXML_PATHS.xlSharedStrings });
|
|
20289
20427
|
}
|
|
@@ -20425,6 +20563,7 @@ var ExcelTS = (function(exports) {
|
|
|
20425
20563
|
});
|
|
20426
20564
|
worksheetXform.prepare(worksheet, worksheetOptions);
|
|
20427
20565
|
});
|
|
20566
|
+
model.hasCheckboxes = model.styles.hasCheckboxes;
|
|
20428
20567
|
}
|
|
20429
20568
|
};
|
|
20430
20569
|
|
|
@@ -22448,6 +22587,7 @@ var ExcelTS = (function(exports) {
|
|
|
22448
22587
|
this.addCore(),
|
|
22449
22588
|
this.addSharedStrings(),
|
|
22450
22589
|
this.addStyles(),
|
|
22590
|
+
this.addFeaturePropertyBag(),
|
|
22451
22591
|
this.addWorkbookRels()
|
|
22452
22592
|
]);
|
|
22453
22593
|
await this.addWorkbook();
|
|
@@ -22543,7 +22683,8 @@ var ExcelTS = (function(exports) {
|
|
|
22543
22683
|
worksheets: this._worksheets.filter(Boolean),
|
|
22544
22684
|
sharedStrings: this.sharedStrings,
|
|
22545
22685
|
commentRefs: this.commentRefs,
|
|
22546
|
-
media: this.media
|
|
22686
|
+
media: this.media,
|
|
22687
|
+
hasCheckboxes: this.styles.hasCheckboxes
|
|
22547
22688
|
};
|
|
22548
22689
|
const xform$1 = new ContentTypesXform();
|
|
22549
22690
|
this._addFile(xform$1.toXml(model), OOXML_PATHS.contentTypes);
|
|
@@ -22593,6 +22734,13 @@ var ExcelTS = (function(exports) {
|
|
|
22593
22734
|
});
|
|
22594
22735
|
return Promise.resolve();
|
|
22595
22736
|
}
|
|
22737
|
+
addFeaturePropertyBag() {
|
|
22738
|
+
if (this.styles.hasCheckboxes) {
|
|
22739
|
+
const xform$1 = new FeaturePropertyBagXform();
|
|
22740
|
+
this._addFile(xform$1.toXml({}), OOXML_PATHS.xlFeaturePropertyBag);
|
|
22741
|
+
}
|
|
22742
|
+
return Promise.resolve();
|
|
22743
|
+
}
|
|
22596
22744
|
addWorkbookRels() {
|
|
22597
22745
|
let count = 1;
|
|
22598
22746
|
const relationships = [{
|
|
@@ -22609,6 +22757,11 @@ var ExcelTS = (function(exports) {
|
|
|
22609
22757
|
Type: RelType.SharedStrings,
|
|
22610
22758
|
Target: OOXML_REL_TARGETS.workbookSharedStrings
|
|
22611
22759
|
});
|
|
22760
|
+
if (this.styles.hasCheckboxes) relationships.push({
|
|
22761
|
+
Id: `rId${count++}`,
|
|
22762
|
+
Type: RelType.FeaturePropertyBag,
|
|
22763
|
+
Target: OOXML_REL_TARGETS.workbookFeaturePropertyBag
|
|
22764
|
+
});
|
|
22612
22765
|
this._worksheets.forEach((ws) => {
|
|
22613
22766
|
if (ws) {
|
|
22614
22767
|
ws.rId = `rId${count++}`;
|