ooxml.js 6.0.0 → 6.2.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/README.md +32 -23
- package/dist/{build-XSm3I8LT.d.cts → build--uPsivid.d.cts} +1 -1
- package/dist/{build-q0qMH_ML.d.ts → build-BOI7rIog.d.ts} +1 -1
- package/dist/{build-D-ldsmtA.d.cts → build-BY9Mn-4K.d.cts} +1 -1
- package/dist/{build-Z1KRkSEB.d.ts → build-DgBE0bmv.d.ts} +1 -1
- package/dist/{codec-DdrBDJSU.d.cts → codec-BBM1RYx7.d.cts} +19 -19
- package/dist/{codec-CHbouqVZ.d.ts → codec-Cva8QD7-.d.ts} +19 -19
- package/dist/codec.d.cts +1 -1
- package/dist/codec.d.ts +1 -1
- package/dist/{color-fFIKAs-Y.d.cts → color-DLoZOrg3.d.cts} +1 -1
- package/dist/{color-fFIKAs-Y.d.ts → color-DLoZOrg3.d.ts} +1 -1
- package/dist/{compact-f0TfhicN.d.ts → compact-CmOeA2dl.d.ts} +2 -2
- package/dist/{compact-B1qg9oex.d.cts → compact-DMCbYORW.d.cts} +2 -2
- package/dist/compact.d.cts +1 -1
- package/dist/compact.d.ts +1 -1
- package/dist/{content-C79O3esU.d.cts → content-BiYr86lr.d.cts} +1 -1
- package/dist/{content-MEmp_Rlx.d.ts → content-D1pmxaUb.d.ts} +1 -1
- package/dist/{document-tree-BV4sMCXO.d.ts → document-tree-B17XbBOR.d.ts} +2 -2
- package/dist/{document-tree-BSPf6fkr.d.cts → document-tree-CjI-Z4Tp.d.cts} +2 -2
- package/dist/{fragment-B1og_8uA.d.cts → fragment-9dNg-m46.d.cts} +1 -1
- package/dist/{fragment-B1ZV7T5Z.d.ts → fragment-ClgCV_if.d.ts} +1 -1
- package/dist/image/sniff.d.cts +1 -1
- package/dist/image/sniff.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +21 -21
- package/dist/index.d.ts +21 -21
- package/dist/index.js +1 -1
- package/dist/{metadata-o_WH9V_I.d.ts → metadata-Bjfa88HQ.d.ts} +1 -1
- package/dist/{metadata-D6o-kLpg.d.cts → metadata-C74-XCrx.d.cts} +1 -1
- package/dist/model/node.d.cts +1 -1
- package/dist/model/node.d.ts +1 -1
- package/dist/model/package.d.cts +1 -1
- package/dist/model/package.d.ts +1 -1
- package/dist/{node-CkBWRjNR.d.cts → node-B6JX5CRX.d.cts} +1 -1
- package/dist/{node-CkBWRjNR.d.ts → node-B6JX5CRX.d.ts} +1 -1
- package/dist/{numbering-D0YfuiOO.d.ts → numbering-CUMTFxfk.d.ts} +1 -1
- package/dist/{numbering-C53LT-Jx.d.cts → numbering-vpq3iLPm.d.cts} +1 -1
- package/dist/{package-L24lkba-.d.cts → package-DMk9fuTI.d.cts} +1 -1
- package/dist/package-io/read.d.cts +1 -1
- package/dist/package-io/read.d.ts +1 -1
- package/dist/package-io/write.d.cts +1 -1
- package/dist/package-io/write.d.ts +1 -1
- package/dist/{package-BUojjTXf.d.ts → package-otZYrxiO.d.ts} +1 -1
- package/dist/{parse-A8_8sdpX.d.ts → parse-BLukZ2z0.d.ts} +1 -1
- package/dist/{parse-CP5FLZqv.d.cts → parse-DcVtB3jT.d.cts} +1 -1
- package/dist/{read-ZWJPDvG-.d.ts → read-B5kexLpc.d.ts} +1 -1
- package/dist/{read-DPR6ihXO.js → read-BZ_jycSX.js} +3 -1
- package/dist/{read-CevviAf2.d.ts → read-BlcKA9Cg.d.ts} +1 -1
- package/dist/{read-BoV9SZy4.d.cts → read-C1h_Q4kx.d.cts} +1 -1
- package/dist/{read-Cj23Gllx.cjs → read-CXksZHJW.cjs} +3 -1
- package/dist/{read-A9CC5Toq.d.cts → read-D6kQeo-T.d.cts} +1 -1
- package/dist/{read-DA55zDgD.d.ts → read-D_kXw2N2.d.ts} +1 -1
- package/dist/{read-VbRhmjOh.d.cts → read-uKN0paUP.d.cts} +1 -1
- package/dist/{sniff-DjpnUZRp.d.cts → sniff-DGOBHA0O.d.cts} +1 -1
- package/dist/{sniff-DjpnUZRp.d.ts → sniff-DGOBHA0O.d.ts} +1 -1
- package/dist/typed/document-tree.cjs +1 -1
- package/dist/typed/document-tree.d.cts +1 -1
- package/dist/typed/document-tree.d.ts +1 -1
- package/dist/typed/document-tree.js +1 -1
- package/dist/typed/docx/constructs.d.cts +3 -3
- package/dist/typed/docx/constructs.d.ts +3 -3
- package/dist/typed/docx/numbering.d.cts +1 -1
- package/dist/typed/docx/numbering.d.ts +1 -1
- package/dist/typed/docx/read.cjs +1 -1
- package/dist/typed/docx/read.d.cts +1 -1
- package/dist/typed/docx/read.d.ts +1 -1
- package/dist/typed/docx/read.js +1 -1
- package/dist/typed/docx/styles.d.cts +1 -1
- package/dist/typed/docx/styles.d.ts +1 -1
- package/dist/typed/docx/write.d.cts +1 -1
- package/dist/typed/docx/write.d.ts +1 -1
- package/dist/typed/embedded.cjs +1 -1
- package/dist/typed/embedded.d.cts +2 -2
- package/dist/typed/embedded.d.ts +2 -2
- package/dist/typed/embedded.js +1 -1
- package/dist/typed/pptx/chart.d.cts +1 -1
- package/dist/typed/pptx/chart.d.ts +1 -1
- package/dist/typed/pptx/diagram.d.cts +1 -1
- package/dist/typed/pptx/diagram.d.ts +1 -1
- package/dist/typed/pptx/inherit.d.cts +2 -2
- package/dist/typed/pptx/inherit.d.ts +2 -2
- package/dist/typed/pptx/read.cjs +1 -1
- package/dist/typed/pptx/read.d.cts +1 -1
- package/dist/typed/pptx/read.d.ts +1 -1
- package/dist/typed/pptx/read.js +1 -1
- package/dist/typed/shared/color.d.cts +1 -1
- package/dist/typed/shared/color.d.ts +1 -1
- package/dist/typed/shared/drawingml.d.cts +1 -1
- package/dist/typed/shared/drawingml.d.ts +1 -1
- package/dist/typed/shared/metadata.d.cts +1 -1
- package/dist/typed/shared/metadata.d.ts +1 -1
- package/dist/typed/util.d.cts +1 -1
- package/dist/typed/util.d.ts +1 -1
- package/dist/typed/xlsx/build.cjs +12 -4
- package/dist/typed/xlsx/build.d.cts +1 -1
- package/dist/typed/xlsx/build.d.ts +1 -1
- package/dist/typed/xlsx/build.js +12 -4
- package/dist/typed/xlsx/comments.d.cts +1 -1
- package/dist/typed/xlsx/comments.d.ts +1 -1
- package/dist/typed/xlsx/conditional-format.cjs +519 -0
- package/dist/typed/xlsx/conditional-format.d.cts +16 -0
- package/dist/typed/xlsx/conditional-format.d.ts +16 -0
- package/dist/typed/xlsx/conditional-format.js +516 -0
- package/dist/typed/xlsx/content.cjs +11 -7
- package/dist/typed/xlsx/content.d.cts +1 -1
- package/dist/typed/xlsx/content.d.ts +1 -1
- package/dist/typed/xlsx/content.js +12 -8
- package/dist/typed/xlsx/data-validation.cjs +116 -0
- package/dist/typed/xlsx/data-validation.d.cts +11 -0
- package/dist/typed/xlsx/data-validation.d.ts +11 -0
- package/dist/typed/xlsx/data-validation.js +114 -0
- package/dist/typed/xlsx/defined-names.d.cts +1 -1
- package/dist/typed/xlsx/defined-names.d.ts +1 -1
- package/dist/typed/xlsx/definitions.d.cts +1 -1
- package/dist/typed/xlsx/definitions.d.ts +1 -1
- package/dist/typed/xlsx/drawings.d.cts +2 -2
- package/dist/typed/xlsx/drawings.d.ts +2 -2
- package/dist/typed/xlsx/number-format.d.cts +14 -14
- package/dist/typed/xlsx/number-format.d.ts +14 -14
- package/dist/typed/xlsx/print-settings.d.cts +1 -1
- package/dist/typed/xlsx/print-settings.d.ts +1 -1
- package/dist/typed/xlsx/rule-residue.cjs +29 -0
- package/dist/typed/xlsx/rule-residue.d.cts +7 -0
- package/dist/typed/xlsx/rule-residue.d.ts +7 -0
- package/dist/typed/xlsx/rule-residue.js +27 -0
- package/dist/typed/xlsx/serial.d.cts +1 -1
- package/dist/typed/xlsx/serial.d.ts +1 -1
- package/dist/typed/xlsx/shared-strings.d.cts +1 -1
- package/dist/typed/xlsx/shared-strings.d.ts +1 -1
- package/dist/typed/xlsx/sqref.cjs +24 -0
- package/dist/typed/xlsx/sqref.d.cts +7 -0
- package/dist/typed/xlsx/sqref.d.ts +7 -0
- package/dist/typed/xlsx/sqref.js +21 -0
- package/dist/typed/xlsx/styles.cjs +14 -2
- package/dist/typed/xlsx/styles.d.cts +10 -6
- package/dist/typed/xlsx/styles.d.ts +10 -6
- package/dist/typed/xlsx/styles.js +12 -3
- package/dist/typed/xlsx.d.cts +1 -1
- package/dist/typed/xlsx.d.ts +1 -1
- package/dist/util/base64.cjs +4 -4
- package/dist/util/base64.js +4 -4
- package/dist/{util-DFe4UbvU.d.ts → util-DKrYuajM.d.ts} +2 -2
- package/dist/{util-M3JJlDhF.d.cts → util-xRsVgH-g.d.cts} +2 -2
- package/dist/{write-Dn_CL8qb.d.cts → write-BGTpp3RS.d.cts} +3 -3
- package/dist/{write-6JmxvaK5.d.cts → write-Ba1IxfDT.d.cts} +1 -1
- package/dist/{write-CT-EgVT7.d.ts → write-C4902scQ.d.ts} +1 -1
- package/dist/{write-inqdKHR3.d.ts → write-Cnfu3zdB.d.ts} +3 -3
- package/dist/{xlsx-DacFqZeF.d.ts → xlsx-B3JGnx0l.d.ts} +1 -1
- package/dist/{xlsx-CpX5nzGV.d.cts → xlsx-DCgJ8IbV.d.cts} +1 -1
- package/dist/xml/build.d.cts +1 -1
- package/dist/xml/build.d.ts +1 -1
- package/dist/xml/fragment.d.cts +1 -1
- package/dist/xml/fragment.d.ts +1 -1
- package/dist/xml/parse.d.cts +1 -1
- package/dist/xml/parse.d.ts +1 -1
- package/package.json +3 -11
package/dist/typed/util.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as elementsWithTag, c as textContent, i as decodeEntities, l as walk, n as attr, o as resolveRelationships, r as childrenWithTag, s as rootElement, t as Relationship } from "../util-
|
|
1
|
+
import { a as elementsWithTag, c as textContent, i as decodeEntities, l as walk, n as attr, o as resolveRelationships, r as childrenWithTag, s as rootElement, t as Relationship } from "../util-xRsVgH-g.cjs";
|
|
2
2
|
export { Relationship, attr, childrenWithTag, decodeEntities, elementsWithTag, resolveRelationships, rootElement, textContent, walk };
|
package/dist/typed/util.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as elementsWithTag, c as textContent, i as decodeEntities, l as walk, n as attr, o as resolveRelationships, r as childrenWithTag, s as rootElement, t as Relationship } from "../util-
|
|
1
|
+
import { a as elementsWithTag, c as textContent, i as decodeEntities, l as walk, n as attr, o as resolveRelationships, r as childrenWithTag, s as rootElement, t as Relationship } from "../util-DKrYuajM.js";
|
|
2
2
|
export { Relationship, attr, childrenWithTag, decodeEntities, elementsWithTag, resolveRelationships, rootElement, textContent, walk };
|
|
@@ -10,6 +10,8 @@ const require_typed_xlsx_units = require("./units.cjs");
|
|
|
10
10
|
const require_typed_xlsx_serial = require("./serial.cjs");
|
|
11
11
|
const require_typed_xlsx_shared_strings = require("./shared-strings.cjs");
|
|
12
12
|
const require_typed_xlsx_styles = require("./styles.cjs");
|
|
13
|
+
const require_typed_xlsx_conditional_format = require("./conditional-format.cjs");
|
|
14
|
+
const require_typed_xlsx_data_validation = require("./data-validation.cjs");
|
|
13
15
|
let document_schema_js = require("document-schema.js");
|
|
14
16
|
//#region src/typed/xlsx/build.ts
|
|
15
17
|
const SML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
@@ -184,7 +186,7 @@ function buildSharedStringsPart(sharedStrings) {
|
|
|
184
186
|
uniqueCount: String(entries.length)
|
|
185
187
|
}, siElements));
|
|
186
188
|
}
|
|
187
|
-
function buildStylesPart(cellFormats) {
|
|
189
|
+
function buildStylesPart(cellFormats, dxfTable) {
|
|
188
190
|
const children = [];
|
|
189
191
|
const declarations = cellFormats.declarations();
|
|
190
192
|
if (declarations.length > 0) {
|
|
@@ -250,6 +252,8 @@ function buildStylesPart(cellFormats) {
|
|
|
250
252
|
xfId: "0",
|
|
251
253
|
builtinId: "0"
|
|
252
254
|
})]));
|
|
255
|
+
const dxfElements = dxfTable.dxfElements();
|
|
256
|
+
if (dxfElements.length > 0) children.push(require_xml_fragment.el("dxfs", { count: String(dxfElements.length) }, [...dxfElements]));
|
|
253
257
|
return xmlPart(require_xml_fragment.el("styleSheet", { xmlns: SML_NS }, children));
|
|
254
258
|
}
|
|
255
259
|
function buildCorePropertiesPart(metadata) {
|
|
@@ -488,13 +492,16 @@ function buildBreaksElements(settings) {
|
|
|
488
492
|
}
|
|
489
493
|
return result;
|
|
490
494
|
}
|
|
491
|
-
function buildWorksheetPart(sheet, sharedStrings, cellFormats) {
|
|
495
|
+
function buildWorksheetPart(sheet, sharedStrings, cellFormats, dxfTable) {
|
|
492
496
|
const children = [buildSheetPrElement(sheet.printSettings), require_xml_fragment.el("dimension", { ref: computeDimension(sheet) })];
|
|
493
497
|
const colsElement = buildColsElement(sheet.columns);
|
|
494
498
|
if (colsElement !== void 0) children.push(colsElement);
|
|
495
499
|
children.push(buildSheetDataElement(sheet, sharedStrings, cellFormats));
|
|
496
500
|
const mergeCellsElement = buildMergeCellsElement(sheet.cells);
|
|
497
501
|
if (mergeCellsElement !== void 0) children.push(mergeCellsElement);
|
|
502
|
+
children.push(...require_typed_xlsx_conditional_format.buildConditionalFormattingElements(sheet.conditionalFormats ?? [], dxfTable));
|
|
503
|
+
const dataValidationsElement = require_typed_xlsx_data_validation.buildDataValidationsElement(sheet.dataValidations ?? []);
|
|
504
|
+
if (dataValidationsElement !== void 0) children.push(dataValidationsElement);
|
|
498
505
|
children.push(buildPrintOptionsElement(sheet.printSettings), buildPageMarginsElement(sheet.printSettings), buildPageSetupElement(sheet.printSettings));
|
|
499
506
|
const { rowBreaks, colBreaks } = buildBreaksElements(sheet.printSettings);
|
|
500
507
|
if (rowBreaks !== void 0) children.push(rowBreaks);
|
|
@@ -509,13 +516,14 @@ function buildXlsxPackageFromContent(document) {
|
|
|
509
516
|
const sheets = document.sheets;
|
|
510
517
|
const sharedStrings = new require_typed_xlsx_shared_strings.SharedStringTable();
|
|
511
518
|
const cellFormats = new require_typed_xlsx_styles.CellFormatTable();
|
|
512
|
-
const
|
|
519
|
+
const dxfTable = new require_typed_xlsx_conditional_format.DxfTable();
|
|
520
|
+
const worksheetParts = sheets.map((sheet) => buildWorksheetPart(sheet, sharedStrings, cellFormats, dxfTable));
|
|
513
521
|
const parts = {
|
|
514
522
|
"[Content_Types].xml": buildContentTypesPart(sheets.length),
|
|
515
523
|
"_rels/.rels": buildPackageRelsPart(),
|
|
516
524
|
"xl/workbook.xml": buildWorkbookPart(sheets),
|
|
517
525
|
"xl/_rels/workbook.xml.rels": buildWorkbookRelsPart(sheets.length),
|
|
518
|
-
"xl/styles.xml": buildStylesPart(cellFormats),
|
|
526
|
+
"xl/styles.xml": buildStylesPart(cellFormats, dxfTable),
|
|
519
527
|
"xl/sharedStrings.xml": buildSharedStringsPart(sharedStrings),
|
|
520
528
|
"docProps/core.xml": buildCorePropertiesPart(document.metadata),
|
|
521
529
|
"docProps/app.xml": buildAppPropertiesPart(document.metadata)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as buildXlsxPackageFromContent } from "../../build-
|
|
1
|
+
import { t as buildXlsxPackageFromContent } from "../../build-BY9Mn-4K.cjs";
|
|
2
2
|
export { buildXlsxPackageFromContent };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as buildXlsxPackageFromContent } from "../../build-
|
|
1
|
+
import { t as buildXlsxPackageFromContent } from "../../build-BOI7rIog.js";
|
|
2
2
|
export { buildXlsxPackageFromContent };
|
package/dist/typed/xlsx/build.js
CHANGED
|
@@ -9,6 +9,8 @@ import { ptToColumnWidthChars } from "./units.js";
|
|
|
9
9
|
import { isoDateTimeToSerial, isoDateToSerial, isoTimeToSerial } from "./serial.js";
|
|
10
10
|
import { SharedStringTable } from "./shared-strings.js";
|
|
11
11
|
import { CellFormatTable, RESERVED_BORDER_INDICES, RESERVED_FILL_INDICES } from "./styles.js";
|
|
12
|
+
import { DxfTable, buildConditionalFormattingElements } from "./conditional-format.js";
|
|
13
|
+
import { buildDataValidationsElement } from "./data-validation.js";
|
|
12
14
|
import { cellReference, rangeReference } from "document-schema.js";
|
|
13
15
|
//#region src/typed/xlsx/build.ts
|
|
14
16
|
const SML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
@@ -183,7 +185,7 @@ function buildSharedStringsPart(sharedStrings) {
|
|
|
183
185
|
uniqueCount: String(entries.length)
|
|
184
186
|
}, siElements));
|
|
185
187
|
}
|
|
186
|
-
function buildStylesPart(cellFormats) {
|
|
188
|
+
function buildStylesPart(cellFormats, dxfTable) {
|
|
187
189
|
const children = [];
|
|
188
190
|
const declarations = cellFormats.declarations();
|
|
189
191
|
if (declarations.length > 0) {
|
|
@@ -249,6 +251,8 @@ function buildStylesPart(cellFormats) {
|
|
|
249
251
|
xfId: "0",
|
|
250
252
|
builtinId: "0"
|
|
251
253
|
})]));
|
|
254
|
+
const dxfElements = dxfTable.dxfElements();
|
|
255
|
+
if (dxfElements.length > 0) children.push(el("dxfs", { count: String(dxfElements.length) }, [...dxfElements]));
|
|
252
256
|
return xmlPart(el("styleSheet", { xmlns: SML_NS }, children));
|
|
253
257
|
}
|
|
254
258
|
function buildCorePropertiesPart(metadata) {
|
|
@@ -487,13 +491,16 @@ function buildBreaksElements(settings) {
|
|
|
487
491
|
}
|
|
488
492
|
return result;
|
|
489
493
|
}
|
|
490
|
-
function buildWorksheetPart(sheet, sharedStrings, cellFormats) {
|
|
494
|
+
function buildWorksheetPart(sheet, sharedStrings, cellFormats, dxfTable) {
|
|
491
495
|
const children = [buildSheetPrElement(sheet.printSettings), el("dimension", { ref: computeDimension(sheet) })];
|
|
492
496
|
const colsElement = buildColsElement(sheet.columns);
|
|
493
497
|
if (colsElement !== void 0) children.push(colsElement);
|
|
494
498
|
children.push(buildSheetDataElement(sheet, sharedStrings, cellFormats));
|
|
495
499
|
const mergeCellsElement = buildMergeCellsElement(sheet.cells);
|
|
496
500
|
if (mergeCellsElement !== void 0) children.push(mergeCellsElement);
|
|
501
|
+
children.push(...buildConditionalFormattingElements(sheet.conditionalFormats ?? [], dxfTable));
|
|
502
|
+
const dataValidationsElement = buildDataValidationsElement(sheet.dataValidations ?? []);
|
|
503
|
+
if (dataValidationsElement !== void 0) children.push(dataValidationsElement);
|
|
497
504
|
children.push(buildPrintOptionsElement(sheet.printSettings), buildPageMarginsElement(sheet.printSettings), buildPageSetupElement(sheet.printSettings));
|
|
498
505
|
const { rowBreaks, colBreaks } = buildBreaksElements(sheet.printSettings);
|
|
499
506
|
if (rowBreaks !== void 0) children.push(rowBreaks);
|
|
@@ -508,13 +515,14 @@ function buildXlsxPackageFromContent(document) {
|
|
|
508
515
|
const sheets = document.sheets;
|
|
509
516
|
const sharedStrings = new SharedStringTable();
|
|
510
517
|
const cellFormats = new CellFormatTable();
|
|
511
|
-
const
|
|
518
|
+
const dxfTable = new DxfTable();
|
|
519
|
+
const worksheetParts = sheets.map((sheet) => buildWorksheetPart(sheet, sharedStrings, cellFormats, dxfTable));
|
|
512
520
|
const parts = {
|
|
513
521
|
"[Content_Types].xml": buildContentTypesPart(sheets.length),
|
|
514
522
|
"_rels/.rels": buildPackageRelsPart(),
|
|
515
523
|
"xl/workbook.xml": buildWorkbookPart(sheets),
|
|
516
524
|
"xl/_rels/workbook.xml.rels": buildWorkbookRelsPart(sheets.length),
|
|
517
|
-
"xl/styles.xml": buildStylesPart(cellFormats),
|
|
525
|
+
"xl/styles.xml": buildStylesPart(cellFormats, dxfTable),
|
|
518
526
|
"xl/sharedStrings.xml": buildSharedStringsPart(sharedStrings),
|
|
519
527
|
"docProps/core.xml": buildCorePropertiesPart(document.metadata),
|
|
520
528
|
"docProps/app.xml": buildAppPropertiesPart(document.metadata)
|
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_parse = require("../../xml/parse.cjs");
|
|
3
|
+
const require_xml_build = require("../../xml/build.cjs");
|
|
4
|
+
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
5
|
+
const require_xml_entities = require("../../xml/entities.cjs");
|
|
6
|
+
const require_typed_util = require("../util.cjs");
|
|
7
|
+
const require_typed_xlsx_util = require("./util.cjs");
|
|
8
|
+
const require_typed_xlsx_styles = require("./styles.cjs");
|
|
9
|
+
const require_typed_xlsx_rule_residue = require("./rule-residue.cjs");
|
|
10
|
+
const require_typed_xlsx_sqref = require("./sqref.cjs");
|
|
11
|
+
let document_schema_js = require("document-schema.js");
|
|
12
|
+
//#region src/typed/xlsx/conditional-format.ts
|
|
13
|
+
const CF_RULE_MANAGED_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
14
|
+
"type",
|
|
15
|
+
"dxfId",
|
|
16
|
+
"priority",
|
|
17
|
+
"stopIfTrue",
|
|
18
|
+
"operator",
|
|
19
|
+
"text",
|
|
20
|
+
"rank",
|
|
21
|
+
"percent",
|
|
22
|
+
"bottom",
|
|
23
|
+
"aboveAverage",
|
|
24
|
+
"equalAverage",
|
|
25
|
+
"stdDev",
|
|
26
|
+
"timePeriod",
|
|
27
|
+
"iconSet",
|
|
28
|
+
"reverse",
|
|
29
|
+
"showValue"
|
|
30
|
+
]);
|
|
31
|
+
function readConditionalFormats(worksheet, dxfs) {
|
|
32
|
+
const formats = [];
|
|
33
|
+
const residueElements = [];
|
|
34
|
+
for (const wrapper of require_typed_util.childrenWithTag(worksheet, "conditionalFormatting")) {
|
|
35
|
+
const ranges = require_typed_xlsx_sqref.parseSqref(require_typed_util.attr(wrapper, "sqref"));
|
|
36
|
+
for (const cfRule of require_typed_util.childrenWithTag(wrapper, "cfRule")) {
|
|
37
|
+
const promoted = ranges.length === 0 ? void 0 : readCfRule(cfRule, ranges, dxfs);
|
|
38
|
+
if (promoted === void 0) {
|
|
39
|
+
residueElements.push({
|
|
40
|
+
type: "element",
|
|
41
|
+
tag: "conditionalFormatting",
|
|
42
|
+
attributes: wrapper.attributes,
|
|
43
|
+
children: [cfRule]
|
|
44
|
+
});
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
formats.push(promoted);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
formats,
|
|
52
|
+
residueElements
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function readCommonFields(cfRule, ranges) {
|
|
56
|
+
const result = { ranges: [...ranges] };
|
|
57
|
+
const priorityRaw = require_typed_util.attr(cfRule, "priority");
|
|
58
|
+
if (priorityRaw !== void 0) {
|
|
59
|
+
const priority = Number.parseInt(priorityRaw, 10);
|
|
60
|
+
if (Number.isInteger(priority)) result.priority = priority;
|
|
61
|
+
}
|
|
62
|
+
if (require_typed_xlsx_util.readXmlBool(require_typed_util.attr(cfRule, "stopIfTrue"))) result.stopIfTrue = true;
|
|
63
|
+
const source = require_typed_xlsx_rule_residue.captureResidualAttributes(cfRule, CF_RULE_MANAGED_ATTRIBUTES);
|
|
64
|
+
if (source !== void 0) result.source = source;
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
function readFormula(cfRule, index) {
|
|
68
|
+
const formulaEl = require_typed_util.childrenWithTag(cfRule, "formula")[index];
|
|
69
|
+
return formulaEl === void 0 ? void 0 : require_typed_util.textContent(formulaEl);
|
|
70
|
+
}
|
|
71
|
+
function isSheetRuleOperator(value) {
|
|
72
|
+
return value === "between" || value === "notBetween" || value === "equal" || value === "notEqual" || value === "greaterThan" || value === "greaterThanOrEqual" || value === "lessThan" || value === "lessThanOrEqual";
|
|
73
|
+
}
|
|
74
|
+
const TEXT_PREDICATE_TYPES = /* @__PURE__ */ new Set([
|
|
75
|
+
"containsText",
|
|
76
|
+
"notContainsText",
|
|
77
|
+
"beginsWith",
|
|
78
|
+
"endsWith"
|
|
79
|
+
]);
|
|
80
|
+
function isTextPredicateType(value) {
|
|
81
|
+
return value !== void 0 && TEXT_PREDICATE_TYPES.has(value);
|
|
82
|
+
}
|
|
83
|
+
const OPERAND_FREE_TYPES = /* @__PURE__ */ new Set([
|
|
84
|
+
"containsBlanks",
|
|
85
|
+
"notContainsBlanks",
|
|
86
|
+
"containsErrors",
|
|
87
|
+
"notContainsErrors",
|
|
88
|
+
"uniqueValues",
|
|
89
|
+
"duplicateValues"
|
|
90
|
+
]);
|
|
91
|
+
function isOperandFreeType(value) {
|
|
92
|
+
return value !== void 0 && OPERAND_FREE_TYPES.has(value);
|
|
93
|
+
}
|
|
94
|
+
const TIME_PERIODS = /* @__PURE__ */ new Set([
|
|
95
|
+
"yesterday",
|
|
96
|
+
"today",
|
|
97
|
+
"tomorrow",
|
|
98
|
+
"last7Days",
|
|
99
|
+
"thisMonth",
|
|
100
|
+
"lastMonth",
|
|
101
|
+
"nextMonth",
|
|
102
|
+
"thisWeek",
|
|
103
|
+
"lastWeek",
|
|
104
|
+
"nextWeek"
|
|
105
|
+
]);
|
|
106
|
+
function isTimePeriod(value) {
|
|
107
|
+
return value !== void 0 && TIME_PERIODS.has(value);
|
|
108
|
+
}
|
|
109
|
+
function isCfvoType(value) {
|
|
110
|
+
return value === "num" || value === "percent" || value === "max" || value === "min" || value === "formula" || value === "percentile";
|
|
111
|
+
}
|
|
112
|
+
function readCfvo(cfvoEl) {
|
|
113
|
+
const type = require_typed_util.attr(cfvoEl, "type");
|
|
114
|
+
if (!isCfvoType(type)) return;
|
|
115
|
+
if (type === "min" || type === "max") return { type };
|
|
116
|
+
const valRaw = require_typed_util.attr(cfvoEl, "val");
|
|
117
|
+
if (valRaw === void 0) return;
|
|
118
|
+
return {
|
|
119
|
+
type,
|
|
120
|
+
value: require_typed_util.decodeEntities(valRaw)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function readColorScaleStops(colorScaleEl) {
|
|
124
|
+
const cfvoEls = require_typed_util.childrenWithTag(colorScaleEl, "cfvo");
|
|
125
|
+
const colorEls = require_typed_util.childrenWithTag(colorScaleEl, "color");
|
|
126
|
+
if (cfvoEls.length !== colorEls.length || cfvoEls.length < 2 || cfvoEls.length > 3) return;
|
|
127
|
+
const stops = [];
|
|
128
|
+
for (let index = 0; index < cfvoEls.length; index++) {
|
|
129
|
+
const cfvoEl = cfvoEls[index];
|
|
130
|
+
const colorEl = colorEls[index];
|
|
131
|
+
if (cfvoEl === void 0 || colorEl === void 0) return;
|
|
132
|
+
const value = readCfvo(cfvoEl);
|
|
133
|
+
const color = require_typed_xlsx_styles.colorFromElement(colorEl);
|
|
134
|
+
if (value === void 0 || color === void 0) return;
|
|
135
|
+
stops.push({
|
|
136
|
+
value,
|
|
137
|
+
color
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return stops;
|
|
141
|
+
}
|
|
142
|
+
function readDataBar(dataBarEl) {
|
|
143
|
+
const cfvoEls = require_typed_util.childrenWithTag(dataBarEl, "cfvo");
|
|
144
|
+
const minEl = cfvoEls[0];
|
|
145
|
+
const maxEl = cfvoEls[1];
|
|
146
|
+
const min = minEl === void 0 ? void 0 : readCfvo(minEl);
|
|
147
|
+
const max = maxEl === void 0 ? void 0 : readCfvo(maxEl);
|
|
148
|
+
const color = require_typed_xlsx_styles.colorFromElement(require_typed_util.childrenWithTag(dataBarEl, "color")[0]);
|
|
149
|
+
if (min === void 0 || max === void 0 || color === void 0) return;
|
|
150
|
+
const result = {
|
|
151
|
+
min,
|
|
152
|
+
max,
|
|
153
|
+
color
|
|
154
|
+
};
|
|
155
|
+
const showValueRaw = require_typed_util.attr(dataBarEl, "showValue");
|
|
156
|
+
if (showValueRaw !== void 0 && !require_typed_xlsx_util.readXmlBool(showValueRaw)) result.showValue = false;
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
const DEFAULT_ICON_SET_TYPE = "3TrafficLights1";
|
|
160
|
+
function readIconSet(iconSetEl) {
|
|
161
|
+
const thresholds = [];
|
|
162
|
+
for (const cfvoEl of require_typed_util.childrenWithTag(iconSetEl, "cfvo")) {
|
|
163
|
+
const value = readCfvo(cfvoEl);
|
|
164
|
+
if (value === void 0) return;
|
|
165
|
+
thresholds.push(value);
|
|
166
|
+
}
|
|
167
|
+
if (thresholds.length === 0) return;
|
|
168
|
+
const result = {
|
|
169
|
+
iconSetType: require_typed_util.attr(iconSetEl, "iconSet") ?? DEFAULT_ICON_SET_TYPE,
|
|
170
|
+
thresholds
|
|
171
|
+
};
|
|
172
|
+
if (require_typed_xlsx_util.readXmlBool(require_typed_util.attr(iconSetEl, "reverse"))) result.reverse = true;
|
|
173
|
+
const showValueRaw = require_typed_util.attr(iconSetEl, "showValue");
|
|
174
|
+
if (showValueRaw !== void 0 && !require_typed_xlsx_util.readXmlBool(showValueRaw)) result.showValue = false;
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
function styleFromDxf(dxf) {
|
|
178
|
+
const fontEl = require_typed_util.childrenWithTag(dxf, "font")[0];
|
|
179
|
+
const textColor = fontEl === void 0 ? void 0 : require_typed_xlsx_styles.readColorRgb(fontEl, "color");
|
|
180
|
+
const fillEl = require_typed_util.childrenWithTag(dxf, "fill")[0];
|
|
181
|
+
const patternFillEl = fillEl === void 0 ? void 0 : require_typed_util.childrenWithTag(fillEl, "patternFill")[0];
|
|
182
|
+
const background = patternFillEl === void 0 ? void 0 : require_typed_xlsx_styles.readColorRgb(patternFillEl, "bgColor");
|
|
183
|
+
const residueChildren = dxfResidueChildren(dxf, textColor !== void 0, background !== void 0);
|
|
184
|
+
const style = {};
|
|
185
|
+
if (textColor !== void 0) style.textColor = textColor;
|
|
186
|
+
if (background !== void 0) style.background = background;
|
|
187
|
+
if (residueChildren.length > 0) style.source = {
|
|
188
|
+
format: "xlsx",
|
|
189
|
+
xml: require_xml_build.buildXml(residueChildren)
|
|
190
|
+
};
|
|
191
|
+
return style.textColor === void 0 && style.background === void 0 && style.source === void 0 ? void 0 : style;
|
|
192
|
+
}
|
|
193
|
+
function withoutChildTag(element, tag) {
|
|
194
|
+
const remaining = element.children.filter((child) => !(child.type === "element" && child.tag === tag));
|
|
195
|
+
if (remaining.length === 0 && element.attributes.length === 0) return;
|
|
196
|
+
return {
|
|
197
|
+
...element,
|
|
198
|
+
children: remaining
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function fillResidue(fillEl) {
|
|
202
|
+
const patternFillEl = require_typed_util.childrenWithTag(fillEl, "patternFill")[0];
|
|
203
|
+
const otherFillChildren = fillEl.children.filter((child) => !(child.type === "element" && child.tag === "patternFill"));
|
|
204
|
+
if (patternFillEl === void 0) return otherFillChildren.length === 0 && fillEl.attributes.length === 0 ? void 0 : {
|
|
205
|
+
...fillEl,
|
|
206
|
+
children: otherFillChildren
|
|
207
|
+
};
|
|
208
|
+
const patternFillResidue = withoutChildTag(patternFillEl, "bgColor");
|
|
209
|
+
if (patternFillResidue === void 0) return otherFillChildren.length === 0 && fillEl.attributes.length === 0 ? void 0 : {
|
|
210
|
+
...fillEl,
|
|
211
|
+
children: otherFillChildren
|
|
212
|
+
};
|
|
213
|
+
return {
|
|
214
|
+
...fillEl,
|
|
215
|
+
children: [patternFillResidue, ...otherFillChildren]
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function dxfResidueChildren(dxf, textColorCaptured, backgroundCaptured) {
|
|
219
|
+
const residue = [];
|
|
220
|
+
for (const child of dxf.children) {
|
|
221
|
+
if (child.type !== "element") continue;
|
|
222
|
+
if (child.tag === "font" && textColorCaptured) {
|
|
223
|
+
const remainder = withoutChildTag(child, "color");
|
|
224
|
+
if (remainder !== void 0) residue.push(remainder);
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (child.tag === "fill" && backgroundCaptured) {
|
|
228
|
+
const remainder = fillResidue(child);
|
|
229
|
+
if (remainder !== void 0) residue.push(remainder);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
residue.push(child);
|
|
233
|
+
}
|
|
234
|
+
return residue;
|
|
235
|
+
}
|
|
236
|
+
function resolveStyle(cfRule, dxfs) {
|
|
237
|
+
const dxfIdRaw = require_typed_util.attr(cfRule, "dxfId");
|
|
238
|
+
if (dxfIdRaw === void 0) return;
|
|
239
|
+
const dxfId = Number.parseInt(dxfIdRaw, 10);
|
|
240
|
+
const dxf = Number.isInteger(dxfId) ? dxfs[dxfId] : void 0;
|
|
241
|
+
return dxf === void 0 ? void 0 : styleFromDxf(dxf);
|
|
242
|
+
}
|
|
243
|
+
function readCfRule(cfRule, ranges, dxfs) {
|
|
244
|
+
const type = require_typed_util.attr(cfRule, "type");
|
|
245
|
+
const common = readCommonFields(cfRule, ranges);
|
|
246
|
+
const style = resolveStyle(cfRule, dxfs);
|
|
247
|
+
const styleField = style === void 0 ? {} : { style };
|
|
248
|
+
if (type === "cellIs") {
|
|
249
|
+
const operatorRaw = require_typed_util.attr(cfRule, "operator");
|
|
250
|
+
const formula1 = readFormula(cfRule, 0);
|
|
251
|
+
if (!isSheetRuleOperator(operatorRaw) || formula1 === void 0) return;
|
|
252
|
+
const formula2 = operatorRaw === "between" || operatorRaw === "notBetween" ? readFormula(cfRule, 1) : void 0;
|
|
253
|
+
return {
|
|
254
|
+
type: "cellIs",
|
|
255
|
+
...common,
|
|
256
|
+
operator: operatorRaw,
|
|
257
|
+
formula1,
|
|
258
|
+
...formula2 === void 0 ? {} : { formula2 },
|
|
259
|
+
...styleField
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
if (isTextPredicateType(type)) {
|
|
263
|
+
const text = require_typed_util.attr(cfRule, "text");
|
|
264
|
+
if (text === void 0) return;
|
|
265
|
+
return {
|
|
266
|
+
type,
|
|
267
|
+
...common,
|
|
268
|
+
text: require_typed_util.decodeEntities(text),
|
|
269
|
+
...styleField
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
if (isOperandFreeType(type)) return {
|
|
273
|
+
type,
|
|
274
|
+
...common,
|
|
275
|
+
...styleField
|
|
276
|
+
};
|
|
277
|
+
if (type === "top10") {
|
|
278
|
+
const rankRaw = require_typed_util.attr(cfRule, "rank");
|
|
279
|
+
const rank = rankRaw === void 0 ? void 0 : Number(rankRaw);
|
|
280
|
+
if (rank === void 0 || !Number.isFinite(rank) || rank <= 0) return;
|
|
281
|
+
return {
|
|
282
|
+
type: "top10",
|
|
283
|
+
...common,
|
|
284
|
+
rank,
|
|
285
|
+
...require_typed_xlsx_util.readXmlBool(require_typed_util.attr(cfRule, "percent")) ? { percent: true } : {},
|
|
286
|
+
...require_typed_xlsx_util.readXmlBool(require_typed_util.attr(cfRule, "bottom")) ? { bottom: true } : {},
|
|
287
|
+
...styleField
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
if (type === "aboveAverage") {
|
|
291
|
+
const aboveAverageRaw = require_typed_util.attr(cfRule, "aboveAverage");
|
|
292
|
+
const stdDevRaw = require_typed_util.attr(cfRule, "stdDev");
|
|
293
|
+
const stdDev = stdDevRaw === void 0 ? void 0 : Number.parseInt(stdDevRaw, 10);
|
|
294
|
+
return {
|
|
295
|
+
type: "aboveAverage",
|
|
296
|
+
...common,
|
|
297
|
+
...aboveAverageRaw !== void 0 && !require_typed_xlsx_util.readXmlBool(aboveAverageRaw) ? { aboveAverage: false } : {},
|
|
298
|
+
...require_typed_xlsx_util.readXmlBool(require_typed_util.attr(cfRule, "equalAverage")) ? { equalAverage: true } : {},
|
|
299
|
+
...stdDev !== void 0 && Number.isInteger(stdDev) && stdDev > 0 ? { stdDev } : {},
|
|
300
|
+
...styleField
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
if (type === "timePeriod") {
|
|
304
|
+
const timePeriod = require_typed_util.attr(cfRule, "timePeriod");
|
|
305
|
+
if (!isTimePeriod(timePeriod)) return;
|
|
306
|
+
return {
|
|
307
|
+
type: "timePeriod",
|
|
308
|
+
...common,
|
|
309
|
+
timePeriod,
|
|
310
|
+
...styleField
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
if (type === "colorScale") {
|
|
314
|
+
const colorScaleEl = require_typed_util.childrenWithTag(cfRule, "colorScale")[0];
|
|
315
|
+
const stops = colorScaleEl === void 0 ? void 0 : readColorScaleStops(colorScaleEl);
|
|
316
|
+
if (stops === void 0) return;
|
|
317
|
+
return {
|
|
318
|
+
type: "colorScale",
|
|
319
|
+
...common,
|
|
320
|
+
stops
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
if (type === "dataBar") {
|
|
324
|
+
const dataBarEl = require_typed_util.childrenWithTag(cfRule, "dataBar")[0];
|
|
325
|
+
const parsed = dataBarEl === void 0 ? void 0 : readDataBar(dataBarEl);
|
|
326
|
+
if (parsed === void 0) return;
|
|
327
|
+
return {
|
|
328
|
+
type: "dataBar",
|
|
329
|
+
...common,
|
|
330
|
+
min: parsed.min,
|
|
331
|
+
max: parsed.max,
|
|
332
|
+
color: parsed.color,
|
|
333
|
+
...parsed.showValue === void 0 ? {} : { showValue: parsed.showValue }
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
if (type === "iconSet") {
|
|
337
|
+
const iconSetEl = require_typed_util.childrenWithTag(cfRule, "iconSet")[0];
|
|
338
|
+
const parsed = iconSetEl === void 0 ? void 0 : readIconSet(iconSetEl);
|
|
339
|
+
if (parsed === void 0) return;
|
|
340
|
+
return {
|
|
341
|
+
type: "iconSet",
|
|
342
|
+
...common,
|
|
343
|
+
iconSetType: parsed.iconSetType,
|
|
344
|
+
thresholds: parsed.thresholds,
|
|
345
|
+
...parsed.reverse === void 0 ? {} : { reverse: parsed.reverse },
|
|
346
|
+
...parsed.showValue === void 0 ? {} : { showValue: parsed.showValue }
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
var DxfTable = class {
|
|
351
|
+
elements = [];
|
|
352
|
+
intern(style) {
|
|
353
|
+
const index = this.elements.length;
|
|
354
|
+
this.elements.push(buildDxfElement(style));
|
|
355
|
+
return index;
|
|
356
|
+
}
|
|
357
|
+
dxfElements() {
|
|
358
|
+
return this.elements;
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
function attrsRecord(attributes) {
|
|
362
|
+
const result = {};
|
|
363
|
+
for (const attribute of attributes) result[attribute.name] = attribute.value;
|
|
364
|
+
return result;
|
|
365
|
+
}
|
|
366
|
+
function extractResidueElements(source) {
|
|
367
|
+
if (source?.format !== "xlsx") return [];
|
|
368
|
+
const elements = [];
|
|
369
|
+
for (const node of require_xml_parse.parseXml(source.xml)) if (node.type === "element") elements.push(node);
|
|
370
|
+
return elements;
|
|
371
|
+
}
|
|
372
|
+
function buildDxfElement(style) {
|
|
373
|
+
const residueByTag = /* @__PURE__ */ new Map();
|
|
374
|
+
for (const element of extractResidueElements(style.source)) residueByTag.set(element.tag, element);
|
|
375
|
+
const children = [];
|
|
376
|
+
const residualFont = residueByTag.get("font");
|
|
377
|
+
if (style.textColor !== void 0) {
|
|
378
|
+
const fontChildren = residualFont === void 0 ? [] : residualFont.children;
|
|
379
|
+
const fontAttrs = residualFont === void 0 ? {} : attrsRecord(residualFont.attributes);
|
|
380
|
+
children.push(require_xml_fragment.el("font", fontAttrs, [...fontChildren, require_xml_fragment.el("color", { rgb: `FF${(0, document_schema_js.colorToRgbHex)(style.textColor)}` })]));
|
|
381
|
+
} else if (residualFont !== void 0) children.push(residualFont);
|
|
382
|
+
const residualNumFmt = residueByTag.get("numFmt");
|
|
383
|
+
if (residualNumFmt !== void 0) children.push(residualNumFmt);
|
|
384
|
+
const residualFill = residueByTag.get("fill");
|
|
385
|
+
if (style.background !== void 0) {
|
|
386
|
+
const residualPatternFill = residualFill === void 0 ? void 0 : require_typed_util.childrenWithTag(residualFill, "patternFill")[0];
|
|
387
|
+
const patternFillChildren = residualPatternFill === void 0 ? [] : residualPatternFill.children;
|
|
388
|
+
const patternFillAttrs = residualPatternFill === void 0 ? {} : attrsRecord(residualPatternFill.attributes);
|
|
389
|
+
const otherFillChildren = residualFill === void 0 ? [] : residualFill.children.filter((child) => !(child.type === "element" && child.tag === "patternFill"));
|
|
390
|
+
children.push(require_xml_fragment.el("fill", residualFill === void 0 ? {} : attrsRecord(residualFill.attributes), [require_xml_fragment.el("patternFill", patternFillAttrs, [...patternFillChildren, require_xml_fragment.el("bgColor", { rgb: `FF${(0, document_schema_js.colorToRgbHex)(style.background)}` })]), ...otherFillChildren]));
|
|
391
|
+
} else if (residualFill !== void 0) children.push(residualFill);
|
|
392
|
+
for (const tag of [
|
|
393
|
+
"alignment",
|
|
394
|
+
"border",
|
|
395
|
+
"protection"
|
|
396
|
+
]) {
|
|
397
|
+
const residual = residueByTag.get(tag);
|
|
398
|
+
if (residual !== void 0) children.push(residual);
|
|
399
|
+
}
|
|
400
|
+
return require_xml_fragment.el("dxf", {}, children);
|
|
401
|
+
}
|
|
402
|
+
function rangeSetKey(ranges) {
|
|
403
|
+
return ranges.map((range) => `${range.startRow}:${range.startColumn}:${range.endRow}:${range.endColumn}`).join("|");
|
|
404
|
+
}
|
|
405
|
+
const TEXT_PREDICATE_OPERATOR = {
|
|
406
|
+
containsText: "containsText",
|
|
407
|
+
notContainsText: "notContains",
|
|
408
|
+
beginsWith: "beginsWith",
|
|
409
|
+
endsWith: "endsWith"
|
|
410
|
+
};
|
|
411
|
+
function buildCfvoElement(value) {
|
|
412
|
+
const attrs = { type: value.type };
|
|
413
|
+
if (value.value !== void 0) attrs.val = require_xml_entities.encodeXmlText(value.value);
|
|
414
|
+
return require_xml_fragment.el("cfvo", attrs);
|
|
415
|
+
}
|
|
416
|
+
function buildCfRuleElement(rule, priority, dxfTable) {
|
|
417
|
+
const attrs = require_typed_xlsx_rule_residue.residualAttributesFor(rule.source, "cfRule");
|
|
418
|
+
attrs.type = rule.type;
|
|
419
|
+
attrs.priority = String(priority);
|
|
420
|
+
if (rule.stopIfTrue === true) attrs.stopIfTrue = require_typed_xlsx_util.writeXmlBool(true);
|
|
421
|
+
const children = [];
|
|
422
|
+
let style;
|
|
423
|
+
switch (rule.type) {
|
|
424
|
+
case "cellIs":
|
|
425
|
+
attrs.operator = rule.operator;
|
|
426
|
+
children.push(require_xml_fragment.el("formula", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(rule.formula1))]));
|
|
427
|
+
if (rule.formula2 !== void 0) children.push(require_xml_fragment.el("formula", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(rule.formula2))]));
|
|
428
|
+
style = rule.style;
|
|
429
|
+
break;
|
|
430
|
+
case "containsText":
|
|
431
|
+
case "notContainsText":
|
|
432
|
+
case "beginsWith":
|
|
433
|
+
case "endsWith":
|
|
434
|
+
attrs.operator = TEXT_PREDICATE_OPERATOR[rule.type];
|
|
435
|
+
attrs.text = require_xml_entities.encodeXmlText(rule.text);
|
|
436
|
+
style = rule.style;
|
|
437
|
+
break;
|
|
438
|
+
case "containsBlanks":
|
|
439
|
+
case "notContainsBlanks":
|
|
440
|
+
case "containsErrors":
|
|
441
|
+
case "notContainsErrors":
|
|
442
|
+
case "uniqueValues":
|
|
443
|
+
case "duplicateValues":
|
|
444
|
+
style = rule.style;
|
|
445
|
+
break;
|
|
446
|
+
case "top10":
|
|
447
|
+
attrs.rank = String(rule.rank);
|
|
448
|
+
if (rule.percent === true) attrs.percent = require_typed_xlsx_util.writeXmlBool(true);
|
|
449
|
+
if (rule.bottom === true) attrs.bottom = require_typed_xlsx_util.writeXmlBool(true);
|
|
450
|
+
style = rule.style;
|
|
451
|
+
break;
|
|
452
|
+
case "aboveAverage":
|
|
453
|
+
if (rule.aboveAverage === false) attrs.aboveAverage = require_typed_xlsx_util.writeXmlBool(false);
|
|
454
|
+
if (rule.equalAverage === true) attrs.equalAverage = require_typed_xlsx_util.writeXmlBool(true);
|
|
455
|
+
if (rule.stdDev !== void 0) attrs.stdDev = String(rule.stdDev);
|
|
456
|
+
style = rule.style;
|
|
457
|
+
break;
|
|
458
|
+
case "timePeriod":
|
|
459
|
+
attrs.timePeriod = rule.timePeriod;
|
|
460
|
+
style = rule.style;
|
|
461
|
+
break;
|
|
462
|
+
case "colorScale":
|
|
463
|
+
children.push(require_xml_fragment.el("colorScale", {}, [...rule.stops.map((stop) => buildCfvoElement(stop.value)), ...rule.stops.map((stop) => require_xml_fragment.el("color", { rgb: `FF${(0, document_schema_js.colorToRgbHex)(stop.color)}` }))]));
|
|
464
|
+
break;
|
|
465
|
+
case "dataBar": {
|
|
466
|
+
const dataBarChildren = [
|
|
467
|
+
buildCfvoElement(rule.min),
|
|
468
|
+
buildCfvoElement(rule.max),
|
|
469
|
+
require_xml_fragment.el("color", { rgb: `FF${(0, document_schema_js.colorToRgbHex)(rule.color)}` })
|
|
470
|
+
];
|
|
471
|
+
const dataBarAttrs = rule.showValue === false ? { showValue: require_typed_xlsx_util.writeXmlBool(false) } : {};
|
|
472
|
+
children.push(require_xml_fragment.el("dataBar", dataBarAttrs, dataBarChildren));
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
case "iconSet": {
|
|
476
|
+
const iconSetAttrs = {};
|
|
477
|
+
if (rule.iconSetType !== DEFAULT_ICON_SET_TYPE) iconSetAttrs.iconSet = rule.iconSetType;
|
|
478
|
+
if (rule.reverse === true) iconSetAttrs.reverse = require_typed_xlsx_util.writeXmlBool(true);
|
|
479
|
+
if (rule.showValue === false) iconSetAttrs.showValue = require_typed_xlsx_util.writeXmlBool(false);
|
|
480
|
+
children.push(require_xml_fragment.el("iconSet", iconSetAttrs, rule.thresholds.map(buildCfvoElement)));
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
if (style !== void 0) attrs.dxfId = String(dxfTable.intern(style));
|
|
485
|
+
return require_xml_fragment.el("cfRule", attrs, children);
|
|
486
|
+
}
|
|
487
|
+
function buildConditionalFormattingElements(formats, dxfTable) {
|
|
488
|
+
const groupsByKey = /* @__PURE__ */ new Map();
|
|
489
|
+
const groupOrder = [];
|
|
490
|
+
for (const format of formats) {
|
|
491
|
+
const key = rangeSetKey(format.ranges);
|
|
492
|
+
const existing = groupsByKey.get(key);
|
|
493
|
+
if (existing === void 0) {
|
|
494
|
+
const group = {
|
|
495
|
+
ranges: format.ranges,
|
|
496
|
+
rules: [format]
|
|
497
|
+
};
|
|
498
|
+
groupsByKey.set(key, group);
|
|
499
|
+
groupOrder.push(group);
|
|
500
|
+
} else existing.rules.push(format);
|
|
501
|
+
}
|
|
502
|
+
const usedPriorities = /* @__PURE__ */ new Set();
|
|
503
|
+
for (const format of formats) if (format.priority !== void 0) usedPriorities.add(format.priority);
|
|
504
|
+
let nextPriority = 1;
|
|
505
|
+
const assignPriority = (explicit) => {
|
|
506
|
+
if (explicit !== void 0) return explicit;
|
|
507
|
+
while (usedPriorities.has(nextPriority)) nextPriority++;
|
|
508
|
+
usedPriorities.add(nextPriority);
|
|
509
|
+
return nextPriority++;
|
|
510
|
+
};
|
|
511
|
+
return groupOrder.map((group) => {
|
|
512
|
+
const cfRuleElements = group.rules.map((rule) => buildCfRuleElement(rule, assignPriority(rule.priority), dxfTable));
|
|
513
|
+
return require_xml_fragment.el("conditionalFormatting", { sqref: require_typed_xlsx_sqref.formatSqref(group.ranges) }, cfRuleElements);
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
//#endregion
|
|
517
|
+
exports.DxfTable = DxfTable;
|
|
518
|
+
exports.buildConditionalFormattingElements = buildConditionalFormattingElements;
|
|
519
|
+
exports.readConditionalFormats = readConditionalFormats;
|