@evotecit/officeimo 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1219 -2
- package/bundles/officeimo-canopyx.js +11286 -0
- package/bundles/officeimo-canopyx.mjs +11185 -0
- package/bundles/officeimo-csv.js +1254 -0
- package/bundles/officeimo-csv.mjs +1229 -0
- package/bundles/officeimo-datatables.js +11572 -0
- package/bundles/officeimo-datatables.mjs +11470 -0
- package/bundles/officeimo-execution.js +1503 -0
- package/bundles/officeimo-execution.mjs +1479 -0
- package/bundles/officeimo-pdf.js +6564 -0
- package/bundles/officeimo-pdf.mjs +6502 -0
- package/bundles/officeimo-xlsx.js +5333 -0
- package/bundles/officeimo-xlsx.mjs +5279 -0
- package/bundles/officeimo.js +11022 -0
- package/bundles/officeimo.mjs +10924 -0
- package/dist/core/dates.d.ts +1 -0
- package/dist/core/dates.js +16 -0
- package/dist/core/errors.d.ts +12 -0
- package/dist/core/errors.js +31 -0
- package/dist/core/grouped-report.d.ts +87 -0
- package/dist/core/grouped-report.js +252 -0
- package/dist/core/index.d.ts +72 -0
- package/dist/core/index.js +37 -0
- package/dist/core/iteration.d.ts +7 -0
- package/dist/core/iteration.js +149 -0
- package/dist/core/limits.d.ts +7 -0
- package/dist/core/limits.js +56 -0
- package/dist/core/links.d.ts +5 -0
- package/dist/core/links.js +14 -0
- package/dist/core/presentation.d.ts +29 -0
- package/dist/core/presentation.js +59 -0
- package/dist/core/progress.d.ts +1 -0
- package/dist/core/progress.js +10 -0
- package/dist/core/sinks.d.ts +33 -0
- package/dist/core/sinks.js +101 -0
- package/dist/core/table.d.ts +8 -0
- package/dist/core/table.js +1 -0
- package/dist/core/value-text.d.ts +7 -0
- package/dist/core/value-text.js +13 -0
- package/dist/csv/index.d.ts +44 -0
- package/dist/csv/index.js +133 -0
- package/dist/csv/options.d.ts +1 -0
- package/dist/csv/options.js +8 -0
- package/dist/csv/structured-rows.d.ts +3 -0
- package/dist/csv/structured-rows.js +15 -0
- package/dist/execution/host.d.ts +5 -0
- package/dist/execution/host.js +164 -0
- package/dist/execution/index.d.ts +3 -0
- package/dist/execution/index.js +2 -0
- package/dist/execution/protocol.d.ts +48 -0
- package/dist/execution/protocol.js +173 -0
- package/dist/execution/types.d.ts +42 -0
- package/dist/execution/types.js +1 -0
- package/dist/execution/worker.d.ts +3 -0
- package/dist/execution/worker.js +147 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +14 -0
- package/dist/integrations/canopyx/dates.d.ts +1 -0
- package/dist/integrations/canopyx/dates.js +34 -0
- package/dist/integrations/canopyx/index.d.ts +10 -0
- package/dist/integrations/canopyx/index.js +45 -0
- package/dist/integrations/canopyx/source.d.ts +3 -0
- package/dist/integrations/canopyx/source.js +116 -0
- package/dist/integrations/canopyx/types.d.ts +83 -0
- package/dist/integrations/canopyx/types.js +1 -0
- package/dist/integrations/datatables/api.d.ts +1 -0
- package/dist/integrations/datatables/api.js +27 -0
- package/dist/integrations/datatables/headings.d.ts +1 -0
- package/dist/integrations/datatables/headings.js +65 -0
- package/dist/integrations/datatables/index.d.ts +12 -0
- package/dist/integrations/datatables/index.js +167 -0
- package/dist/integrations/datatables/snapshot.d.ts +3 -0
- package/dist/integrations/datatables/snapshot.js +206 -0
- package/dist/integrations/datatables/types.d.ts +98 -0
- package/dist/integrations/datatables/types.js +1 -0
- package/dist/integrations/options.d.ts +13 -0
- package/dist/integrations/options.js +34 -0
- package/dist/internal/capture.d.ts +4 -0
- package/dist/internal/capture.js +14 -0
- package/dist/internal/columns.d.ts +27 -0
- package/dist/internal/columns.js +1 -0
- package/dist/internal/crc32.d.ts +6 -0
- package/dist/internal/crc32.js +17 -0
- package/dist/internal/export-values.d.ts +3 -0
- package/dist/internal/export-values.js +14 -0
- package/dist/internal/rows.d.ts +6 -0
- package/dist/internal/rows.js +68 -0
- package/dist/internal/table-spans.d.ts +11 -0
- package/dist/internal/table-spans.js +58 -0
- package/dist/internal/totals.d.ts +15 -0
- package/dist/internal/totals.js +42 -0
- package/dist/opc/index.d.ts +67 -0
- package/dist/opc/index.js +233 -0
- package/dist/opc/properties.d.ts +15 -0
- package/dist/opc/properties.js +18 -0
- package/dist/opc/uri.d.ts +5 -0
- package/dist/opc/uri.js +41 -0
- package/dist/pdf/annotations.d.ts +1 -0
- package/dist/pdf/annotations.js +38 -0
- package/dist/pdf/binary.d.ts +6 -0
- package/dist/pdf/binary.js +24 -0
- package/dist/pdf/document-drawings.d.ts +15 -0
- package/dist/pdf/document-drawings.js +237 -0
- package/dist/pdf/document-grouped.d.ts +1 -0
- package/dist/pdf/document-grouped.js +194 -0
- package/dist/pdf/document-images.d.ts +19 -0
- package/dist/pdf/document-images.js +125 -0
- package/dist/pdf/document-types.d.ts +160 -0
- package/dist/pdf/document-types.js +1 -0
- package/dist/pdf/document-vectors.d.ts +11 -0
- package/dist/pdf/document-vectors.js +77 -0
- package/dist/pdf/document.d.ts +9 -0
- package/dist/pdf/document.js +270 -0
- package/dist/pdf/drawing-types.d.ts +53 -0
- package/dist/pdf/drawing-types.js +1 -0
- package/dist/pdf/font-resources.d.ts +43 -0
- package/dist/pdf/font-resources.js +201 -0
- package/dist/pdf/font-support.d.ts +1 -0
- package/dist/pdf/font-support.js +60 -0
- package/dist/pdf/font.d.ts +17 -0
- package/dist/pdf/font.js +56 -0
- package/dist/pdf/grouped-table.d.ts +6 -0
- package/dist/pdf/grouped-table.js +40 -0
- package/dist/pdf/grouped-types.d.ts +34 -0
- package/dist/pdf/grouped-types.js +1 -0
- package/dist/pdf/grouped.d.ts +10 -0
- package/dist/pdf/grouped.js +37 -0
- package/dist/pdf/index.d.ts +22 -0
- package/dist/pdf/index.js +8 -0
- package/dist/pdf/inline-text.d.ts +30 -0
- package/dist/pdf/inline-text.js +142 -0
- package/dist/pdf/inline-types.d.ts +15 -0
- package/dist/pdf/inline-types.js +1 -0
- package/dist/pdf/list-layout.d.ts +6 -0
- package/dist/pdf/list-layout.js +49 -0
- package/dist/pdf/objects.d.ts +2 -0
- package/dist/pdf/objects.js +143 -0
- package/dist/pdf/outlines.d.ts +1 -0
- package/dist/pdf/outlines.js +55 -0
- package/dist/pdf/page-context.d.ts +1 -0
- package/dist/pdf/page-context.js +12 -0
- package/dist/pdf/pages.d.ts +1 -0
- package/dist/pdf/pages.js +679 -0
- package/dist/pdf/paragraph-layout.d.ts +19 -0
- package/dist/pdf/paragraph-layout.js +66 -0
- package/dist/pdf/paragraph-styles.d.ts +1 -0
- package/dist/pdf/paragraph-styles.js +66 -0
- package/dist/pdf/png.d.ts +9 -0
- package/dist/pdf/png.js +259 -0
- package/dist/pdf/preflight.d.ts +7 -0
- package/dist/pdf/preflight.js +32 -0
- package/dist/pdf/presentation-settings.d.ts +5 -0
- package/dist/pdf/presentation-settings.js +28 -0
- package/dist/pdf/providers/harfbuzz.d.ts +60 -0
- package/dist/pdf/providers/harfbuzz.js +112 -0
- package/dist/pdf/providers/unicode13-profile.d.ts +2 -0
- package/dist/pdf/providers/unicode13-profile.js +115 -0
- package/dist/pdf/section-types.d.ts +15 -0
- package/dist/pdf/section-types.js +40 -0
- package/dist/pdf/session.d.ts +25 -0
- package/dist/pdf/session.js +55 -0
- package/dist/pdf/settings.d.ts +15 -0
- package/dist/pdf/settings.js +171 -0
- package/dist/pdf/shaped-text.d.ts +5 -0
- package/dist/pdf/shaped-text.js +205 -0
- package/dist/pdf/standard-widths.d.ts +1 -0
- package/dist/pdf/standard-widths.js +317 -0
- package/dist/pdf/structure-parent-tree.d.ts +1 -0
- package/dist/pdf/structure-parent-tree.js +57 -0
- package/dist/pdf/structure.d.ts +6 -0
- package/dist/pdf/structure.js +250 -0
- package/dist/pdf/table-band-flow.d.ts +34 -0
- package/dist/pdf/table-band-flow.js +114 -0
- package/dist/pdf/table-band-plan.d.ts +10 -0
- package/dist/pdf/table-band-plan.js +85 -0
- package/dist/pdf/table-layout.d.ts +71 -0
- package/dist/pdf/table-layout.js +205 -0
- package/dist/pdf/table-structure.d.ts +1 -0
- package/dist/pdf/table-structure.js +92 -0
- package/dist/pdf/text-shaping-types.d.ts +39 -0
- package/dist/pdf/text-shaping-types.js +1 -0
- package/dist/pdf/text.d.ts +13 -0
- package/dist/pdf/text.js +96 -0
- package/dist/pdf/truetype-subset.d.ts +5 -0
- package/dist/pdf/truetype-subset.js +217 -0
- package/dist/pdf/truetype.d.ts +1 -0
- package/dist/pdf/truetype.js +235 -0
- package/dist/pdf/types.d.ts +169 -0
- package/dist/pdf/types.js +1 -0
- package/dist/pdf/write.d.ts +6 -0
- package/dist/pdf/write.js +57 -0
- package/dist/xlsx/attachments.d.ts +30 -0
- package/dist/xlsx/attachments.js +67 -0
- package/dist/xlsx/chart-bindings.d.ts +1 -0
- package/dist/xlsx/chart-bindings.js +122 -0
- package/dist/xlsx/chart-types.d.ts +73 -0
- package/dist/xlsx/chart-types.js +1 -0
- package/dist/xlsx/chart-xml.d.ts +2 -0
- package/dist/xlsx/chart-xml.js +103 -0
- package/dist/xlsx/charts.d.ts +1 -0
- package/dist/xlsx/charts.js +159 -0
- package/dist/xlsx/conditional-formatting.d.ts +1 -0
- package/dist/xlsx/conditional-formatting.js +158 -0
- package/dist/xlsx/conditional-types.d.ts +64 -0
- package/dist/xlsx/conditional-types.js +1 -0
- package/dist/xlsx/data-row-ranges.d.ts +5 -0
- package/dist/xlsx/data-row-ranges.js +39 -0
- package/dist/xlsx/differential-styles.d.ts +1 -0
- package/dist/xlsx/differential-styles.js +102 -0
- package/dist/xlsx/formula.d.ts +8 -0
- package/dist/xlsx/formula.js +104 -0
- package/dist/xlsx/grouped-layout.d.ts +61 -0
- package/dist/xlsx/grouped-layout.js +79 -0
- package/dist/xlsx/grouped.d.ts +16 -0
- package/dist/xlsx/grouped.js +161 -0
- package/dist/xlsx/index.d.ts +24 -0
- package/dist/xlsx/index.js +10 -0
- package/dist/xlsx/layout.d.ts +1 -0
- package/dist/xlsx/layout.js +186 -0
- package/dist/xlsx/options.d.ts +1 -0
- package/dist/xlsx/options.js +16 -0
- package/dist/xlsx/portable.d.ts +27 -0
- package/dist/xlsx/portable.js +44 -0
- package/dist/xlsx/preservation.d.ts +1 -0
- package/dist/xlsx/preservation.js +60 -0
- package/dist/xlsx/ranges.d.ts +1 -0
- package/dist/xlsx/ranges.js +24 -0
- package/dist/xlsx/regions.d.ts +1 -0
- package/dist/xlsx/regions.js +97 -0
- package/dist/xlsx/structured-rows.d.ts +11 -0
- package/dist/xlsx/structured-rows.js +28 -0
- package/dist/xlsx/style-xml.d.ts +1 -0
- package/dist/xlsx/style-xml.js +6 -0
- package/dist/xlsx/styles.d.ts +70 -0
- package/dist/xlsx/styles.js +203 -0
- package/dist/xlsx/table.d.ts +12 -0
- package/dist/xlsx/table.js +35 -0
- package/dist/xlsx/types.d.ts +180 -0
- package/dist/xlsx/types.js +1 -0
- package/dist/xlsx/validation-types.d.ts +18 -0
- package/dist/xlsx/validation-types.js +1 -0
- package/dist/xlsx/validation.d.ts +1 -0
- package/dist/xlsx/validation.js +92 -0
- package/dist/xlsx/values.d.ts +13 -0
- package/dist/xlsx/values.js +86 -0
- package/dist/xlsx/workbook.d.ts +50 -0
- package/dist/xlsx/workbook.js +452 -0
- package/dist/xlsx/worksheet.d.ts +71 -0
- package/dist/xlsx/worksheet.js +700 -0
- package/dist/xlsx/write.d.ts +15 -0
- package/dist/xlsx/write.js +47 -0
- package/dist/xml/index.d.ts +24 -0
- package/dist/xml/index.js +74 -0
- package/dist/zip/entry.d.ts +39 -0
- package/dist/zip/entry.js +122 -0
- package/dist/zip/index.d.ts +44 -0
- package/dist/zip/index.js +248 -0
- package/package.json +104 -4
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { ColumnSettings, CellValue, StreamOptions, TableSpanRows } from "../core/index.js";
|
|
2
|
+
import type { ProjectedColumn } from "../internal/columns.js";
|
|
3
|
+
import type { ExportLimits } from "../core/limits.js";
|
|
4
|
+
import type { InvalidCharacterPolicy } from "../xml/index.js";
|
|
5
|
+
import type { Compression } from "../zip/index.js";
|
|
6
|
+
import type { PackagePart, Relationship } from "../opc/index.js";
|
|
7
|
+
import type { CoreProperties, AppProperties } from "../opc/index.js";
|
|
8
|
+
import type { Cell } from "./values.js";
|
|
9
|
+
import type { CellStyle } from "./styles.js";
|
|
10
|
+
import type { Hyperlink } from "./attachments.js";
|
|
11
|
+
import type { ExportValue } from "../core/presentation.js";
|
|
12
|
+
import type { ConditionalFormat } from "./conditional-types.js";
|
|
13
|
+
import type { FormulaCell } from "./formula.js";
|
|
14
|
+
import type { ListValidation } from "./validation-types.js";
|
|
15
|
+
export type XlsxRow = readonly (ExportValue | Cell | FormulaCell)[] | Readonly<Record<string, ExportValue | Cell | FormulaCell>>;
|
|
16
|
+
export type XlsxRows = Iterable<XlsxRow> | AsyncIterable<XlsxRow>;
|
|
17
|
+
/** Advanced worksheet column with an optional style registered on its owning workbook. */
|
|
18
|
+
interface XlsxColumnSettings extends ColumnSettings {
|
|
19
|
+
readonly style?: number;
|
|
20
|
+
}
|
|
21
|
+
export type XlsxColumn<T = never> = ProjectedColumn<T, ExportValue | Cell | FormulaCell> & XlsxColumnSettings;
|
|
22
|
+
export interface CellWriterContext {
|
|
23
|
+
readonly column: XlsxColumn;
|
|
24
|
+
readonly rowIndex: number;
|
|
25
|
+
readonly worksheetRow: number;
|
|
26
|
+
readonly columnIndex: number;
|
|
27
|
+
readonly sheetName: string;
|
|
28
|
+
}
|
|
29
|
+
/** Convert domain column values to plain values or styled Cells; raw XML is never accepted. */
|
|
30
|
+
export type CellValueWriter = (value: CellValue, context: CellWriterContext) => ExportValue | Cell | FormulaCell;
|
|
31
|
+
/** Data indexes are zero-based. worksheetRow is the explicit one-based Excel coordinate. */
|
|
32
|
+
export interface RowStyleContext {
|
|
33
|
+
readonly rowIndex: number;
|
|
34
|
+
readonly worksheetRow: number;
|
|
35
|
+
readonly values: readonly CellValue[];
|
|
36
|
+
readonly sheetName: string;
|
|
37
|
+
}
|
|
38
|
+
export interface CellStyleContext extends RowStyleContext {
|
|
39
|
+
readonly value: CellValue;
|
|
40
|
+
readonly column: XlsxColumn;
|
|
41
|
+
readonly columnIndex: number;
|
|
42
|
+
}
|
|
43
|
+
/** Native Excel outline metadata for a serialized worksheet data row. */
|
|
44
|
+
export interface RowOutline {
|
|
45
|
+
/** Zero is a summary row; Excel supports at most seven nested detail levels. */
|
|
46
|
+
readonly level?: number;
|
|
47
|
+
readonly hidden?: boolean;
|
|
48
|
+
/** Marks a summary row whose preceding detail rows are initially hidden. */
|
|
49
|
+
readonly collapsed?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** A real Excel table over this worksheet's header and data rows. Empty exports retain headers without a table part. */
|
|
52
|
+
export interface TableOptions {
|
|
53
|
+
readonly name?: string;
|
|
54
|
+
/** Built-in Excel TableStyleLight1..21, TableStyleMedium1..28 or TableStyleDark1..11. */
|
|
55
|
+
readonly style?: string;
|
|
56
|
+
readonly bandedRows?: boolean;
|
|
57
|
+
readonly bandedColumns?: boolean;
|
|
58
|
+
readonly firstColumn?: boolean;
|
|
59
|
+
readonly lastColumn?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface WorkbookOptions extends StreamOptions, CoreProperties {
|
|
62
|
+
/** Selected before rows are written. Streamed worksheets are completed in order. The caller owns the sink. */
|
|
63
|
+
readonly sink?: import("../core/sinks.js").ByteSink;
|
|
64
|
+
readonly limits?: WorkbookLimits;
|
|
65
|
+
readonly dateMode?: "local" | "utc";
|
|
66
|
+
readonly compression?: Compression;
|
|
67
|
+
readonly invalidCharacterPolicy?: InvalidCharacterPolicy;
|
|
68
|
+
readonly appProperties?: AppProperties;
|
|
69
|
+
readonly cellValueWriters?: Readonly<Record<string, CellValueWriter>>;
|
|
70
|
+
/** Reject by default. Preserve keeps a bounded preview and the full text in numbered overflow-sheet chunks. */
|
|
71
|
+
readonly oversizedText?: "reject" | "preserve";
|
|
72
|
+
}
|
|
73
|
+
export interface WorkbookLimits extends ExportLimits {
|
|
74
|
+
readonly maxStyles?: number;
|
|
75
|
+
readonly maxSheets?: number;
|
|
76
|
+
/** Retained UTF-16 units before the overflow sheet is emitted; defaults to 4,000,000. */
|
|
77
|
+
readonly maxOverflowCharacters?: number;
|
|
78
|
+
readonly maxHyperlinks?: number;
|
|
79
|
+
readonly maxImageBytes?: number;
|
|
80
|
+
readonly maxBufferedCells?: number;
|
|
81
|
+
/** UTF-16 units of encoded row XML retained during width sampling, including markup. */
|
|
82
|
+
readonly maxBufferedCharacters?: number;
|
|
83
|
+
/** Includes generated title/group merges across the workbook; defaults to 10,000. */
|
|
84
|
+
readonly maxMergedRanges?: number;
|
|
85
|
+
/** Workbook-wide rule count, including data-only rules on empty sheets; defaults to 1,000. */
|
|
86
|
+
readonly maxConditionalFormats?: number;
|
|
87
|
+
/** Unique conditional differential styles across the workbook; defaults to 1,000. */
|
|
88
|
+
readonly maxDifferentialStyles?: number;
|
|
89
|
+
/** Native charts across the workbook; defaults to 100. Snapshot charts also own a hidden data sheet. */
|
|
90
|
+
readonly maxCharts?: number;
|
|
91
|
+
/** Numeric cached data points across all chart series; defaults to 100,000. */
|
|
92
|
+
readonly maxChartPoints?: number;
|
|
93
|
+
/** Captured category/name/title/axis/label text across all charts; defaults to 1,000,000 UTF-16 units. */
|
|
94
|
+
readonly maxChartTextCharacters?: number;
|
|
95
|
+
/** Authored formula text across all cells; defaults to 1,000,000 UTF-16 units. */
|
|
96
|
+
readonly maxFormulaCharacters?: number;
|
|
97
|
+
/** Inline-list rules across all worksheets, including empty sources; defaults to 1,000. */
|
|
98
|
+
readonly maxDataValidations?: number;
|
|
99
|
+
/** Captured list items and messages across all rules; defaults to 1,000,000 UTF-16 units. */
|
|
100
|
+
readonly maxValidationTextCharacters?: number;
|
|
101
|
+
}
|
|
102
|
+
export interface XlsxExportResult {
|
|
103
|
+
readonly rows: number;
|
|
104
|
+
readonly sheets: number;
|
|
105
|
+
readonly bytes: number;
|
|
106
|
+
}
|
|
107
|
+
export interface SheetOptions<T = never> {
|
|
108
|
+
readonly columns?: readonly XlsxColumn<T>[];
|
|
109
|
+
readonly includeHeader?: boolean;
|
|
110
|
+
/** Replaces inferred group/leaf headings with a rectangular matrix; covered positions are null. */
|
|
111
|
+
readonly headerRows?: TableSpanRows;
|
|
112
|
+
readonly freezeHeader?: boolean;
|
|
113
|
+
readonly autoFilter?: boolean;
|
|
114
|
+
readonly boldHeader?: boolean;
|
|
115
|
+
readonly headerFill?: string;
|
|
116
|
+
readonly headerStyle?: number;
|
|
117
|
+
/** Presentation patches retain column number/date formats. The second data row gets this patch first. */
|
|
118
|
+
readonly alternatingRowStyle?: CellStyle;
|
|
119
|
+
readonly rowStyle?: (context: RowStyleContext) => CellStyle | undefined;
|
|
120
|
+
readonly cellStyle?: (context: CellStyleContext) => CellStyle | undefined;
|
|
121
|
+
/** Native row outlines, captured once during serialization. Requires an explicit maximum level. */
|
|
122
|
+
readonly rowOutline?: (context: RowStyleContext) => RowOutline | undefined;
|
|
123
|
+
/** Declared outline upper bound, from zero through seven; emitted before streamed rows. */
|
|
124
|
+
readonly maxOutlineLevel?: number;
|
|
125
|
+
readonly rowHeight?: number;
|
|
126
|
+
readonly headerHeight?: number;
|
|
127
|
+
/** Fallback width in characters. Native tables default to 20 when no column width is supplied. */
|
|
128
|
+
readonly defaultColumnWidth?: number;
|
|
129
|
+
readonly freezeColumns?: number;
|
|
130
|
+
readonly table?: TableOptions;
|
|
131
|
+
readonly autoSize?: AutoSizeOptions;
|
|
132
|
+
readonly footer?: FooterOptions;
|
|
133
|
+
readonly print?: PrintOptions;
|
|
134
|
+
readonly title?: ReportTitle;
|
|
135
|
+
/** Uppercase A1 ranges within exported rows/columns. Covered cells must be empty; ranges cannot intersect a native table or another merge. */
|
|
136
|
+
readonly mergedCells?: readonly string[];
|
|
137
|
+
readonly hyperlinks?: readonly Hyperlink[];
|
|
138
|
+
readonly conditionalFormats?: readonly ConditionalFormat[];
|
|
139
|
+
readonly dataValidation?: readonly ListValidation[];
|
|
140
|
+
}
|
|
141
|
+
/** A single merged report title above grouped/leaf headings. Print repetition includes headings only. */
|
|
142
|
+
export interface ReportTitle {
|
|
143
|
+
readonly text: string;
|
|
144
|
+
readonly style?: CellStyle;
|
|
145
|
+
readonly height?: number;
|
|
146
|
+
}
|
|
147
|
+
/** Widths use a bounded leading sample and an approximate character count. Automatic sampling stops within buffer budgets; an explicit sampleRows fails when its sample exceeds them. */
|
|
148
|
+
export interface AutoSizeOptions {
|
|
149
|
+
/** Leading rows to inspect, through Excel's row capacity. Large explicit samples require matching buffer budgets. */
|
|
150
|
+
readonly sampleRows?: number;
|
|
151
|
+
readonly minWidth?: number;
|
|
152
|
+
readonly maxWidth?: number;
|
|
153
|
+
}
|
|
154
|
+
export type TotalOperation = "sum" | "count" | "average" | "min" | "max";
|
|
155
|
+
export interface FooterOptions {
|
|
156
|
+
/** Explicit rectangular footer, outside the native table. Cannot accompany values or totals. */
|
|
157
|
+
readonly rows?: TableSpanRows;
|
|
158
|
+
/** One explicit value per declared column; computed totals replace the corresponding value. */
|
|
159
|
+
readonly values?: readonly (ExportValue | Cell | FormulaCell)[];
|
|
160
|
+
readonly totals?: Readonly<Record<string, TotalOperation>>;
|
|
161
|
+
readonly style?: import("./styles.js").CellStyle;
|
|
162
|
+
}
|
|
163
|
+
export interface PrintOptions {
|
|
164
|
+
readonly paper?: "A4" | "Letter";
|
|
165
|
+
readonly orientation?: "portrait" | "landscape";
|
|
166
|
+
readonly fitToWidth?: number;
|
|
167
|
+
readonly fitToHeight?: number;
|
|
168
|
+
readonly repeatHeaders?: boolean;
|
|
169
|
+
readonly margins?: Readonly<Partial<Record<"left" | "right" | "top" | "bottom" | "header" | "footer", number>>>;
|
|
170
|
+
/** Literal center header/footer text. Ampersands are escaped, so Excel control codes are not interpreted. */
|
|
171
|
+
readonly header?: string;
|
|
172
|
+
readonly footer?: string;
|
|
173
|
+
}
|
|
174
|
+
export interface ExtraPart extends PackagePart {
|
|
175
|
+
/** Optional relationship to this part, from the workbook unless a source is supplied. */
|
|
176
|
+
readonly relationship?: Omit<Relationship, "target" | "external"> & {
|
|
177
|
+
readonly source?: string;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** An inline dropdown applied only to the selected exported data column, after its final row count is known. */
|
|
2
|
+
export interface ListValidation {
|
|
3
|
+
readonly type: "list";
|
|
4
|
+
/** One-based column number, or an unambiguous declared column key. */
|
|
5
|
+
readonly column: string | number;
|
|
6
|
+
/** Literal dropdown choices. Commas are not supported; the quoted list source must fit 255 UTF-16 units. */
|
|
7
|
+
readonly items: readonly string[];
|
|
8
|
+
/** Defaults to true, matching OfficeIMO.Excel.ValidationList. */
|
|
9
|
+
readonly allowBlank?: boolean;
|
|
10
|
+
/** Defaults to true. Excel applies the alert when the user edits a validated cell. */
|
|
11
|
+
readonly showErrorMessage?: boolean;
|
|
12
|
+
/** Defaults to stop. Warning and information alerts allow the user to accept a value outside the list. */
|
|
13
|
+
readonly errorStyle?: "stop" | "warning" | "information";
|
|
14
|
+
/** At most 32 XML-valid UTF-16 units. */
|
|
15
|
+
readonly errorTitle?: string;
|
|
16
|
+
/** At most 255 XML-valid UTF-16 units. */
|
|
17
|
+
readonly errorMessage?: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { OfficeIMOError } from "../core/errors.js";
|
|
2
|
+
import { checkAbort } from "../core/iteration.js";
|
|
3
|
+
import { cleanXml, escapeOoxmlAttribute, escapeXml } from "../xml/index.js";
|
|
4
|
+
import { fields, optionalBoolean } from "./differential-styles.js";
|
|
5
|
+
import { resolveDataColumn } from "./ranges.js";
|
|
6
|
+
import { dataRowReference } from "./data-row-ranges.js";
|
|
7
|
+
function message(value, maximum, name) {
|
|
8
|
+
if (value === undefined)
|
|
9
|
+
return undefined;
|
|
10
|
+
if (typeof value !== "string")
|
|
11
|
+
throw new TypeError(name + " must be text.");
|
|
12
|
+
if (value.length > maximum)
|
|
13
|
+
throw new RangeError(name + " exceeds " + maximum + " UTF-16 units.");
|
|
14
|
+
return cleanXml(value, "reject");
|
|
15
|
+
}
|
|
16
|
+
/** @internal Snapshot and validate before any source iteration or workbook registration. */
|
|
17
|
+
export function prepareDataValidations(rules, columns, availableCount = 1000, availableText = 1000000, signal) {
|
|
18
|
+
checkAbort(signal);
|
|
19
|
+
if (rules === undefined)
|
|
20
|
+
return Object.freeze({ rules: Object.freeze([]), count: 0, textCharacters: 0 });
|
|
21
|
+
if (!Array.isArray(rules))
|
|
22
|
+
throw new TypeError("dataValidation must be an array.");
|
|
23
|
+
const count = rules.length;
|
|
24
|
+
if (count > availableCount)
|
|
25
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxDataValidations exceeded.");
|
|
26
|
+
const prepared = [];
|
|
27
|
+
const usedColumns = new Set();
|
|
28
|
+
let textCharacters = 0;
|
|
29
|
+
const acceptText = (length) => {
|
|
30
|
+
if (textCharacters + length > availableText)
|
|
31
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxValidationTextCharacters exceeded.");
|
|
32
|
+
textCharacters += length;
|
|
33
|
+
};
|
|
34
|
+
for (let index = 0; index < count; index++) {
|
|
35
|
+
checkAbort(signal);
|
|
36
|
+
const rule = rules[index];
|
|
37
|
+
fields(rule, ["type", "column", "items", "allowBlank", "showErrorMessage", "errorStyle", "errorTitle", "errorMessage"], "data validation");
|
|
38
|
+
const { type, column, items, allowBlank, showErrorMessage, errorStyle, errorTitle, errorMessage } = rule;
|
|
39
|
+
if (type !== "list")
|
|
40
|
+
throw new TypeError("Only inline-list data validation is supported.");
|
|
41
|
+
const selected = resolveDataColumn(columns, column, "Validation");
|
|
42
|
+
if (usedColumns.has(selected))
|
|
43
|
+
throw new TypeError("A data column cannot have multiple validation rules.");
|
|
44
|
+
usedColumns.add(selected);
|
|
45
|
+
optionalBoolean(allowBlank, "allowBlank");
|
|
46
|
+
optionalBoolean(showErrorMessage, "showErrorMessage");
|
|
47
|
+
if (errorStyle !== undefined && !["stop", "warning", "information"].includes(errorStyle))
|
|
48
|
+
throw new TypeError("Unsupported validation error style.");
|
|
49
|
+
if (!Array.isArray(items))
|
|
50
|
+
throw new TypeError("Inline validation lists require a nonempty string array.");
|
|
51
|
+
// Even empty choices need separators. Bound the loop before observing any item getters.
|
|
52
|
+
const itemCount = items.length;
|
|
53
|
+
if (!itemCount)
|
|
54
|
+
throw new TypeError("Inline validation lists require a nonempty string array.");
|
|
55
|
+
if (itemCount > 254)
|
|
56
|
+
throw new RangeError("Inline validation lists must fit 255 UTF-16 units including quotes and separators.");
|
|
57
|
+
let formula = '"';
|
|
58
|
+
for (let item = 0; item < itemCount; item++) {
|
|
59
|
+
checkAbort(signal);
|
|
60
|
+
const value = items[item];
|
|
61
|
+
if (typeof value !== "string")
|
|
62
|
+
throw new TypeError("Inline validation choices must be strings.");
|
|
63
|
+
if (value.length > 253 || value.includes(","))
|
|
64
|
+
throw new RangeError("Inline validation choices cannot contain commas and must fit the 255-character list source.");
|
|
65
|
+
cleanXml(value, "reject");
|
|
66
|
+
const escaped = value.replace(/"/g, '""');
|
|
67
|
+
if (formula.length + (item ? 1 : 0) + escaped.length + 1 > 255)
|
|
68
|
+
throw new RangeError("Inline validation lists must fit 255 UTF-16 units including quotes and separators.");
|
|
69
|
+
formula += (item ? "," : "") + escaped;
|
|
70
|
+
}
|
|
71
|
+
formula += '"';
|
|
72
|
+
const title = message(errorTitle, 32, "Validation error title"), error = message(errorMessage, 255, "Validation error message");
|
|
73
|
+
acceptText(formula.length + (title?.length ?? 0) + (error?.length ?? 0));
|
|
74
|
+
const attributes = ' type="list" allowBlank="' + (allowBlank === false ? 0 : 1) + '" showErrorMessage="' + (showErrorMessage === false ? 0 : 1) +
|
|
75
|
+
'" errorStyle="' + (errorStyle ?? "stop") + '"' + (title === undefined ? "" : ' errorTitle="' + escapeOoxmlAttribute(title, "reject") + '"') +
|
|
76
|
+
(error === undefined ? "" : ' error="' + escapeOoxmlAttribute(error, "reject") + '"');
|
|
77
|
+
prepared.push(Object.freeze({ column: selected, attributes, formula }));
|
|
78
|
+
}
|
|
79
|
+
checkAbort(signal);
|
|
80
|
+
return Object.freeze({ rules: Object.freeze(prepared), count, textCharacters });
|
|
81
|
+
}
|
|
82
|
+
/** @internal Empty sources do not create validation over headings, totals or an artificial blank row. */
|
|
83
|
+
export function* dataValidationsXml(prepared, headerRows, dataRows, ranges) {
|
|
84
|
+
if (!prepared.count || !dataRows || ranges?.length === 0)
|
|
85
|
+
return;
|
|
86
|
+
yield '<dataValidations count="' + prepared.count + '">';
|
|
87
|
+
for (const rule of prepared.rules) {
|
|
88
|
+
const reference = dataRowReference(rule.column, rule.column, headerRows, dataRows, ranges);
|
|
89
|
+
yield '<dataValidation' + rule.attributes + ' sqref="' + reference + '"><formula1>' + escapeXml(rule.formula, "reject") + '</formula1></dataValidation>';
|
|
90
|
+
}
|
|
91
|
+
yield '</dataValidations>';
|
|
92
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { InvalidCharacterPolicy } from "../xml/index.js";
|
|
2
|
+
import type { CellValue } from "../core/index.js";
|
|
3
|
+
/** A typed value plus a workbook-local style index. */
|
|
4
|
+
export declare class Cell {
|
|
5
|
+
readonly value: CellValue;
|
|
6
|
+
readonly style?: number | undefined;
|
|
7
|
+
constructor(value: CellValue, style?: number | undefined);
|
|
8
|
+
}
|
|
9
|
+
export declare function cellText(value: unknown, policy?: InvalidCharacterPolicy): string;
|
|
10
|
+
export declare function inlineText(value: unknown, policy: InvalidCharacterPolicy): string;
|
|
11
|
+
export declare function columnName(index: number): string;
|
|
12
|
+
export declare function sheetName(requested: string, names: Set<string>, policy: InvalidCharacterPolicy, register?: boolean): string;
|
|
13
|
+
export declare function excelDate(date: Date, mode: "local" | "utc"): number | null;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { cleanXml, escapeXml } from "../xml/index.js";
|
|
2
|
+
import { assertExportValue, assertScalar } from "../core/presentation.js";
|
|
3
|
+
import { FormulaCell } from "./formula.js";
|
|
4
|
+
import { copyExportValue } from "../internal/export-values.js";
|
|
5
|
+
/** A typed value plus a workbook-local style index. */
|
|
6
|
+
export class Cell {
|
|
7
|
+
value;
|
|
8
|
+
style;
|
|
9
|
+
constructor(value, style) {
|
|
10
|
+
this.value = value;
|
|
11
|
+
this.style = style;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** @internal Advanced worksheets admit cells registered on their owning workbook. */
|
|
15
|
+
export function assertXlsxValue(value) {
|
|
16
|
+
if (value instanceof FormulaCell)
|
|
17
|
+
return;
|
|
18
|
+
if (value instanceof Cell)
|
|
19
|
+
assertScalar(value.value);
|
|
20
|
+
else
|
|
21
|
+
assertExportValue(value);
|
|
22
|
+
}
|
|
23
|
+
/** @internal Buffered samples and footer definitions capture mutable Date values. */
|
|
24
|
+
export function copyValue(value) {
|
|
25
|
+
if (value instanceof FormulaCell)
|
|
26
|
+
return value;
|
|
27
|
+
if (value instanceof Cell)
|
|
28
|
+
return Object.freeze(new Cell(copyExportValue(value.value), value.style));
|
|
29
|
+
return copyExportValue(value);
|
|
30
|
+
}
|
|
31
|
+
export function cellText(value, policy = "strip") {
|
|
32
|
+
const text = cleanXml(value, policy);
|
|
33
|
+
if (text.length > 32767)
|
|
34
|
+
throw new RangeError("Excel cell text exceeds 32,767 UTF-16 code units.");
|
|
35
|
+
return text;
|
|
36
|
+
}
|
|
37
|
+
export function inlineText(value, policy) {
|
|
38
|
+
const text = cellText(value, policy), node = (part) => '<t xml:space="preserve">' + escapeXml(part, policy) + '</t>';
|
|
39
|
+
// OOXML escapes are decoded per run. Splitting the initial underscore preserves literal text in both reader kinds.
|
|
40
|
+
return /_x[0-9a-f]{4}_/i.test(text)
|
|
41
|
+
? text.split(/(?<=_)(?=x[0-9a-f]{4}_)/gi).map(part => '<r>' + node(part) + '</r>').join("") : node(text);
|
|
42
|
+
}
|
|
43
|
+
export function columnName(index) {
|
|
44
|
+
if (!Number.isInteger(index) || index < 1 || index > 16384)
|
|
45
|
+
throw new RangeError("Column index must be from 1 through 16,384.");
|
|
46
|
+
let name = "";
|
|
47
|
+
while (index) {
|
|
48
|
+
index--;
|
|
49
|
+
name = String.fromCharCode(65 + index % 26) + name;
|
|
50
|
+
index = Math.floor(index / 26);
|
|
51
|
+
}
|
|
52
|
+
return name;
|
|
53
|
+
}
|
|
54
|
+
function clipName(text, length) { return text.slice(0, length).replace(/[\ud800-\udbff]$/, ""); }
|
|
55
|
+
export function sheetName(requested, names, policy, register = true) {
|
|
56
|
+
if (typeof requested !== "string")
|
|
57
|
+
throw new TypeError("Sheet name must be a string.");
|
|
58
|
+
// Validate and deduplicate the decoded literal value, before ST_Xstring attribute encoding.
|
|
59
|
+
// A requested _xHHHH_ token is literal text; the serializer protects its leading underscore.
|
|
60
|
+
let base = cleanXml(requested, policy).replace(/[\[\]:*?/\\]/g, "_").trim().replace(/^'+|'+$/g, "").trim();
|
|
61
|
+
if (!base)
|
|
62
|
+
base = "Sheet";
|
|
63
|
+
if (base.toLowerCase() === "history")
|
|
64
|
+
base += "_";
|
|
65
|
+
base = clipName(base, 31);
|
|
66
|
+
let name = base, suffix = 2;
|
|
67
|
+
while (names.has(name.toLowerCase())) {
|
|
68
|
+
const tail = " (" + suffix++ + ")";
|
|
69
|
+
name = clipName(base, 31 - tail.length) + tail;
|
|
70
|
+
}
|
|
71
|
+
if (register)
|
|
72
|
+
names.add(name.toLowerCase());
|
|
73
|
+
return name;
|
|
74
|
+
}
|
|
75
|
+
export function excelDate(date, mode) {
|
|
76
|
+
if (!Number.isFinite(date.getTime()))
|
|
77
|
+
return null;
|
|
78
|
+
const utc = mode === "utc", year = utc ? date.getUTCFullYear() : date.getFullYear();
|
|
79
|
+
if (year < 1900 || year > 9999)
|
|
80
|
+
throw new RangeError("Excel dates must be in years 1900 through 9999.");
|
|
81
|
+
const wall = new Date(0);
|
|
82
|
+
wall.setUTCFullYear(year, utc ? date.getUTCMonth() : date.getMonth(), utc ? date.getUTCDate() : date.getDate());
|
|
83
|
+
wall.setUTCHours(utc ? date.getUTCHours() : date.getHours(), utc ? date.getUTCMinutes() : date.getMinutes(), utc ? date.getUTCSeconds() : date.getSeconds(), utc ? date.getUTCMilliseconds() : date.getMilliseconds());
|
|
84
|
+
const time = wall.getTime();
|
|
85
|
+
return (time - Date.UTC(1899, 11, 31)) / 86400000 + (time >= Date.UTC(1900, 2, 1) ? 1 : 0);
|
|
86
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { StyleRegistry } from "./styles.js";
|
|
2
|
+
import { Worksheet } from "./worksheet.js";
|
|
3
|
+
import type { WorkbookOptions, SheetOptions, ExtraPart, XlsxExportResult } from "./types.js";
|
|
4
|
+
/** Streaming writer model; append rows through Worksheets, then finalize once. */
|
|
5
|
+
export declare class Workbook {
|
|
6
|
+
private portableValues;
|
|
7
|
+
readonly styles: StyleRegistry;
|
|
8
|
+
private readonly names;
|
|
9
|
+
private readonly sheets;
|
|
10
|
+
private readonly tableNames;
|
|
11
|
+
private tableCount;
|
|
12
|
+
private readonly writers;
|
|
13
|
+
private readonly package;
|
|
14
|
+
private state;
|
|
15
|
+
private result;
|
|
16
|
+
private completion;
|
|
17
|
+
private activeSheet;
|
|
18
|
+
private failure;
|
|
19
|
+
private overflow;
|
|
20
|
+
private links;
|
|
21
|
+
private imageBytes;
|
|
22
|
+
private bufferedBytes;
|
|
23
|
+
private mergedRanges;
|
|
24
|
+
private conditionalFormats;
|
|
25
|
+
private dataValidationCount;
|
|
26
|
+
private validationTextCharacters;
|
|
27
|
+
private formulaCharacters;
|
|
28
|
+
private hasAuthoredFormulas;
|
|
29
|
+
private readonly nativeCharts;
|
|
30
|
+
private chartSourceSheets;
|
|
31
|
+
private chartPoints;
|
|
32
|
+
private chartTextCharacters;
|
|
33
|
+
private registering;
|
|
34
|
+
/** Caller-owned property getters may run during capture; they cannot register another workbook object. */
|
|
35
|
+
private registration;
|
|
36
|
+
constructor(options?: WorkbookOptions);
|
|
37
|
+
private addXmlPart;
|
|
38
|
+
private workbookXml;
|
|
39
|
+
private checkSheetLimit;
|
|
40
|
+
private checkChartText;
|
|
41
|
+
private resolveChartBinding;
|
|
42
|
+
get worksheets(): readonly Worksheet[];
|
|
43
|
+
/** Total report data rows; excludes title/header/footer and preservation records. */
|
|
44
|
+
get rowCount(): number;
|
|
45
|
+
addWorksheet<T = never>(name: string, options?: SheetOptions<T>): Worksheet<T>;
|
|
46
|
+
addPart(part: ExtraPart): void;
|
|
47
|
+
/** Complete the archive and return counts. Does not close or dispose a caller-owned sink. */
|
|
48
|
+
finish(): Promise<XlsxExportResult>;
|
|
49
|
+
toBlob(): Promise<Blob>;
|
|
50
|
+
}
|