@cj-tech-master/excelts 4.2.1-canary.20260111102127.f808a37 → 4.2.1-canary.20260112134913.a3cecdd
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/archive/io/archive-sink.d.ts +0 -1
- package/dist/browser/modules/archive/io/archive-sink.js +6 -38
- package/dist/browser/modules/archive/io/archive-source.d.ts +0 -2
- package/dist/browser/modules/archive/io/archive-source.js +1 -8
- package/dist/browser/modules/excel/utils/ooxml-validator.d.ts +48 -0
- package/dist/browser/modules/excel/utils/ooxml-validator.js +469 -0
- package/dist/browser/modules/excel/worksheet.js +5 -2
- package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/sp-xform.d.ts +18 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/sp-xform.js +112 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +6 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
- package/dist/browser/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/page-setup-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
- package/dist/browser/modules/stream/base-transform.d.ts +3 -0
- package/dist/browser/modules/stream/base-transform.js +34 -20
- package/dist/browser/modules/stream/buffered-stream.d.ts +2 -12
- package/dist/browser/modules/stream/chunked-builder.js +4 -4
- package/dist/browser/modules/stream/index.browser.d.ts +13 -19
- package/dist/browser/modules/stream/index.browser.js +10 -22
- package/dist/browser/modules/stream/index.d.ts +18 -41
- package/dist/browser/modules/stream/index.js +15 -44
- package/dist/browser/modules/stream/internal/event-utils.d.ts +17 -0
- package/dist/browser/modules/stream/internal/event-utils.js +40 -0
- package/dist/browser/modules/stream/internal/type-guards.d.ts +9 -0
- package/dist/browser/modules/stream/internal/type-guards.js +24 -0
- package/dist/browser/modules/stream/pull-stream.d.ts +5 -6
- package/dist/browser/modules/stream/pull-stream.js +107 -43
- package/dist/browser/modules/stream/shared.d.ts +1 -1
- package/dist/browser/modules/stream/shared.js +7 -4
- package/dist/browser/modules/stream/streams.browser.d.ts +4 -14
- package/dist/browser/modules/stream/streams.browser.js +129 -164
- package/dist/browser/modules/stream/streams.d.ts +4 -20
- package/dist/browser/modules/stream/streams.js +6 -37
- package/dist/browser/modules/stream/utils.js +5 -38
- package/dist/cjs/modules/archive/io/archive-sink.js +7 -40
- package/dist/cjs/modules/archive/io/archive-source.js +3 -12
- package/dist/cjs/modules/excel/utils/ooxml-validator.js +475 -0
- package/dist/cjs/modules/excel/worksheet.js +5 -2
- package/dist/cjs/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/sp-xform.js +115 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
- package/dist/cjs/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
- package/dist/cjs/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
- package/dist/cjs/modules/stream/base-transform.js +34 -20
- package/dist/cjs/modules/stream/chunked-builder.js +4 -4
- package/dist/cjs/modules/stream/index.browser.js +10 -17
- package/dist/cjs/modules/stream/index.js +15 -39
- package/dist/cjs/modules/stream/internal/event-utils.js +43 -0
- package/dist/cjs/modules/stream/internal/type-guards.js +30 -0
- package/dist/cjs/modules/stream/pull-stream.js +107 -43
- package/dist/cjs/modules/stream/shared.js +7 -4
- package/dist/cjs/modules/stream/streams.browser.js +135 -175
- package/dist/cjs/modules/stream/streams.js +16 -49
- package/dist/cjs/modules/stream/utils.js +3 -36
- package/dist/esm/modules/archive/io/archive-sink.js +6 -38
- package/dist/esm/modules/archive/io/archive-source.js +1 -8
- package/dist/esm/modules/excel/utils/ooxml-validator.js +469 -0
- package/dist/esm/modules/excel/worksheet.js +5 -2
- package/dist/esm/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/sp-xform.js +112 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
- package/dist/esm/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
- package/dist/esm/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
- package/dist/esm/modules/stream/base-transform.js +34 -20
- package/dist/esm/modules/stream/chunked-builder.js +4 -4
- package/dist/esm/modules/stream/index.browser.js +10 -22
- package/dist/esm/modules/stream/index.js +15 -44
- package/dist/esm/modules/stream/internal/event-utils.js +40 -0
- package/dist/esm/modules/stream/internal/type-guards.js +24 -0
- package/dist/esm/modules/stream/pull-stream.js +107 -43
- package/dist/esm/modules/stream/shared.js +7 -4
- package/dist/esm/modules/stream/streams.browser.js +129 -164
- package/dist/esm/modules/stream/streams.js +6 -37
- package/dist/esm/modules/stream/utils.js +5 -38
- package/dist/iife/excelts.iife.js +325 -60
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +25 -25
- package/dist/types/modules/archive/io/archive-sink.d.ts +0 -1
- package/dist/types/modules/archive/io/archive-source.d.ts +0 -2
- package/dist/types/modules/excel/utils/ooxml-validator.d.ts +48 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/sp-xform.d.ts +18 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +6 -1
- package/dist/types/modules/excel/xlsx/xform/sheet/page-setup-xform.d.ts +1 -0
- package/dist/types/modules/stream/base-transform.d.ts +3 -0
- package/dist/types/modules/stream/buffered-stream.d.ts +2 -12
- package/dist/types/modules/stream/index.browser.d.ts +13 -19
- package/dist/types/modules/stream/index.d.ts +18 -41
- package/dist/types/modules/stream/internal/event-utils.d.ts +17 -0
- package/dist/types/modules/stream/internal/type-guards.d.ts +9 -0
- package/dist/types/modules/stream/pull-stream.d.ts +5 -6
- package/dist/types/modules/stream/shared.d.ts +1 -1
- package/dist/types/modules/stream/streams.browser.d.ts +4 -14
- package/dist/types/modules/stream/streams.d.ts +4 -20
- package/package.json +10 -10
|
@@ -4,6 +4,5 @@ export type ArchiveSink = WritableStream<Uint8Array> | {
|
|
|
4
4
|
on?(event: string, listener: (...args: any[]) => void): any;
|
|
5
5
|
once?(event: string, listener: (...args: any[]) => void): any;
|
|
6
6
|
};
|
|
7
|
-
export declare function isWritableStream(value: unknown): value is WritableStream<Uint8Array>;
|
|
8
7
|
export declare function pipeIterableToSink(iterable: AsyncIterable<Uint8Array>, sink: ArchiveSink): Promise<void>;
|
|
9
8
|
export declare function collect(iterable: AsyncIterable<Uint8Array>): Promise<Uint8Array>;
|
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
function once(emitter, event) {
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
const onError = (err) => {
|
|
7
|
-
cleanup();
|
|
8
|
-
reject(err instanceof Error ? err : new Error(String(err)));
|
|
9
|
-
};
|
|
10
|
-
const onDone = () => {
|
|
11
|
-
cleanup();
|
|
12
|
-
resolve();
|
|
13
|
-
};
|
|
14
|
-
const cleanup = () => {
|
|
15
|
-
emitter.off?.("error", onError);
|
|
16
|
-
emitter.off?.(event, onDone);
|
|
17
|
-
emitter.removeListener?.("error", onError);
|
|
18
|
-
emitter.removeListener?.(event, onDone);
|
|
19
|
-
};
|
|
20
|
-
emitter.on?.("error", onError);
|
|
21
|
-
emitter.on?.(event, onDone);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
1
|
+
import { concatUint8Arrays } from "../../stream/shared.js";
|
|
2
|
+
import { onceEvent } from "../../stream/internal/event-utils.js";
|
|
3
|
+
import { isWritableStream } from "../../stream/internal/type-guards.js";
|
|
24
4
|
export async function pipeIterableToSink(iterable, sink) {
|
|
25
5
|
if (isWritableStream(sink)) {
|
|
26
6
|
const writer = sink.getWriter();
|
|
@@ -44,14 +24,14 @@ export async function pipeIterableToSink(iterable, sink) {
|
|
|
44
24
|
for await (const chunk of iterable) {
|
|
45
25
|
const ok = sink.write(chunk);
|
|
46
26
|
if (ok === false && typeof sink.once === "function") {
|
|
47
|
-
await
|
|
27
|
+
await onceEvent(sink, "drain");
|
|
48
28
|
}
|
|
49
29
|
}
|
|
50
30
|
if (typeof sink.end === "function") {
|
|
51
31
|
sink.end();
|
|
52
32
|
}
|
|
53
33
|
if (typeof sink.once === "function") {
|
|
54
|
-
await Promise.race([
|
|
34
|
+
await Promise.race([onceEvent(sink, "finish"), onceEvent(sink, "close")]);
|
|
55
35
|
}
|
|
56
36
|
}
|
|
57
37
|
export async function collect(iterable) {
|
|
@@ -61,17 +41,5 @@ export async function collect(iterable) {
|
|
|
61
41
|
chunks.push(chunk);
|
|
62
42
|
total += chunk.length;
|
|
63
43
|
}
|
|
64
|
-
|
|
65
|
-
return new Uint8Array(0);
|
|
66
|
-
}
|
|
67
|
-
if (chunks.length === 1) {
|
|
68
|
-
return chunks[0];
|
|
69
|
-
}
|
|
70
|
-
const out = new Uint8Array(total);
|
|
71
|
-
let offset = 0;
|
|
72
|
-
for (const chunk of chunks) {
|
|
73
|
-
out.set(chunk, offset);
|
|
74
|
-
offset += chunk.length;
|
|
75
|
-
}
|
|
76
|
-
return out;
|
|
44
|
+
return concatUint8Arrays(chunks, total);
|
|
77
45
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export type ArchiveSource = Uint8Array | ArrayBuffer | string | Blob | AsyncIterable<unknown> | ReadableStream<unknown> | {
|
|
2
2
|
[Symbol.asyncIterator](): AsyncIterator<unknown>;
|
|
3
3
|
};
|
|
4
|
-
export declare function isReadableStream(value: unknown): value is ReadableStream<unknown>;
|
|
5
|
-
export declare function isAsyncIterable(value: unknown): value is AsyncIterable<unknown>;
|
|
6
4
|
export declare function toUint8ArraySync(source: Uint8Array | ArrayBuffer | string): Uint8Array;
|
|
7
5
|
export declare function toUint8Array(source: Uint8Array | ArrayBuffer | string | Blob): Promise<Uint8Array>;
|
|
8
6
|
export declare function toAsyncIterable(source: ArchiveSource): AsyncIterable<Uint8Array>;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { encodeUtf8 } from "../utils/text.js";
|
|
2
|
-
|
|
3
|
-
return !!value && typeof value === "object" && typeof value.getReader === "function";
|
|
4
|
-
}
|
|
5
|
-
export function isAsyncIterable(value) {
|
|
6
|
-
return (!!value &&
|
|
7
|
-
(typeof value === "object" || typeof value === "function") &&
|
|
8
|
-
typeof value[Symbol.asyncIterator] === "function");
|
|
9
|
-
}
|
|
2
|
+
import { isAsyncIterable, isReadableStream } from "../../stream/internal/type-guards.js";
|
|
10
3
|
function normalizeChunk(value) {
|
|
11
4
|
if (!value) {
|
|
12
5
|
return null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type OoxmlProblemKind = "missing-part" | "xml-malformed" | "content-types-missing" | "content-types-malformed" | "content-types-missing-default" | "content-types-missing-for-part" | "content-types-duplicate-override" | "root-rels-missing-officeDocument" | "rels-malformed" | "rels-missing-target" | "rels-duplicate-id" | "rels-empty-target" | "rels-invalid-target-path" | "rels-source-missing" | "workbook-sheet-missing-rel" | "workbook-sheet-wrong-rel-type" | "workbook-duplicate-sheetId" | "workbook-duplicate-sheet-rid" | "sheet-missing-rels" | "sheet-controls-missing-drawing" | "sheet-control-missing-rel" | "sheet-control-wrong-rel-type" | "sheet-legacyDrawing-missing-rel" | "sheet-legacyDrawing-wrong-rel-type" | "sheet-drawing-missing-rel" | "sheet-drawing-wrong-rel-type" | "sheet-comments-missing-rel" | "sheet-comments-wrong-rel-type" | "sheet-hyperlink-missing-rel" | "sheet-hyperlink-wrong-rel-type" | "sheet-tablePart-missing-rel" | "sheet-tablePart-wrong-rel-type";
|
|
2
|
+
export type OoxmlOrderingProblemKind = "sheet-legacyDrawing-after-controls";
|
|
3
|
+
export interface OoxmlValidationProblem {
|
|
4
|
+
kind: OoxmlProblemKind;
|
|
5
|
+
file?: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export interface OoxmlOrderingValidationProblem {
|
|
9
|
+
kind: OoxmlOrderingProblemKind;
|
|
10
|
+
file?: string;
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
export interface OoxmlValidationReport {
|
|
14
|
+
ok: boolean;
|
|
15
|
+
problems: Array<OoxmlValidationProblem | OoxmlOrderingValidationProblem>;
|
|
16
|
+
stats: {
|
|
17
|
+
entryCount: number;
|
|
18
|
+
xmlLikeCount: number;
|
|
19
|
+
relsCount: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface OoxmlValidateOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Whether to check every XML-like entry (.xml, .rels, .vml) for well-formedness.
|
|
25
|
+
* Default: true.
|
|
26
|
+
*/
|
|
27
|
+
checkXmlWellFormed?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to validate relationship targets exist (TargetMode=External ignored).
|
|
30
|
+
* Default: true.
|
|
31
|
+
*/
|
|
32
|
+
checkRelationshipTargets?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to validate that every ContentTypes Override PartName exists.
|
|
35
|
+
* Default: true.
|
|
36
|
+
*/
|
|
37
|
+
checkContentTypesOverrides?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to validate worksheet <controls>/<legacyDrawing> r:id wiring.
|
|
40
|
+
* Default: true.
|
|
41
|
+
*/
|
|
42
|
+
checkWorksheetControlWiring?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* If provided, stops after this many problems.
|
|
45
|
+
*/
|
|
46
|
+
maxProblems?: number;
|
|
47
|
+
}
|
|
48
|
+
export declare function validateXlsxBuffer(xlsxBuffer: Uint8Array, options?: OoxmlValidateOptions): Promise<OoxmlValidationReport>;
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { extractAll } from "../../archive/unzip/extract.js";
|
|
3
|
+
import { parseSax } from "./parse-sax.js";
|
|
4
|
+
function pushProblem(problems, problem, maxProblems) {
|
|
5
|
+
if (maxProblems !== undefined && problems.length >= maxProblems) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
problems.push(problem);
|
|
9
|
+
}
|
|
10
|
+
function stripLeadingSlash(p) {
|
|
11
|
+
return p.startsWith("/") ? p.slice(1) : p;
|
|
12
|
+
}
|
|
13
|
+
function isXmlLike(pathName) {
|
|
14
|
+
return pathName.endsWith(".xml") || pathName.endsWith(".rels") || pathName.endsWith(".vml");
|
|
15
|
+
}
|
|
16
|
+
function getRelsSourceDir(relsPath) {
|
|
17
|
+
// In OPC, relationship targets are resolved relative to the SOURCE part directory,
|
|
18
|
+
// not the .rels part directory.
|
|
19
|
+
//
|
|
20
|
+
// Examples:
|
|
21
|
+
// - _rels/.rels -> base "" (package root)
|
|
22
|
+
// - xl/_rels/workbook.xml.rels -> base "xl"
|
|
23
|
+
// - xl/worksheets/_rels/sheet1.xml.rels -> base "xl/worksheets"
|
|
24
|
+
if (relsPath === "_rels/.rels") {
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
const relsMarker = "/_rels/";
|
|
28
|
+
const idx = relsPath.indexOf(relsMarker);
|
|
29
|
+
if (idx === -1) {
|
|
30
|
+
return relsPath.includes("/") ? relsPath.slice(0, relsPath.lastIndexOf("/")) : "";
|
|
31
|
+
}
|
|
32
|
+
return relsPath.slice(0, idx);
|
|
33
|
+
}
|
|
34
|
+
function resolveRelTarget(relsPath, target) {
|
|
35
|
+
const baseDir = getRelsSourceDir(relsPath);
|
|
36
|
+
const resolved = path.posix.normalize(path.posix.join(baseDir, target));
|
|
37
|
+
return resolved.replace(/^\//, "");
|
|
38
|
+
}
|
|
39
|
+
function isSafeResolvedPath(resolved) {
|
|
40
|
+
// Prevent path traversal out of package root.
|
|
41
|
+
// `normalize()` can produce paths starting with "../".
|
|
42
|
+
return !(resolved === ".." || resolved.startsWith("../") || resolved.includes("/../"));
|
|
43
|
+
}
|
|
44
|
+
async function assertXmlWellFormed(xmlText) {
|
|
45
|
+
// parseSax throws on malformed XML.
|
|
46
|
+
for await (const _events of parseSax([xmlText])) {
|
|
47
|
+
// no-op
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function parseContentTypes(xml) {
|
|
51
|
+
const defaults = [];
|
|
52
|
+
const overrides = [];
|
|
53
|
+
const defaultRe = /<Default\s+[^>]*Extension="([^"]+)"[^>]*ContentType="([^"]+)"[^>]*\/>/g;
|
|
54
|
+
const overrideRe = /<Override\s+[^>]*PartName="([^"]+)"[^>]*ContentType="([^"]+)"[^>]*\/>/g;
|
|
55
|
+
for (let match = defaultRe.exec(xml); match; match = defaultRe.exec(xml)) {
|
|
56
|
+
defaults.push({ extension: match[1], contentType: match[2] });
|
|
57
|
+
}
|
|
58
|
+
for (let match = overrideRe.exec(xml); match; match = overrideRe.exec(xml)) {
|
|
59
|
+
overrides.push({ partName: match[1], contentType: match[2] });
|
|
60
|
+
}
|
|
61
|
+
const parseOk = xml.includes("<Types") && (defaults.length > 0 || overrides.length > 0);
|
|
62
|
+
return { defaults, overrides, parseOk };
|
|
63
|
+
}
|
|
64
|
+
function getExtension(p) {
|
|
65
|
+
const base = path.posix.basename(p);
|
|
66
|
+
const idx = base.lastIndexOf(".");
|
|
67
|
+
return idx === -1 ? "" : base.slice(idx + 1);
|
|
68
|
+
}
|
|
69
|
+
function isPackagePart(pathName) {
|
|
70
|
+
// Exclude directories and the [Content_Types].xml pseudo-root.
|
|
71
|
+
return pathName !== "" && pathName !== "[Content_Types].xml";
|
|
72
|
+
}
|
|
73
|
+
function parseRelationships(xml) {
|
|
74
|
+
// Ensure the rels XML itself is parseable.
|
|
75
|
+
// We still use regex to extract rels for speed/portability.
|
|
76
|
+
const relRe = /<Relationship\s+[^>]*Id="([^"]+)"[^>]*Type="([^"]+)"[^>]*Target="([^"]*)"(?:[^>]*TargetMode="([^"]+)")?[^>]*\/>/g;
|
|
77
|
+
const rels = [];
|
|
78
|
+
for (let match = relRe.exec(xml); match; match = relRe.exec(xml)) {
|
|
79
|
+
rels.push({ id: match[1], type: match[2], target: match[3], targetMode: match[4] });
|
|
80
|
+
}
|
|
81
|
+
// Basic sanity: should have <Relationships ...> root.
|
|
82
|
+
const parseOk = xml.includes("<Relationships") && xml.includes("Relationship");
|
|
83
|
+
return { rels, parseOk };
|
|
84
|
+
}
|
|
85
|
+
export async function validateXlsxBuffer(xlsxBuffer, options = {}) {
|
|
86
|
+
const { checkXmlWellFormed = true, checkRelationshipTargets = true, checkContentTypesOverrides = true, checkWorksheetControlWiring = true, maxProblems } = options;
|
|
87
|
+
const problems = [];
|
|
88
|
+
const entries = await extractAll(xlsxBuffer);
|
|
89
|
+
const has = (p) => entries.has(p);
|
|
90
|
+
const mustExist = [
|
|
91
|
+
"[Content_Types].xml",
|
|
92
|
+
"_rels/.rels",
|
|
93
|
+
"xl/workbook.xml",
|
|
94
|
+
"xl/_rels/workbook.xml.rels"
|
|
95
|
+
];
|
|
96
|
+
for (const p of mustExist) {
|
|
97
|
+
if (!has(p)) {
|
|
98
|
+
pushProblem(problems, { kind: "missing-part", file: p, message: `Missing required part: ${p}` }, maxProblems);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// XML well-formedness for all XML-like parts.
|
|
102
|
+
if (checkXmlWellFormed) {
|
|
103
|
+
for (const [p, entry] of entries) {
|
|
104
|
+
if (maxProblems !== undefined && problems.length >= maxProblems) {
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
if (entry.isDirectory || !isXmlLike(p)) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const xml = new TextDecoder().decode(entry.data);
|
|
111
|
+
try {
|
|
112
|
+
await assertXmlWellFormed(xml);
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
pushProblem(problems, {
|
|
116
|
+
kind: "xml-malformed",
|
|
117
|
+
file: p,
|
|
118
|
+
message: `Malformed XML: ${err?.message || String(err)}`
|
|
119
|
+
}, maxProblems);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Content types overrides must point to existing parts.
|
|
124
|
+
if (checkContentTypesOverrides && has("[Content_Types].xml")) {
|
|
125
|
+
const ctXml = new TextDecoder().decode(entries.get("[Content_Types].xml").data);
|
|
126
|
+
const { defaults, overrides, parseOk } = parseContentTypes(ctXml);
|
|
127
|
+
if (!parseOk) {
|
|
128
|
+
pushProblem(problems, {
|
|
129
|
+
kind: "content-types-malformed",
|
|
130
|
+
file: "[Content_Types].xml",
|
|
131
|
+
message: "Content types XML missing expected root/entries"
|
|
132
|
+
}, maxProblems);
|
|
133
|
+
}
|
|
134
|
+
const defaultByExt = new Map(defaults.map(d => [d.extension.toLowerCase(), d.contentType]));
|
|
135
|
+
const overrideByPart = new Map();
|
|
136
|
+
for (const ov of overrides) {
|
|
137
|
+
const key = stripLeadingSlash(ov.partName);
|
|
138
|
+
if (overrideByPart.has(key)) {
|
|
139
|
+
pushProblem(problems, {
|
|
140
|
+
kind: "content-types-duplicate-override",
|
|
141
|
+
file: "[Content_Types].xml",
|
|
142
|
+
message: `Duplicate Override PartName: ${ov.partName}`
|
|
143
|
+
}, maxProblems);
|
|
144
|
+
}
|
|
145
|
+
overrideByPart.set(key, ov.contentType);
|
|
146
|
+
}
|
|
147
|
+
// RFC: .rels and .xml defaults are expected in valid packages.
|
|
148
|
+
const relsDefault = defaultByExt.get("rels");
|
|
149
|
+
if (relsDefault !== "application/vnd.openxmlformats-package.relationships+xml") {
|
|
150
|
+
pushProblem(problems, {
|
|
151
|
+
kind: "content-types-missing-default",
|
|
152
|
+
file: "[Content_Types].xml",
|
|
153
|
+
message: "Missing/incorrect Default for .rels (expected application/vnd.openxmlformats-package.relationships+xml)"
|
|
154
|
+
}, maxProblems);
|
|
155
|
+
}
|
|
156
|
+
const xmlDefault = defaultByExt.get("xml");
|
|
157
|
+
if (xmlDefault !== "application/xml") {
|
|
158
|
+
pushProblem(problems, {
|
|
159
|
+
kind: "content-types-missing-default",
|
|
160
|
+
file: "[Content_Types].xml",
|
|
161
|
+
message: "Missing/incorrect Default for .xml (expected application/xml)"
|
|
162
|
+
}, maxProblems);
|
|
163
|
+
}
|
|
164
|
+
for (const ov of overrides) {
|
|
165
|
+
if (maxProblems !== undefined && problems.length >= maxProblems) {
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
const zipPath = stripLeadingSlash(ov.partName);
|
|
169
|
+
if (!has(zipPath)) {
|
|
170
|
+
pushProblem(problems, {
|
|
171
|
+
kind: "content-types-missing",
|
|
172
|
+
file: "[Content_Types].xml",
|
|
173
|
+
message: `Override PartName points to missing file: ${ov.partName}`
|
|
174
|
+
}, maxProblems);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Strong check: every part in the zip should have a content type via Default or Override.
|
|
178
|
+
for (const [p, entry] of entries) {
|
|
179
|
+
if (maxProblems !== undefined && problems.length >= maxProblems) {
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (entry.isDirectory || !isPackagePart(p)) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const overrideType = overrideByPart.get(p);
|
|
186
|
+
if (overrideType) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const ext = getExtension(p).toLowerCase();
|
|
190
|
+
if (!ext) {
|
|
191
|
+
pushProblem(problems, {
|
|
192
|
+
kind: "content-types-missing-for-part",
|
|
193
|
+
file: "[Content_Types].xml",
|
|
194
|
+
message: `No content type for part without extension: ${p}`
|
|
195
|
+
}, maxProblems);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (!defaultByExt.has(ext)) {
|
|
199
|
+
pushProblem(problems, {
|
|
200
|
+
kind: "content-types-missing-for-part",
|
|
201
|
+
file: "[Content_Types].xml",
|
|
202
|
+
message: `No Default/Override content type for part: ${p} (extension .${ext})`
|
|
203
|
+
}, maxProblems);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// Root relationships must point to the workbook (OPC officeDocument).
|
|
208
|
+
if (has("_rels/.rels")) {
|
|
209
|
+
const rootRelsXml = new TextDecoder().decode(entries.get("_rels/.rels").data);
|
|
210
|
+
const { rels } = parseRelationships(rootRelsXml);
|
|
211
|
+
const hasOfficeDocument = rels.some(r => r.type.includes("/relationships/officeDocument") && r.target === "xl/workbook.xml");
|
|
212
|
+
if (!hasOfficeDocument) {
|
|
213
|
+
pushProblem(problems, {
|
|
214
|
+
kind: "root-rels-missing-officeDocument",
|
|
215
|
+
file: "_rels/.rels",
|
|
216
|
+
message: "Missing officeDocument relationship to xl/workbook.xml"
|
|
217
|
+
}, maxProblems);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// Relationships: validate target existence and basic ID uniqueness.
|
|
221
|
+
if (checkRelationshipTargets) {
|
|
222
|
+
for (const [p, entry] of entries) {
|
|
223
|
+
if (maxProblems !== undefined && problems.length >= maxProblems) {
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
if (entry.isDirectory || !p.endsWith(".rels")) {
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
const relsXml = new TextDecoder().decode(entry.data);
|
|
230
|
+
const { rels, parseOk } = parseRelationships(relsXml);
|
|
231
|
+
if (!parseOk) {
|
|
232
|
+
pushProblem(problems, {
|
|
233
|
+
kind: "rels-malformed",
|
|
234
|
+
file: p,
|
|
235
|
+
message: "Relationships XML missing expected root/entries"
|
|
236
|
+
}, maxProblems);
|
|
237
|
+
}
|
|
238
|
+
const ids = new Set();
|
|
239
|
+
for (const rel of rels) {
|
|
240
|
+
if (maxProblems !== undefined && problems.length >= maxProblems) {
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
if (ids.has(rel.id)) {
|
|
244
|
+
pushProblem(problems, {
|
|
245
|
+
kind: "rels-duplicate-id",
|
|
246
|
+
file: p,
|
|
247
|
+
message: `Duplicate relationship Id: ${rel.id}`
|
|
248
|
+
}, maxProblems);
|
|
249
|
+
}
|
|
250
|
+
ids.add(rel.id);
|
|
251
|
+
if (rel.targetMode === "External") {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (!rel.target) {
|
|
255
|
+
pushProblem(problems, {
|
|
256
|
+
kind: "rels-empty-target",
|
|
257
|
+
file: p,
|
|
258
|
+
message: `Relationship ${rel.id} (${rel.type}) has empty Target`
|
|
259
|
+
}, maxProblems);
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
const resolvedTarget = resolveRelTarget(p, rel.target);
|
|
263
|
+
if (!isSafeResolvedPath(resolvedTarget)) {
|
|
264
|
+
pushProblem(problems, {
|
|
265
|
+
kind: "rels-invalid-target-path",
|
|
266
|
+
file: p,
|
|
267
|
+
message: `Rel ${rel.id} (${rel.type}) target escapes package root: ${rel.target} -> ${resolvedTarget}`
|
|
268
|
+
}, maxProblems);
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (!has(resolvedTarget)) {
|
|
272
|
+
pushProblem(problems, {
|
|
273
|
+
kind: "rels-missing-target",
|
|
274
|
+
file: p,
|
|
275
|
+
message: `Rel ${rel.id} (${rel.type}) target missing: ${rel.target} -> ${resolvedTarget}`
|
|
276
|
+
}, maxProblems);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// Optional: ensure the source part exists for non-root rels.
|
|
280
|
+
if (p !== "_rels/.rels") {
|
|
281
|
+
// Convert: xl/_rels/workbook.xml.rels -> xl/workbook.xml
|
|
282
|
+
// Convert: xl/worksheets/_rels/sheet1.xml.rels -> xl/worksheets/sheet1.xml
|
|
283
|
+
const srcDir = getRelsSourceDir(p);
|
|
284
|
+
const relsBaseName = path.posix.basename(p);
|
|
285
|
+
const sourceName = relsBaseName.replace(/\.rels$/, "");
|
|
286
|
+
const sourcePath = srcDir ? `${srcDir}/${sourceName}` : sourceName;
|
|
287
|
+
if (!has(sourcePath)) {
|
|
288
|
+
pushProblem(problems, {
|
|
289
|
+
kind: "rels-source-missing",
|
|
290
|
+
file: p,
|
|
291
|
+
message: `Relationships part has no corresponding source part: ${sourcePath}`
|
|
292
|
+
}, maxProblems);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// Workbook -> worksheets wiring.
|
|
298
|
+
if (has("xl/workbook.xml") && has("xl/_rels/workbook.xml.rels")) {
|
|
299
|
+
const workbookXml = new TextDecoder().decode(entries.get("xl/workbook.xml").data);
|
|
300
|
+
const workbookRelsXml = new TextDecoder().decode(entries.get("xl/_rels/workbook.xml.rels").data);
|
|
301
|
+
const { rels: wbRels } = parseRelationships(workbookRelsXml);
|
|
302
|
+
const wbById = new Map(wbRels.map(r => [r.id, r]));
|
|
303
|
+
// Uniqueness checks: sheetId and r:id should not be duplicated.
|
|
304
|
+
const sheetIdRe = /<sheet\b[^>]*\bsheetId="(\d+)"[^>]*\/>/g;
|
|
305
|
+
const seenSheetIds = new Set();
|
|
306
|
+
for (let match = sheetIdRe.exec(workbookXml); match; match = sheetIdRe.exec(workbookXml)) {
|
|
307
|
+
const id = match[1];
|
|
308
|
+
if (seenSheetIds.has(id)) {
|
|
309
|
+
pushProblem(problems, {
|
|
310
|
+
kind: "workbook-duplicate-sheetId",
|
|
311
|
+
file: "xl/workbook.xml",
|
|
312
|
+
message: `Duplicate sheetId in workbook: ${id}`
|
|
313
|
+
}, maxProblems);
|
|
314
|
+
}
|
|
315
|
+
seenSheetIds.add(id);
|
|
316
|
+
}
|
|
317
|
+
const sheetRidSeen = new Set();
|
|
318
|
+
const sheetRidRe = /<sheet\b[^>]*\br:id="(rId\d+)"[^>]*\/>/g;
|
|
319
|
+
for (let match = sheetRidRe.exec(workbookXml); match; match = sheetRidRe.exec(workbookXml)) {
|
|
320
|
+
if (maxProblems !== undefined && problems.length >= maxProblems) {
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
const rid = match[1];
|
|
324
|
+
if (sheetRidSeen.has(rid)) {
|
|
325
|
+
pushProblem(problems, {
|
|
326
|
+
kind: "workbook-duplicate-sheet-rid",
|
|
327
|
+
file: "xl/workbook.xml",
|
|
328
|
+
message: `Duplicate sheet r:id in workbook: ${rid}`
|
|
329
|
+
}, maxProblems);
|
|
330
|
+
}
|
|
331
|
+
sheetRidSeen.add(rid);
|
|
332
|
+
const rel = wbById.get(rid);
|
|
333
|
+
if (!rel) {
|
|
334
|
+
pushProblem(problems, {
|
|
335
|
+
kind: "workbook-sheet-missing-rel",
|
|
336
|
+
file: "xl/workbook.xml",
|
|
337
|
+
message: `Workbook <sheet> references missing relationship: ${rid} (in xl/_rels/workbook.xml.rels)`
|
|
338
|
+
}, maxProblems);
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
if (!rel.type.includes("/relationships/worksheet")) {
|
|
342
|
+
pushProblem(problems, {
|
|
343
|
+
kind: "workbook-sheet-wrong-rel-type",
|
|
344
|
+
file: "xl/workbook.xml",
|
|
345
|
+
message: `Workbook <sheet> ${rid} relationship is not worksheet: ${rel.type}`
|
|
346
|
+
}, maxProblems);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
// Worksheet <controls>/<legacyDrawing> wiring.
|
|
351
|
+
if (checkWorksheetControlWiring) {
|
|
352
|
+
for (const [p, entry] of entries) {
|
|
353
|
+
if (maxProblems !== undefined && problems.length >= maxProblems) {
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
if (entry.isDirectory || !p.startsWith("xl/worksheets/sheet") || !p.endsWith(".xml")) {
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
const sheetXml = new TextDecoder().decode(entry.data);
|
|
360
|
+
const relsPath = `xl/worksheets/_rels/${path.posix.basename(p)}.rels`;
|
|
361
|
+
// Excel is sensitive to worksheet child element ordering. In particular,
|
|
362
|
+
// legacyDrawing must come before controls when both are present.
|
|
363
|
+
const legacyDrawingIdx = sheetXml.indexOf("<legacyDrawing");
|
|
364
|
+
const controlsIdx = sheetXml.indexOf("<controls");
|
|
365
|
+
if (legacyDrawingIdx !== -1 && controlsIdx !== -1 && legacyDrawingIdx > controlsIdx) {
|
|
366
|
+
pushProblem(problems, {
|
|
367
|
+
kind: "sheet-legacyDrawing-after-controls",
|
|
368
|
+
file: p,
|
|
369
|
+
message: "Worksheet has <legacyDrawing> after <controls>; Excel may repair or reject this sheet"
|
|
370
|
+
}, maxProblems);
|
|
371
|
+
}
|
|
372
|
+
// Match <control ...> elements (not necessarily self-closing).
|
|
373
|
+
const controlRidRe = /<control\b[^>]*\br:id="(rId\d+)"[^>]*>/g;
|
|
374
|
+
const controlRids = [];
|
|
375
|
+
for (let match = controlRidRe.exec(sheetXml); match; match = controlRidRe.exec(sheetXml)) {
|
|
376
|
+
controlRids.push(match[1]);
|
|
377
|
+
}
|
|
378
|
+
// Excel Online / strict Excel builds may reject or "repair" legacy form controls
|
|
379
|
+
// if the sheet doesn't also have a DrawingML <drawing> part.
|
|
380
|
+
if (controlRids.length > 0 && sheetXml.indexOf("<drawing") === -1) {
|
|
381
|
+
pushProblem(problems, {
|
|
382
|
+
kind: "sheet-controls-missing-drawing",
|
|
383
|
+
file: p,
|
|
384
|
+
message: "Worksheet has legacy <controls> but no <drawing>; Excel may repair/reject legacy form controls"
|
|
385
|
+
}, maxProblems);
|
|
386
|
+
}
|
|
387
|
+
const legacyDrawingRidRe = /<legacyDrawing\b[^>]*\br:id="(rId\d+)"[^>]*\/>/g;
|
|
388
|
+
const legacyDrawingRids = [];
|
|
389
|
+
for (let match = legacyDrawingRidRe.exec(sheetXml); match; match = legacyDrawingRidRe.exec(sheetXml)) {
|
|
390
|
+
legacyDrawingRids.push(match[1]);
|
|
391
|
+
}
|
|
392
|
+
if ((controlRids.length > 0 || legacyDrawingRids.length > 0) && !has(relsPath)) {
|
|
393
|
+
pushProblem(problems, {
|
|
394
|
+
kind: "sheet-missing-rels",
|
|
395
|
+
file: p,
|
|
396
|
+
message: `Worksheet has controls/legacyDrawing but missing rels part: ${relsPath}`
|
|
397
|
+
}, maxProblems);
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
if (!has(relsPath)) {
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
const sheetRelsXml = new TextDecoder().decode(entries.get(relsPath).data);
|
|
404
|
+
const { rels: sheetRels } = parseRelationships(sheetRelsXml);
|
|
405
|
+
const byId = new Map(sheetRels.map(r => [r.id, r]));
|
|
406
|
+
const assertRidType = (rid, expectedTypeIncludes, kindMissing, kindWrong, nodeLabel) => {
|
|
407
|
+
const rel = byId.get(rid);
|
|
408
|
+
if (!rel) {
|
|
409
|
+
pushProblem(problems, {
|
|
410
|
+
kind: kindMissing,
|
|
411
|
+
file: p,
|
|
412
|
+
message: `Sheet ${nodeLabel} references missing relationship: ${rid} (in ${relsPath})`
|
|
413
|
+
}, maxProblems);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (!rel.type.includes(expectedTypeIncludes)) {
|
|
417
|
+
pushProblem(problems, {
|
|
418
|
+
kind: kindWrong,
|
|
419
|
+
file: p,
|
|
420
|
+
message: `Sheet ${nodeLabel} ${rid} relationship is not ${expectedTypeIncludes}: ${rel.type}`
|
|
421
|
+
}, maxProblems);
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
for (const rid of controlRids) {
|
|
425
|
+
if (maxProblems !== undefined && problems.length >= maxProblems) {
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
assertRidType(rid, "/relationships/ctrlProp", "sheet-control-missing-rel", "sheet-control-wrong-rel-type", "<control>");
|
|
429
|
+
}
|
|
430
|
+
for (const rid of legacyDrawingRids) {
|
|
431
|
+
if (maxProblems !== undefined && problems.length >= maxProblems) {
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
assertRidType(rid, "/relationships/vmlDrawing", "sheet-legacyDrawing-missing-rel", "sheet-legacyDrawing-wrong-rel-type", "<legacyDrawing>");
|
|
435
|
+
}
|
|
436
|
+
// Common worksheet nodes that are wired via r:id
|
|
437
|
+
// - <drawing r:id="..."/> -> drawing
|
|
438
|
+
// - <comments r:id="..."/> -> comments
|
|
439
|
+
// - <tableParts><tablePart r:id="..."/></tableParts> -> table
|
|
440
|
+
// - <hyperlink r:id="..."/> -> hyperlink
|
|
441
|
+
const drawingRidRe = /<drawing\b[^>]*\br:id="(rId\d+)"[^>]*\/>/g;
|
|
442
|
+
for (let match = drawingRidRe.exec(sheetXml); match; match = drawingRidRe.exec(sheetXml)) {
|
|
443
|
+
assertRidType(match[1], "/relationships/drawing", "sheet-drawing-missing-rel", "sheet-drawing-wrong-rel-type", "<drawing>");
|
|
444
|
+
}
|
|
445
|
+
const commentsRidRe = /<comments\b[^>]*\br:id="(rId\d+)"[^>]*\/>/g;
|
|
446
|
+
for (let match = commentsRidRe.exec(sheetXml); match; match = commentsRidRe.exec(sheetXml)) {
|
|
447
|
+
assertRidType(match[1], "/relationships/comments", "sheet-comments-missing-rel", "sheet-comments-wrong-rel-type", "<comments>");
|
|
448
|
+
}
|
|
449
|
+
const tablePartRidRe = /<tablePart\b[^>]*\br:id="(rId\d+)"[^>]*\/>/g;
|
|
450
|
+
for (let match = tablePartRidRe.exec(sheetXml); match; match = tablePartRidRe.exec(sheetXml)) {
|
|
451
|
+
assertRidType(match[1], "/relationships/table", "sheet-tablePart-missing-rel", "sheet-tablePart-wrong-rel-type", "<tablePart>");
|
|
452
|
+
}
|
|
453
|
+
const hyperlinkRidRe = /<hyperlink\b[^>]*\br:id="(rId\d+)"[^>]*\/>/g;
|
|
454
|
+
for (let match = hyperlinkRidRe.exec(sheetXml); match; match = hyperlinkRidRe.exec(sheetXml)) {
|
|
455
|
+
assertRidType(match[1], "/relationships/hyperlink", "sheet-hyperlink-missing-rel", "sheet-hyperlink-wrong-rel-type", "<hyperlink>");
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
const stats = {
|
|
460
|
+
entryCount: entries.size,
|
|
461
|
+
xmlLikeCount: [...entries.values()].filter((f) => !f.isDirectory && isXmlLike(f.path)).length,
|
|
462
|
+
relsCount: [...entries.values()].filter((f) => !f.isDirectory && f.path.endsWith(".rels")).length
|
|
463
|
+
};
|
|
464
|
+
return {
|
|
465
|
+
ok: problems.length === 0,
|
|
466
|
+
problems,
|
|
467
|
+
stats
|
|
468
|
+
};
|
|
469
|
+
}
|
|
@@ -49,8 +49,11 @@ class Worksheet {
|
|
|
49
49
|
this.pageSetup = Object.assign({}, {
|
|
50
50
|
margins: { left: 0.7, right: 0.7, top: 0.75, bottom: 0.75, header: 0.3, footer: 0.3 },
|
|
51
51
|
orientation: "portrait",
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
// Excel does not normally write these unless explicitly set.
|
|
53
|
+
// Historically we used 4294967295 as a sentinel when parsing, but emitting it
|
|
54
|
+
// can cause strict Excel parsers to treat the workbook as corrupted.
|
|
55
|
+
horizontalDpi: undefined,
|
|
56
|
+
verticalDpi: undefined,
|
|
54
57
|
fitToPage: !!(options.pageSetup &&
|
|
55
58
|
(options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) &&
|
|
56
59
|
!options.pageSetup.scale),
|
|
@@ -7,6 +7,17 @@ import { BaseXform } from "../base-xform.js";
|
|
|
7
7
|
* that stores its properties like objectType, checked state, and linked cell.
|
|
8
8
|
*/
|
|
9
9
|
class CtrlPropXform extends BaseXform {
|
|
10
|
+
_checkedToXmlValue(checked) {
|
|
11
|
+
switch (checked) {
|
|
12
|
+
case "Checked":
|
|
13
|
+
return "1";
|
|
14
|
+
case "Mixed":
|
|
15
|
+
return "2";
|
|
16
|
+
case "Unchecked":
|
|
17
|
+
default:
|
|
18
|
+
return "0";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
10
21
|
get tag() {
|
|
11
22
|
return "formControlPr";
|
|
12
23
|
}
|
|
@@ -15,7 +26,8 @@ class CtrlPropXform extends BaseXform {
|
|
|
15
26
|
const attrs = {
|
|
16
27
|
xmlns: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",
|
|
17
28
|
objectType: "CheckBox",
|
|
18
|
-
|
|
29
|
+
// Excel tends to serialize this as numeric state (0/1/2), matching VML x:Checked.
|
|
30
|
+
checked: this._checkedToXmlValue(renderModel.checked),
|
|
19
31
|
lockText: "1"
|
|
20
32
|
};
|
|
21
33
|
// Add linked cell reference
|