@office-kit/xlsx 0.8.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/LICENSE +21 -0
- package/README.md +319 -0
- package/THIRD_PARTY_NOTICES.md +56 -0
- package/dist/cell/cell.d.ts +234 -0
- package/dist/cell/index.d.ts +4 -0
- package/dist/cell/rich-text.d.ts +37 -0
- package/dist/cell-D9CaNKnU.mjs +320 -0
- package/dist/cell-D9CaNKnU.mjs.map +1 -0
- package/dist/cell-style-BEDjMX1y.mjs +1579 -0
- package/dist/cell-style-BEDjMX1y.mjs.map +1 -0
- package/dist/cell.mjs +2 -0
- package/dist/chart/chart-xml.d.ts +16 -0
- package/dist/chart/chart.d.ts +735 -0
- package/dist/chart/cx/chartex-xml.d.ts +6 -0
- package/dist/chart/cx/chartex.d.ts +279 -0
- package/dist/chart/index.d.ts +6 -0
- package/dist/chart/user-shapes-xml.d.ts +4 -0
- package/dist/chart/user-shapes.d.ts +61 -0
- package/dist/chart.mjs +232 -0
- package/dist/chart.mjs.map +1 -0
- package/dist/chartsheet/chartsheet-xml.d.ts +17 -0
- package/dist/chartsheet/chartsheet.d.ts +121 -0
- package/dist/chartsheet/index.d.ts +2 -0
- package/dist/chartsheet-C3-tqkPy.mjs +23 -0
- package/dist/chartsheet-C3-tqkPy.mjs.map +1 -0
- package/dist/chartsheet.mjs +2 -0
- package/dist/colors-ovWAwnZI.mjs +67 -0
- package/dist/colors-ovWAwnZI.mjs.map +1 -0
- package/dist/compat/numbers.d.ts +14 -0
- package/dist/coordinate-96Ecci4d.mjs +276 -0
- package/dist/coordinate-96Ecci4d.mjs.map +1 -0
- package/dist/datetime-B2ySVlXt.mjs +71 -0
- package/dist/datetime-B2ySVlXt.mjs.map +1 -0
- package/dist/defined-names-CviWmtQg.mjs +89 -0
- package/dist/defined-names-CviWmtQg.mjs.map +1 -0
- package/dist/differential-D4dg-qtZ.mjs +37 -0
- package/dist/differential-D4dg-qtZ.mjs.map +1 -0
- package/dist/drawing/anchor.d.ts +63 -0
- package/dist/drawing/dml/colors.d.ts +109 -0
- package/dist/drawing/dml/dml-xml.d.ts +35 -0
- package/dist/drawing/dml/effect.d.ts +92 -0
- package/dist/drawing/dml/fill.d.ts +115 -0
- package/dist/drawing/dml/geometry.d.ts +113 -0
- package/dist/drawing/dml/line.d.ts +41 -0
- package/dist/drawing/dml/shape-properties.d.ts +33 -0
- package/dist/drawing/dml/text.d.ts +218 -0
- package/dist/drawing/drawing-xml.d.ts +5 -0
- package/dist/drawing/drawing.d.ts +117 -0
- package/dist/drawing/image.d.ts +40 -0
- package/dist/drawing/index.d.ts +14 -0
- package/dist/drawing-BxzLuryn.mjs +415 -0
- package/dist/drawing-BxzLuryn.mjs.map +1 -0
- package/dist/drawing.mjs +119 -0
- package/dist/drawing.mjs.map +1 -0
- package/dist/escape-DFTE7ZJc.mjs +51 -0
- package/dist/escape-DFTE7ZJc.mjs.map +1 -0
- package/dist/exceptions-D-CFwxgm.mjs +37 -0
- package/dist/exceptions-D-CFwxgm.mjs.map +1 -0
- package/dist/formula/tokenizer.d.ts +61 -0
- package/dist/formula/translate.d.ts +67 -0
- package/dist/inference-B3ES3KEJ.mjs +42 -0
- package/dist/inference-B3ES3KEJ.mjs.map +1 -0
- package/dist/io/browser.d.ts +41 -0
- package/dist/io/index.d.ts +7 -0
- package/dist/io/load.d.ts +46 -0
- package/dist/io/node-fs.d.ts +62 -0
- package/dist/io/node-save.d.ts +3 -0
- package/dist/io/node.d.ts +17 -0
- package/dist/io/save.d.ts +14 -0
- package/dist/io/sink.d.ts +54 -0
- package/dist/io/source.d.ts +14 -0
- package/dist/io.mjs +212 -0
- package/dist/io.mjs.map +1 -0
- package/dist/load-D5cbhoGx.mjs +1069 -0
- package/dist/load-D5cbhoGx.mjs.map +1 -0
- package/dist/manifest-Dps1-OpP.mjs +801 -0
- package/dist/manifest-Dps1-OpP.mjs.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.mjs +308 -0
- package/dist/node.mjs.map +1 -0
- package/dist/packaging/core.d.ts +45 -0
- package/dist/packaging/custom.d.ts +62 -0
- package/dist/packaging/extended.d.ts +45 -0
- package/dist/packaging/index.d.ts +10 -0
- package/dist/packaging/manifest.d.ts +24 -0
- package/dist/packaging/relationships.d.ts +30 -0
- package/dist/packaging.mjs +2 -0
- package/dist/parser-DuLejQy1.mjs +156 -0
- package/dist/parser-DuLejQy1.mjs.map +1 -0
- package/dist/reader-D1fNW9k1.mjs +534 -0
- package/dist/reader-D1fNW9k1.mjs.map +1 -0
- package/dist/save-RohQtgEZ.mjs +745 -0
- package/dist/save-RohQtgEZ.mjs.map +1 -0
- package/dist/schema/core.d.ts +133 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/serialize.d.ts +6 -0
- package/dist/schema.mjs +2 -0
- package/dist/serialize-55EnT30e.mjs +254 -0
- package/dist/serialize-55EnT30e.mjs.map +1 -0
- package/dist/serializer-BwbgHYJV.mjs +116 -0
- package/dist/serializer-BwbgHYJV.mjs.map +1 -0
- package/dist/streaming/index.d.ts +2 -0
- package/dist/streaming/read-only.d.ts +38 -0
- package/dist/streaming/write-only.d.ts +47 -0
- package/dist/streaming.mjs +612 -0
- package/dist/streaming.mjs.map +1 -0
- package/dist/styles/alignment.d.ts +33 -0
- package/dist/styles/alignment.schema.d.ts +3 -0
- package/dist/styles/borders.d.ts +40 -0
- package/dist/styles/borders.schema.d.ts +4 -0
- package/dist/styles/cell-style.d.ts +270 -0
- package/dist/styles/colors.d.ts +128 -0
- package/dist/styles/colors.schema.d.ts +3 -0
- package/dist/styles/differential.d.ts +41 -0
- package/dist/styles/fills.d.ts +54 -0
- package/dist/styles/fills.schema.d.ts +6 -0
- package/dist/styles/fonts.d.ts +44 -0
- package/dist/styles/fonts.schema.d.ts +3 -0
- package/dist/styles/index.d.ts +21 -0
- package/dist/styles/named-styles.d.ts +52 -0
- package/dist/styles/numbers.d.ts +39 -0
- package/dist/styles/numbers.schema.d.ts +3 -0
- package/dist/styles/protection.d.ts +9 -0
- package/dist/styles/protection.schema.d.ts +3 -0
- package/dist/styles/stylesheet-reader.d.ts +7 -0
- package/dist/styles/stylesheet-writer.d.ts +3 -0
- package/dist/styles/stylesheet.d.ts +95 -0
- package/dist/styles.mjs +4 -0
- package/dist/stylesheet-writer-C2eRmn22.mjs +8624 -0
- package/dist/stylesheet-writer-C2eRmn22.mjs.map +1 -0
- package/dist/table-DkX6UniA.mjs +113 -0
- package/dist/table-DkX6UniA.mjs.map +1 -0
- package/dist/tree-Bbs1C8Rc.mjs +192 -0
- package/dist/tree-Bbs1C8Rc.mjs.map +1 -0
- package/dist/units-rOMQqXh2.mjs +41 -0
- package/dist/units-rOMQqXh2.mjs.map +1 -0
- package/dist/user-shapes-DfmCGKB0.mjs +252 -0
- package/dist/user-shapes-DfmCGKB0.mjs.map +1 -0
- package/dist/utf8-D91g1XTG.mjs +143 -0
- package/dist/utf8-D91g1XTG.mjs.map +1 -0
- package/dist/utils/coordinate.d.ts +103 -0
- package/dist/utils/css.d.ts +18 -0
- package/dist/utils/datetime.d.ts +38 -0
- package/dist/utils/escape.d.ts +34 -0
- package/dist/utils/exceptions.d.ts +34 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/inference.d.ts +24 -0
- package/dist/utils/stable-stringify.d.ts +7 -0
- package/dist/utils/units.d.ts +14 -0
- package/dist/utils/utf8.d.ts +1 -0
- package/dist/utils.mjs +39 -0
- package/dist/utils.mjs.map +1 -0
- package/dist/workbook/calc-properties.d.ts +47 -0
- package/dist/workbook/defined-names.d.ts +121 -0
- package/dist/workbook/file-recovery.d.ts +11 -0
- package/dist/workbook/file-sharing.d.ts +14 -0
- package/dist/workbook/file-version.d.ts +13 -0
- package/dist/workbook/function-groups.d.ts +10 -0
- package/dist/workbook/index.d.ts +24 -0
- package/dist/workbook/protection.d.ts +35 -0
- package/dist/workbook/shared-strings.d.ts +57 -0
- package/dist/workbook/smart-tags.d.ts +13 -0
- package/dist/workbook/views.d.ts +89 -0
- package/dist/workbook/workbook-properties.d.ts +57 -0
- package/dist/workbook/workbook.d.ts +643 -0
- package/dist/workbook-HGYNRBlV.mjs +636 -0
- package/dist/workbook-HGYNRBlV.mjs.map +1 -0
- package/dist/workbook.mjs +58 -0
- package/dist/workbook.mjs.map +1 -0
- package/dist/worksheet/auto-filter.d.ts +34 -0
- package/dist/worksheet/cell-range.d.ts +121 -0
- package/dist/worksheet/comments-xml.d.ts +24 -0
- package/dist/worksheet/comments.d.ts +13 -0
- package/dist/worksheet/conditional-formatting.d.ts +150 -0
- package/dist/worksheet/custom-sheet-views.d.ts +43 -0
- package/dist/worksheet/data-consolidate.d.ts +29 -0
- package/dist/worksheet/data-validations.d.ts +72 -0
- package/dist/worksheet/dimensions.d.ts +40 -0
- package/dist/worksheet/errors.d.ts +40 -0
- package/dist/worksheet/hyperlinks.d.ts +42 -0
- package/dist/worksheet/index.d.ts +46 -0
- package/dist/worksheet/ole-objects.d.ts +37 -0
- package/dist/worksheet/page-setup.d.ts +173 -0
- package/dist/worksheet/phonetic.d.ts +11 -0
- package/dist/worksheet/properties.d.ts +34 -0
- package/dist/worksheet/protected-ranges.d.ts +19 -0
- package/dist/worksheet/protection.d.ts +44 -0
- package/dist/worksheet/reader.d.ts +38 -0
- package/dist/worksheet/scenarios.d.ts +36 -0
- package/dist/worksheet/smart-tags.d.ts +23 -0
- package/dist/worksheet/sort-state.d.ts +28 -0
- package/dist/worksheet/table-xml.d.ts +5 -0
- package/dist/worksheet/table.d.ts +80 -0
- package/dist/worksheet/views.d.ts +47 -0
- package/dist/worksheet/web-publish.d.ts +21 -0
- package/dist/worksheet/worksheet.d.ts +935 -0
- package/dist/worksheet/writer.d.ts +72 -0
- package/dist/worksheet-CmCNoIgD.mjs +1726 -0
- package/dist/worksheet-CmCNoIgD.mjs.map +1 -0
- package/dist/worksheet.mjs +247 -0
- package/dist/worksheet.mjs.map +1 -0
- package/dist/writer-DspzfkNA.mjs +221 -0
- package/dist/writer-DspzfkNA.mjs.map +1 -0
- package/dist/xml/index.d.ts +10 -0
- package/dist/xml/iterparse.d.ts +22 -0
- package/dist/xml/namespaces.d.ts +91 -0
- package/dist/xml/parser.d.ts +7 -0
- package/dist/xml/serializer.d.ts +14 -0
- package/dist/xml/stream-writer.d.ts +39 -0
- package/dist/xml/tree.d.ts +37 -0
- package/dist/xml.mjs +140 -0
- package/dist/xml.mjs.map +1 -0
- package/dist/zip/decompression-guard.d.ts +70 -0
- package/dist/zip/index.d.ts +6 -0
- package/dist/zip/random-access-reader.d.ts +16 -0
- package/dist/zip/reader.d.ts +45 -0
- package/dist/zip/writer.d.ts +65 -0
- package/dist/zip/zip64-patch.d.ts +12 -0
- package/dist/zip.mjs +3 -0
- package/package.json +147 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Excel epoch identifier. */
|
|
2
|
+
export type ExcelEpoch = 'windows' | 'mac';
|
|
3
|
+
/** 1899-12-30 (UTC) — the Windows / 1900-system epoch in ms. */
|
|
4
|
+
export declare const WINDOWS_EPOCH_MS: number;
|
|
5
|
+
/** 1904-01-01 (UTC) — the Mac / 1904-system epoch in ms. */
|
|
6
|
+
export declare const MAC_EPOCH_MS: number;
|
|
7
|
+
/**
|
|
8
|
+
* Convert an Excel serial date into a JS `Date` (UTC). The fractional part is
|
|
9
|
+
* treated as a fraction of a day. For Windows 1900 the leap-bug compensation
|
|
10
|
+
* kicks in for serials in [0, 60).
|
|
11
|
+
*/
|
|
12
|
+
export declare function excelToDate(serial: number, opts?: {
|
|
13
|
+
epoch?: ExcelEpoch;
|
|
14
|
+
}): Date;
|
|
15
|
+
/**
|
|
16
|
+
* Convert a JS `Date` into an Excel serial. The Date is read in UTC. On Windows
|
|
17
|
+
* 1900, dates ≤ 1900-02-28 get a -1 day correction to account for Excel's
|
|
18
|
+
* phantom leap day.
|
|
19
|
+
*/
|
|
20
|
+
export declare function dateToExcel(date: Date, opts?: {
|
|
21
|
+
epoch?: ExcelEpoch;
|
|
22
|
+
}): number;
|
|
23
|
+
/** Excel duration serial (fraction of a day) → milliseconds. */
|
|
24
|
+
export declare function excelToDuration(serial: number): number;
|
|
25
|
+
/** Milliseconds → Excel duration serial (fraction of a day). */
|
|
26
|
+
export declare function durationToExcel(ms: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Parse an ISO-8601 / W3CDTF datetime string into a `Date`. Same grammar as
|
|
29
|
+
* `new Date(string)`; the wrapper just adds typed error reporting and a
|
|
30
|
+
* stricter "must be a recognised ISO" guard.
|
|
31
|
+
*/
|
|
32
|
+
export declare function fromIso8601(s: string): Date;
|
|
33
|
+
/**
|
|
34
|
+
* Format a `Date` as ISO-8601 with second precision in UTC. Trims the
|
|
35
|
+
* millisecond fragment that `Date.toISOString()` always produces, so the output
|
|
36
|
+
* matches Excel / openpyxl's W3CDTF style.
|
|
37
|
+
*/
|
|
38
|
+
export declare function toIso8601(d: Date): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escape a string for safe storage in an OOXML cell. Already-escaped
|
|
3
|
+
* sequences (`_xHHHH_`) are protected by escaping their leading
|
|
4
|
+
* underscore; illegal codepoints are replaced with their `_xHHHH_`
|
|
5
|
+
* representation.
|
|
6
|
+
*/
|
|
7
|
+
export declare function escapeCellString(s: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Inverse of {@link escapeCellString}. Looking from left to right
|
|
10
|
+
* we replace any `_xHHHH_` sequence with the corresponding code unit;
|
|
11
|
+
* the protected `_x005F_` becomes a literal underscore which the
|
|
12
|
+
* subsequent replacements skip safely (replace's regex is non-overlapping).
|
|
13
|
+
*/
|
|
14
|
+
export declare function unescapeCellString(s: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Escape a string for safe placement in an XML text node. Replaces the three
|
|
17
|
+
* codepoints that would otherwise terminate the text region or open a markup
|
|
18
|
+
* sequence (`&`, `<`, `>`); `"` and `'` are not legal markup terminators
|
|
19
|
+
* inside text and stay verbatim.
|
|
20
|
+
*/
|
|
21
|
+
export declare function escapeXmlText(s: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Escape a string for safe placement inside a `"`-quoted XML attribute.
|
|
24
|
+
* Handles `&`, `<`, `>` and the `"` that would otherwise close the value.
|
|
25
|
+
*
|
|
26
|
+
* Note: this deliberately does NOT escape `\r` / `\n` / `\t` to numeric
|
|
27
|
+
* character references. XML 1.0 attribute-value normalisation would
|
|
28
|
+
* collapse them to spaces in theory, but the parser used on the read side
|
|
29
|
+
* (fast-xml-parser) does not decode numeric character references, so a
|
|
30
|
+
* write-then-read round-trip would surface the literal `	` instead of
|
|
31
|
+
* recovering the original tab. Leaving the whitespace bytes literal keeps
|
|
32
|
+
* the round-trip stable and matches what Excel itself emits.
|
|
33
|
+
*/
|
|
34
|
+
export declare function escapeXmlAttr(s: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface OpenXmlErrorOptions {
|
|
2
|
+
/** Underlying cause; preserved on the standard `cause` property. */
|
|
3
|
+
cause?: unknown;
|
|
4
|
+
}
|
|
5
|
+
export declare class OpenXmlError extends Error {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
constructor(message: string, options?: OpenXmlErrorOptions);
|
|
8
|
+
}
|
|
9
|
+
/** Thrown for ZIP, file system, network or stream-level failures. */
|
|
10
|
+
export declare class OpenXmlIoError extends OpenXmlError {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
}
|
|
13
|
+
/** Thrown when an OOXML payload violates structural / schema invariants. */
|
|
14
|
+
export declare class OpenXmlSchemaError extends OpenXmlError {
|
|
15
|
+
readonly name = "OpenXmlSchemaError";
|
|
16
|
+
}
|
|
17
|
+
/** Thrown when a workbook is structurally valid OOXML but semantically broken. */
|
|
18
|
+
export declare class OpenXmlInvalidWorkbookError extends OpenXmlError {
|
|
19
|
+
readonly name = "OpenXmlInvalidWorkbookError";
|
|
20
|
+
}
|
|
21
|
+
/** Thrown for features the port has chosen not to implement (yet). */
|
|
22
|
+
export declare class OpenXmlNotImplementedError extends OpenXmlError {
|
|
23
|
+
readonly name = "OpenXmlNotImplementedError";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Thrown when an archive trips the decompression-bomb safeguards configured on
|
|
27
|
+
* {@link openZip} / {@link loadWorkbook} / {@link loadWorkbookStream}. Subclass
|
|
28
|
+
* of {@link OpenXmlIoError} so existing `catch (OpenXmlIoError)` paths still
|
|
29
|
+
* see it, while letting callers branch on bomb-specific recovery (reject the
|
|
30
|
+
* upload, log a security event, etc.).
|
|
31
|
+
*/
|
|
32
|
+
export declare class OpenXmlDecompressionBombError extends OpenXmlIoError {
|
|
33
|
+
readonly name = "OpenXmlDecompressionBombError";
|
|
34
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { CellCoordinate, CellCoordinateNumeric, CellRangeBoundaries } from './coordinate';
|
|
2
|
+
export { boundariesToRangeString, columnIndexFromLetter, columnLetterFromIndex, coordinateFromString, coordinateToTuple, formatSheetQualifiedRef, isValidCellRef, isValidColumnLetter, isValidColumnNumber, isValidRangeRef, isValidRowNumber, MAX_COL, MAX_ROW, parseSheetRange, rangeBoundaries, tupleToCoordinate, } from './coordinate';
|
|
3
|
+
export type { ExcelEpoch } from './datetime';
|
|
4
|
+
export { dateToExcel, durationToExcel, excelToDate, excelToDuration, fromIso8601, MAC_EPOCH_MS, toIso8601, WINDOWS_EPOCH_MS, } from './datetime';
|
|
5
|
+
export { cssRecordToInlineStyle } from './css';
|
|
6
|
+
export { escapeCellString, unescapeCellString } from './escape';
|
|
7
|
+
export type { OpenXmlErrorOptions } from './exceptions';
|
|
8
|
+
export { OpenXmlDecompressionBombError, OpenXmlError, OpenXmlInvalidWorkbookError, OpenXmlIoError, OpenXmlNotImplementedError, OpenXmlSchemaError, } from './exceptions';
|
|
9
|
+
export type { CellDataType } from './inference';
|
|
10
|
+
export { ERROR_CODES, inferCellType } from './inference';
|
|
11
|
+
export { cmFromEmu, EMU_PER_CM, EMU_PER_INCH, EMU_PER_PIXEL, EMU_PER_POINT, emuFromCm, emuFromInch, emuFromPoint, emuFromPx, inchFromEmu, pixelToPoint, pointFromEmu, pointToPixel, pxFromEmu, } from './units';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OOXML `t` attribute values. Note that 'inlineStr' is treated
|
|
3
|
+
* separately — the writer chooses between 's' (shared string) and
|
|
4
|
+
* 'inlineStr' based on workbook settings, not the value itself.
|
|
5
|
+
*/
|
|
6
|
+
export type CellDataType = 'n' | 's' | 'b' | 'd' | 'f' | 'e';
|
|
7
|
+
/** Excel error tokens. Anything outside this set is treated as a string. */
|
|
8
|
+
export declare const ERROR_CODES: ReadonlySet<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Infer the cell `t` attribute for a runtime value.
|
|
11
|
+
*
|
|
12
|
+
* - `boolean` → 'b'
|
|
13
|
+
* - `number` → 'n' (incl. integer numerics; date inference is left to
|
|
14
|
+
* the caller because Excel decides on type via the cell's number
|
|
15
|
+
* format, not the raw value)
|
|
16
|
+
* - `Date` → 'd'
|
|
17
|
+
* - string starting with `=` → 'f' (formula)
|
|
18
|
+
* - string in {@link ERROR_CODES} → 'e'
|
|
19
|
+
* - any other string → 's'
|
|
20
|
+
* - `null` / `undefined` → 'n' (empty)
|
|
21
|
+
*
|
|
22
|
+
* Throws nothing — returns 'n' as the no-information fallback.
|
|
23
|
+
*/
|
|
24
|
+
export declare function inferCellType(value: unknown): CellDataType;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stringify `value` with object keys sorted recursively. Equal logical
|
|
3
|
+
* values produce the same string regardless of insertion order; arrays
|
|
4
|
+
* preserve their element order. Circular references throw (the error
|
|
5
|
+
* comes straight from JSON.stringify's stack-overflow check).
|
|
6
|
+
*/
|
|
7
|
+
export declare function stableStringify(value: unknown): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const EMU_PER_INCH = 914400;
|
|
2
|
+
export declare const EMU_PER_CM = 360000;
|
|
3
|
+
export declare const EMU_PER_PIXEL = 9525;
|
|
4
|
+
export declare const EMU_PER_POINT = 12700;
|
|
5
|
+
export declare function emuFromPx(px: number): number;
|
|
6
|
+
export declare function pxFromEmu(emu: number): number;
|
|
7
|
+
export declare function emuFromCm(cm: number): number;
|
|
8
|
+
export declare function cmFromEmu(emu: number): number;
|
|
9
|
+
export declare function emuFromInch(inch: number): number;
|
|
10
|
+
export declare function inchFromEmu(emu: number): number;
|
|
11
|
+
export declare function emuFromPoint(pt: number): number;
|
|
12
|
+
export declare function pointFromEmu(emu: number): number;
|
|
13
|
+
export declare function pointToPixel(pt: number, dpi?: number): number;
|
|
14
|
+
export declare function pixelToPoint(px: number, dpi?: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function utf8ByteLength(s: string): number;
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { a as OpenXmlNotImplementedError, i as OpenXmlIoError, n as OpenXmlError, o as OpenXmlSchemaError, r as OpenXmlInvalidWorkbookError, t as OpenXmlDecompressionBombError } from "./exceptions-D-CFwxgm.mjs";
|
|
2
|
+
import { a as columnLetterFromIndex, c as formatSheetQualifiedRef, d as isValidColumnNumber, f as isValidRangeRef, g as tupleToCoordinate, h as rangeBoundaries, i as columnIndexFromLetter, l as isValidCellRef, m as parseSheetRange, n as MAX_ROW, o as coordinateFromString, p as isValidRowNumber, r as boundariesToRangeString, s as coordinateToTuple, t as MAX_COL, u as isValidColumnLetter } from "./coordinate-96Ecci4d.mjs";
|
|
3
|
+
import { n as inferCellType, t as ERROR_CODES } from "./inference-B3ES3KEJ.mjs";
|
|
4
|
+
import { a as cmFromEmu, c as emuFromPoint, d as pixelToPoint, f as pointFromEmu, i as EMU_PER_POINT, l as emuFromPx, m as pxFromEmu, n as EMU_PER_INCH, o as emuFromCm, p as pointToPixel, r as EMU_PER_PIXEL, s as emuFromInch, t as EMU_PER_CM, u as inchFromEmu } from "./units-rOMQqXh2.mjs";
|
|
5
|
+
import { i as unescapeCellString, t as escapeCellString } from "./escape-DFTE7ZJc.mjs";
|
|
6
|
+
import { a as excelToDate, c as toIso8601, i as durationToExcel, n as WINDOWS_EPOCH_MS, o as excelToDuration, r as dateToExcel, s as fromIso8601, t as MAC_EPOCH_MS } from "./datetime-B2ySVlXt.mjs";
|
|
7
|
+
//#region src/utils/css.ts
|
|
8
|
+
/**
|
|
9
|
+
* Serialize a CSS-property record to an inline-style declaration string
|
|
10
|
+
* (`prop1: val1; prop2: val2`). Properties are alphabetised so the
|
|
11
|
+
* output is deterministic across runs.
|
|
12
|
+
*
|
|
13
|
+
* - Empty record returns `''`.
|
|
14
|
+
* - Empty-string values are skipped (treat as "unset").
|
|
15
|
+
* - Values containing `;` are dropped — they would terminate the
|
|
16
|
+
* declaration early and risk attribute-injection in `style="…"`
|
|
17
|
+
* contexts. Callers should pre-escape user data; this is a
|
|
18
|
+
* defensive last line.
|
|
19
|
+
*
|
|
20
|
+
* The returned string is suitable for direct interpolation into an
|
|
21
|
+
* HTML `style="…"` attribute *after* the usual attribute-value HTML
|
|
22
|
+
* escaping (no `&` / `"` injection here — this only guards against
|
|
23
|
+
* stray semicolons).
|
|
24
|
+
*/
|
|
25
|
+
function cssRecordToInlineStyle(record) {
|
|
26
|
+
if (!record) return "";
|
|
27
|
+
const parts = [];
|
|
28
|
+
for (const key of Object.keys(record).sort()) {
|
|
29
|
+
const value = record[key];
|
|
30
|
+
if (value === void 0 || value === "") continue;
|
|
31
|
+
if (value.includes(";")) continue;
|
|
32
|
+
parts.push(`${key}: ${value}`);
|
|
33
|
+
}
|
|
34
|
+
return parts.join("; ");
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { EMU_PER_CM, EMU_PER_INCH, EMU_PER_PIXEL, EMU_PER_POINT, ERROR_CODES, MAC_EPOCH_MS, MAX_COL, MAX_ROW, OpenXmlDecompressionBombError, OpenXmlError, OpenXmlInvalidWorkbookError, OpenXmlIoError, OpenXmlNotImplementedError, OpenXmlSchemaError, WINDOWS_EPOCH_MS, boundariesToRangeString, cmFromEmu, columnIndexFromLetter, columnLetterFromIndex, coordinateFromString, coordinateToTuple, cssRecordToInlineStyle, dateToExcel, durationToExcel, emuFromCm, emuFromInch, emuFromPoint, emuFromPx, escapeCellString, excelToDate, excelToDuration, formatSheetQualifiedRef, fromIso8601, inchFromEmu, inferCellType, isValidCellRef, isValidColumnLetter, isValidColumnNumber, isValidRangeRef, isValidRowNumber, parseSheetRange, pixelToPoint, pointFromEmu, pointToPixel, pxFromEmu, rangeBoundaries, toIso8601, tupleToCoordinate, unescapeCellString };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils/css.ts"],"sourcesContent":["// CSS-record → inline-style serializer.\n//\n// Companion to the `*ToCss` style helpers (fontToCss / fillToCss /\n// borderToCss / alignmentToCss / cellStyleToCss): once a caller has\n// merged the partials into a `Record<string, string>`, this turns it\n// into a stable `style=\"…\"` attribute value for HTML preview.\n\n/**\n * Serialize a CSS-property record to an inline-style declaration string\n * (`prop1: val1; prop2: val2`). Properties are alphabetised so the\n * output is deterministic across runs.\n *\n * - Empty record returns `''`.\n * - Empty-string values are skipped (treat as \"unset\").\n * - Values containing `;` are dropped — they would terminate the\n * declaration early and risk attribute-injection in `style=\"…\"`\n * contexts. Callers should pre-escape user data; this is a\n * defensive last line.\n *\n * The returned string is suitable for direct interpolation into an\n * HTML `style=\"…\"` attribute *after* the usual attribute-value HTML\n * escaping (no `&` / `\"` injection here — this only guards against\n * stray semicolons).\n */\nexport function cssRecordToInlineStyle(record: Record<string, string> | undefined): string {\n if (!record) return '';\n const parts: string[] = [];\n for (const key of Object.keys(record).sort()) {\n const value = record[key];\n if (value === undefined || value === '') continue;\n if (value.includes(';')) continue;\n parts.push(`${key}: ${value}`);\n }\n return parts.join('; ');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,uBAAuB,QAAoD;CACzF,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,EAAE,KAAK,GAAG;EAC5C,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAA,KAAa,UAAU,IAAI;EACzC,IAAI,MAAM,SAAS,GAAG,GAAG;EACzB,MAAM,KAAK,GAAG,IAAI,IAAI,OAAO;CAC/B;CACA,OAAO,MAAM,KAAK,IAAI;AACxB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type CalcMode = 'manual' | 'auto' | 'autoNoTable';
|
|
2
|
+
export type RefMode = 'A1' | 'R1C1';
|
|
3
|
+
export interface CalcProperties {
|
|
4
|
+
/** Excel build/calc-engine identifier; OpenOffice sets 191621, Excel 2016+ 162913 etc. */
|
|
5
|
+
calcId?: number;
|
|
6
|
+
calcMode?: CalcMode;
|
|
7
|
+
/** Force a full recalc when the workbook is loaded. Excel default `true` for safety. */
|
|
8
|
+
fullCalcOnLoad?: boolean;
|
|
9
|
+
refMode?: RefMode;
|
|
10
|
+
/** Allow circular references via iterative calculation. */
|
|
11
|
+
iterate?: boolean;
|
|
12
|
+
iterateCount?: number;
|
|
13
|
+
iterateDelta?: number;
|
|
14
|
+
/** Use full 15-digit precision (vs. displayed precision). */
|
|
15
|
+
fullPrecision?: boolean;
|
|
16
|
+
calcCompleted?: boolean;
|
|
17
|
+
/** Run a recalc on save. */
|
|
18
|
+
calcOnSave?: boolean;
|
|
19
|
+
/** Use multi-threaded calculation. */
|
|
20
|
+
concurrentCalc?: boolean;
|
|
21
|
+
concurrentManualCount?: number;
|
|
22
|
+
/** Force a full recalc on next interaction. */
|
|
23
|
+
forceFullCalc?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const makeCalcProperties: (opts?: CalcProperties) => CalcProperties;
|
|
26
|
+
import type { Workbook } from './workbook';
|
|
27
|
+
/**
|
|
28
|
+
* Set the recalculation mode. `'auto'` is Excel's default;
|
|
29
|
+
* `'manual'` requires F9 to recompute formulas; `'autoNoTable'`
|
|
30
|
+
* recomputes everything except data-table cells.
|
|
31
|
+
*/
|
|
32
|
+
export declare const setCalcMode: (wb: Workbook, mode: CalcMode) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Toggle iterative calculation (Excel's "Enable iterative calculation"
|
|
35
|
+
* option). When `enable` is true and `count` / `delta` are provided,
|
|
36
|
+
* they replace the default Excel limits (100 iterations, 0.001 delta).
|
|
37
|
+
*/
|
|
38
|
+
export declare const setIterativeCalc: (wb: Workbook, enable: boolean, opts?: {
|
|
39
|
+
count?: number;
|
|
40
|
+
delta?: number;
|
|
41
|
+
}) => void;
|
|
42
|
+
/** Toggle "Recalculate workbook before saving" (workbook-level). */
|
|
43
|
+
export declare const setCalcOnSave: (wb: Workbook, on: boolean) => void;
|
|
44
|
+
/** Toggle "Recalculate workbook on load" — forces a full recalc on open. */
|
|
45
|
+
export declare const setFullCalcOnLoad: (wb: Workbook, on: boolean) => void;
|
|
46
|
+
/** Toggle "Set precision as displayed" (false = full 15-digit precision). */
|
|
47
|
+
export declare const setFullPrecision: (wb: Workbook, on: boolean) => void;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export interface DefinedName {
|
|
2
|
+
/** Identifier — `_xlnm.Print_Area` for built-ins, otherwise user-chosen. */
|
|
3
|
+
name: string;
|
|
4
|
+
/** The formula expression the name points at. */
|
|
5
|
+
value: string;
|
|
6
|
+
/** 0-based sheet index for sheet-scope names; undefined → workbook-scope. */
|
|
7
|
+
scope?: number;
|
|
8
|
+
/** Hidden from the Name Manager when true. */
|
|
9
|
+
hidden?: boolean;
|
|
10
|
+
/** Optional human-readable description. */
|
|
11
|
+
comment?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function makeDefinedName(opts: Partial<DefinedName> & {
|
|
14
|
+
name: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}): DefinedName;
|
|
17
|
+
import { type CellRangeBoundaries } from '../utils/coordinate';
|
|
18
|
+
import type { Worksheet } from '../worksheet/worksheet';
|
|
19
|
+
import type { Workbook } from './workbook';
|
|
20
|
+
/**
|
|
21
|
+
* One parsed leg of a defined name's value. Defined-name values can be
|
|
22
|
+
* comma-separated multi-range expressions (e.g. `_xlnm.Print_Titles` sets
|
|
23
|
+
* `Sheet!$1:$1,Sheet!$A:$A`); this represents one such leg.
|
|
24
|
+
*/
|
|
25
|
+
export interface DefinedNameTarget {
|
|
26
|
+
sheet: string;
|
|
27
|
+
range: string;
|
|
28
|
+
bounds: CellRangeBoundaries;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Add a workbook-scope or sheet-scope defined name. If a defined name with the
|
|
32
|
+
* same `name` (and `scope`) already exists, it's replaced — Excel allows one
|
|
33
|
+
* workbook-scope and one per-sheet-scope name, but not two with the same scope.
|
|
34
|
+
* Returns the resulting `DefinedName`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const addDefinedName: (wb: Workbook, opts: Partial<DefinedName> & {
|
|
37
|
+
name: string;
|
|
38
|
+
value: string;
|
|
39
|
+
}) => DefinedName;
|
|
40
|
+
/**
|
|
41
|
+
* High-level: register a defined name pointing at a worksheet range. Combines
|
|
42
|
+
* {@link getRangeAddress} (sheet-qualified, properly quoted) with {@link
|
|
43
|
+
* addDefinedName}, so the caller doesn't have to assemble the formula string by
|
|
44
|
+
* hand.
|
|
45
|
+
*
|
|
46
|
+
* Pass `opts.localToSheet: true` to scope the name to the worksheet (instead of
|
|
47
|
+
* the workbook). Re-using the same `name` + scope replaces the previous entry
|
|
48
|
+
* (Excel's per-scope-uniqueness rule).
|
|
49
|
+
*
|
|
50
|
+
* Throws when `localToSheet: true` is set but the worksheet isn't on
|
|
51
|
+
* `wb.sheets` — that would be a stale Worksheet reference.
|
|
52
|
+
*/
|
|
53
|
+
export declare const addDefinedNameForRange: (wb: Workbook, name: string, ws: Worksheet, range: string, opts?: {
|
|
54
|
+
localToSheet?: boolean;
|
|
55
|
+
hidden?: boolean;
|
|
56
|
+
comment?: string;
|
|
57
|
+
}) => DefinedName;
|
|
58
|
+
/** Look up a defined name by identifier and (optional) sheet scope. */
|
|
59
|
+
export declare const getDefinedName: (wb: Workbook, name: string, scope?: number) => DefinedName | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Resolve a defined name's `value` into one or more {@link DefinedNameTarget}s.
|
|
62
|
+
* Comma-separated values (e.g. `_xlnm.Print_Titles` typically sets
|
|
63
|
+
* `Sheet!$1:$1,Sheet!$A:$A`) yield one entry per leg; a plain `Sheet!A1:B5`
|
|
64
|
+
* yields a single-element array.
|
|
65
|
+
*
|
|
66
|
+
* Returns `undefined` when the name doesn't exist; throws when the value can't
|
|
67
|
+
* be parsed (e.g. a constant or a non-range formula — defined names are
|
|
68
|
+
* sometimes used for things like `=42` or `=SUM(A:A)` which aren't ranges).
|
|
69
|
+
*/
|
|
70
|
+
export declare const getDefinedNameTarget: (wb: Workbook, name: string, scope?: number) => DefinedNameTarget[] | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Remove a defined name by identifier + scope. Returns true if any entry was
|
|
73
|
+
* removed.
|
|
74
|
+
*/
|
|
75
|
+
export declare const removeDefinedName: (wb: Workbook, name: string, scope?: number) => boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Read-only snapshot of every defined name. Pass `{ scope }` to narrow to
|
|
78
|
+
* workbook-scope (`scope: undefined`) or one specific sheet (`scope: 0`) — omit
|
|
79
|
+
* the option entirely to list all.
|
|
80
|
+
*/
|
|
81
|
+
export declare const listDefinedNames: (wb: Workbook, opts?: {
|
|
82
|
+
scope?: number | "workbook" | "all";
|
|
83
|
+
}) => ReadonlyArray<DefinedName>;
|
|
84
|
+
/**
|
|
85
|
+
* Bulk-remove every defined name matching `predicate`. Returns the count
|
|
86
|
+
* removed. Mirrors {@link removeDataValidations} on worksheets.
|
|
87
|
+
*/
|
|
88
|
+
export declare const removeDefinedNames: (wb: Workbook, predicate: (d: DefinedName) => boolean) => number;
|
|
89
|
+
/**
|
|
90
|
+
* Rename a defined name, scoped or workbook-scope. Returns `true` when an entry
|
|
91
|
+
* was renamed. Throws when `newName` is already taken with the same scope
|
|
92
|
+
* (Excel forbids duplicates within a scope).
|
|
93
|
+
*/
|
|
94
|
+
export declare const renameDefinedName: (wb: Workbook, oldName: string, newName: string, scope?: number) => boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Read-only snapshot of every `_xlnm.Print_Area` defined name. Each entry is
|
|
97
|
+
* the raw DefinedName carrying `scope` (sheet index) and `value` (the
|
|
98
|
+
* print-area expression like `'Sheet1'!$A$1:$D$10`).
|
|
99
|
+
*/
|
|
100
|
+
export declare const listPrintAreas: (wb: Workbook) => ReadonlyArray<DefinedName>;
|
|
101
|
+
/**
|
|
102
|
+
* Read-only snapshot of every `_xlnm.Print_Titles` defined name. Each entry's
|
|
103
|
+
* `value` is the title-row / title-col expression Excel re-uses on every
|
|
104
|
+
* printed page.
|
|
105
|
+
*/
|
|
106
|
+
export declare const listPrintTitles: (wb: Workbook) => ReadonlyArray<DefinedName>;
|
|
107
|
+
/**
|
|
108
|
+
* Define the print-area for a given sheet. Excel uses the built-in
|
|
109
|
+
* `_xlnm.Print_Area` defined name with sheet scope.
|
|
110
|
+
*/
|
|
111
|
+
export declare const setPrintArea: (wb: Workbook, sheetIndex: number, ref: string) => DefinedName;
|
|
112
|
+
/**
|
|
113
|
+
* Define print-title rows / columns on a sheet. Excel uses the
|
|
114
|
+
* `_xlnm.Print_Titles` defined name. Pass `rows` ("$1:$1") to repeat row 1 on
|
|
115
|
+
* every printed page; `cols` ("$A:$A") to repeat column A.
|
|
116
|
+
*/
|
|
117
|
+
export declare const setPrintTitles: (wb: Workbook, sheetIndex: number, opts: {
|
|
118
|
+
rows?: string;
|
|
119
|
+
cols?: string;
|
|
120
|
+
sheetName: string;
|
|
121
|
+
}) => DefinedName;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface FileRecoveryProperties {
|
|
2
|
+
/** True after an autorecover save — Excel uses it to display the recovery banner. */
|
|
3
|
+
autoRecover?: boolean;
|
|
4
|
+
/** Persisted crash-recovery flag. */
|
|
5
|
+
crashSave?: boolean;
|
|
6
|
+
/** Mark the file as "data extracted from a damaged workbook". */
|
|
7
|
+
dataExtractLoad?: boolean;
|
|
8
|
+
/** Workbook was repaired during load. */
|
|
9
|
+
repairLoad?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const makeFileRecoveryProperties: (opts?: FileRecoveryProperties) => FileRecoveryProperties;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface FileSharing {
|
|
2
|
+
/** Mark the workbook as "Read-only recommended" — Excel pops a dialog on open. */
|
|
3
|
+
readOnlyRecommended?: boolean;
|
|
4
|
+
/** Author name attached to the read/write password. */
|
|
5
|
+
userName?: string;
|
|
6
|
+
/** Legacy 16-bit hex hash of the reservation password. */
|
|
7
|
+
reservationPassword?: string;
|
|
8
|
+
/** Modern hash quad — algorithmName + hashValue + saltValue + spinCount. */
|
|
9
|
+
algorithmName?: string;
|
|
10
|
+
hashValue?: string;
|
|
11
|
+
saltValue?: string;
|
|
12
|
+
spinCount?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const makeFileSharing: (opts?: FileSharing) => FileSharing;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface FileVersion {
|
|
2
|
+
/** Application that last saved the workbook ("xl" for Excel). */
|
|
3
|
+
appName?: string;
|
|
4
|
+
/** Build number of the last editor (e.g. "7.5210"). */
|
|
5
|
+
lastEdited?: string;
|
|
6
|
+
/** Build number of the lowest editor (oldest Excel that touched the file). */
|
|
7
|
+
lowestEdited?: string;
|
|
8
|
+
/** Internal "rolled-up build" number. */
|
|
9
|
+
rupBuild?: string;
|
|
10
|
+
/** GUID identifying the file content (Excel uses it to detect re-saves). */
|
|
11
|
+
codeName?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const makeFileVersion: (opts?: FileVersion) => FileVersion;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface FunctionGroup {
|
|
2
|
+
name: string;
|
|
3
|
+
}
|
|
4
|
+
export interface FunctionGroups {
|
|
5
|
+
/** Number of built-in groups Excel reserves before user entries (default 16). */
|
|
6
|
+
builtInGroupCount?: number;
|
|
7
|
+
groups: FunctionGroup[];
|
|
8
|
+
}
|
|
9
|
+
export declare const makeFunctionGroup: (name: string) => FunctionGroup;
|
|
10
|
+
export declare const makeFunctionGroups: (opts?: Partial<FunctionGroups>) => FunctionGroups;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type { CellSummary, SheetRef, SheetState, Workbook, WorkbookOverview, WorkbookSheetOverview, WorkbookStats, } from './workbook';
|
|
2
|
+
export { addChartsheet, addWorksheet, createWorkbook, describeWorkbook, getActiveSheet, getCellAtAddress, getCellSummary, getChartsheet, getSheet, getSheetState, getWorkbookCellsByKind, getWorkbookStats, iterWorksheets, listCustomXmlParts, moveSheet, removeSheet, renameSheet, setActiveSheet, setCellAtAddress, setSheetState, sheetNames, } from './workbook';
|
|
3
|
+
export type { DefinedName, DefinedNameTarget } from './defined-names';
|
|
4
|
+
export { addDefinedName, getDefinedName, getDefinedNameTarget, listDefinedNames, makeDefinedName, removeDefinedName, } from './defined-names';
|
|
5
|
+
export type { WorkbookProtection } from './protection';
|
|
6
|
+
export { makeWorkbookProtection } from './protection';
|
|
7
|
+
export type { SharedStringEntry, SharedStringsTable } from './shared-strings';
|
|
8
|
+
export { addSharedString, getSharedStringAt, getSharedStringIndex, makeSharedStrings, sharedStringCount, } from './shared-strings';
|
|
9
|
+
export type { CustomViewShowComments, CustomViewShowObjects, CustomWorkbookView, WorkbookView, WorkbookViewVisibility, } from './views';
|
|
10
|
+
export { makeCustomWorkbookView, makeWorkbookView } from './views';
|
|
11
|
+
export type { CalcMode, CalcProperties, RefMode } from './calc-properties';
|
|
12
|
+
export { makeCalcProperties } from './calc-properties';
|
|
13
|
+
export type { ShowObjectsMode, UpdateLinksMode, WorkbookProperties, } from './workbook-properties';
|
|
14
|
+
export { makeWorkbookProperties } from './workbook-properties';
|
|
15
|
+
export type { FileVersion } from './file-version';
|
|
16
|
+
export { makeFileVersion } from './file-version';
|
|
17
|
+
export type { FileSharing } from './file-sharing';
|
|
18
|
+
export { makeFileSharing } from './file-sharing';
|
|
19
|
+
export type { FileRecoveryProperties } from './file-recovery';
|
|
20
|
+
export { makeFileRecoveryProperties } from './file-recovery';
|
|
21
|
+
export type { SmartTagProperties, SmartTagShowMode, SmartTagType } from './smart-tags';
|
|
22
|
+
export { makeSmartTagProperties, makeSmartTagType } from './smart-tags';
|
|
23
|
+
export type { FunctionGroup, FunctionGroups } from './function-groups';
|
|
24
|
+
export { makeFunctionGroup, makeFunctionGroups } from './function-groups';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface WorkbookProtection {
|
|
2
|
+
/** Legacy 16-bit hex hash of the workbook password ("CC1A" etc.). */
|
|
3
|
+
workbookPassword?: string;
|
|
4
|
+
workbookPasswordCharacterSet?: string;
|
|
5
|
+
workbookAlgorithmName?: string;
|
|
6
|
+
workbookHashValue?: string;
|
|
7
|
+
workbookSaltValue?: string;
|
|
8
|
+
workbookSpinCount?: number;
|
|
9
|
+
/** Legacy 16-bit hex hash of the revisions-tracking password. */
|
|
10
|
+
revisionsPassword?: string;
|
|
11
|
+
revisionsPasswordCharacterSet?: string;
|
|
12
|
+
revisionsAlgorithmName?: string;
|
|
13
|
+
revisionsHashValue?: string;
|
|
14
|
+
revisionsSaltValue?: string;
|
|
15
|
+
revisionsSpinCount?: number;
|
|
16
|
+
/** Lock add/delete/move/rename/hide of sheets. */
|
|
17
|
+
lockStructure?: boolean;
|
|
18
|
+
/** Lock the workbook window size and position. */
|
|
19
|
+
lockWindows?: boolean;
|
|
20
|
+
/** Lock revision tracking — enabled with the "Track Changes" feature. */
|
|
21
|
+
lockRevision?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const makeWorkbookProtection: (opts?: WorkbookProtection) => WorkbookProtection;
|
|
24
|
+
import type { Workbook } from './workbook';
|
|
25
|
+
/**
|
|
26
|
+
* Lock the workbook with Excel's "Protect Workbook → Structure" default
|
|
27
|
+
* (lockStructure=true). Pass `overrides` to also lock windows /
|
|
28
|
+
* revision-tracking, or to attach a password-hash quad. Plaintext password
|
|
29
|
+
* support is deferred until the D-tier hashing helper lands.
|
|
30
|
+
*/
|
|
31
|
+
export declare const protectWorkbook: (wb: Workbook, overrides?: Partial<WorkbookProtection>) => WorkbookProtection;
|
|
32
|
+
/** Drop the workbook-protection record entirely. */
|
|
33
|
+
export declare const unprotectWorkbook: (wb: Workbook) => void;
|
|
34
|
+
/** True iff `lockStructure === true`. */
|
|
35
|
+
export declare const isWorkbookProtected: (wb: Workbook) => boolean;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { RichText } from '../cell/rich-text';
|
|
2
|
+
/** A single SST entry: either a plain string or a rich-text run array. */
|
|
3
|
+
export type SharedStringEntry = string | {
|
|
4
|
+
kind: 'rich-text';
|
|
5
|
+
runs: RichText;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Mutable shared-strings accumulator + lookup table. The same shape is used
|
|
9
|
+
* during read (just populate `entries`) and write (call `addSharedString` from
|
|
10
|
+
* the worksheet writer; emit to bytes at the end).
|
|
11
|
+
*/
|
|
12
|
+
export interface SharedStringsTable {
|
|
13
|
+
/** Insertion-ordered list of unique entries. */
|
|
14
|
+
entries: SharedStringEntry[];
|
|
15
|
+
/** Reverse lookup keyed by literal text — rich-text entries skip this map. */
|
|
16
|
+
index: Map<string, number>;
|
|
17
|
+
}
|
|
18
|
+
export declare function makeSharedStrings(): SharedStringsTable;
|
|
19
|
+
/**
|
|
20
|
+
* Insert a string and return its index. Idempotent: calling with the same value
|
|
21
|
+
* twice gives the same index. Empty strings are deduped just like everything
|
|
22
|
+
* else.
|
|
23
|
+
*/
|
|
24
|
+
export declare function addSharedString(table: SharedStringsTable, value: string): number;
|
|
25
|
+
/** Look up a shared-string index by its literal text. Returns `undefined` for unknown values. */
|
|
26
|
+
export declare function getSharedStringIndex(table: SharedStringsTable, value: string): number | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Read a shared-string by its 0-based index. Returns `undefined` for
|
|
29
|
+
* out-of-range. Rich-text entries surface their concatenated plain text so
|
|
30
|
+
* callers that want only the textual body don't need to know about the
|
|
31
|
+
* discriminated union.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getSharedStringAt(table: SharedStringsTable, index: number): string | undefined;
|
|
34
|
+
/** Number of unique entries in the SST. */
|
|
35
|
+
export declare function sharedStringCount(table: SharedStringsTable): number;
|
|
36
|
+
/**
|
|
37
|
+
* Parse a `xl/sharedStrings.xml` payload. Returns the table directly (rather
|
|
38
|
+
* than just the array) so the worksheet writer can keep appending to it without
|
|
39
|
+
* rebuilding the index.
|
|
40
|
+
*
|
|
41
|
+
* Rich-text runs are preserved as their full per-run formatting so
|
|
42
|
+
* round-tripping a file with rich text doesn't drop the styling.
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseSharedStringsXml(bytes: Uint8Array | string): SharedStringsTable;
|
|
45
|
+
/**
|
|
46
|
+
* Serialise a SharedStringsTable to its OOXML bytes. The `count` attribute
|
|
47
|
+
* tracks total references (we don't know that here so we report the same as
|
|
48
|
+
* `uniqueCount` — readers tolerate the discrepancy and Excel ignores `count` in
|
|
49
|
+
* practice). `uniqueCount` always matches `entries.length`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function sharedStringsToBytes(table: SharedStringsTable): Uint8Array;
|
|
52
|
+
export declare function serializeSharedStrings(table: SharedStringsTable): string;
|
|
53
|
+
/**
|
|
54
|
+
* Serialise a sequence of `<r>...<r>` runs — shared by the SST `<si>` writer
|
|
55
|
+
* and the worksheet's inline-string (`t="inlineStr"`) cell writer.
|
|
56
|
+
*/
|
|
57
|
+
export declare function serializeRichTextRuns(runs: import('../cell/rich-text').RichText): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type SmartTagShowMode = 'all' | 'noIndicator';
|
|
2
|
+
export interface SmartTagProperties {
|
|
3
|
+
/** Embed smart tags into the workbook on save. */
|
|
4
|
+
embed?: boolean;
|
|
5
|
+
show?: SmartTagShowMode;
|
|
6
|
+
}
|
|
7
|
+
export interface SmartTagType {
|
|
8
|
+
namespaceUri?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const makeSmartTagProperties: (opts?: SmartTagProperties) => SmartTagProperties;
|
|
13
|
+
export declare const makeSmartTagType: (opts?: SmartTagType) => SmartTagType;
|