@cj-tech-master/excelts 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/README_zh.md +19 -0
- package/dist/browser/excelts.iife.js +1 -1
- package/dist/browser/excelts.iife.js.map +1 -1
- package/dist/browser/excelts.iife.min.js +1 -1
- package/dist/cjs/stream/xlsx/hyperlink-reader.js +1 -1
- package/dist/cjs/stream/xlsx/workbook-reader.js +7 -4
- package/dist/cjs/stream/xlsx/workbook-writer.js +37 -23
- package/dist/cjs/stream/xlsx/worksheet-reader.js +12 -8
- package/dist/cjs/stream/xlsx/worksheet-writer.js +12 -6
- package/dist/esm/stream/xlsx/hyperlink-reader.js +1 -1
- package/dist/esm/stream/xlsx/workbook-reader.js +7 -4
- package/dist/esm/stream/xlsx/workbook-writer.js +37 -23
- package/dist/esm/stream/xlsx/worksheet-reader.js +12 -8
- package/dist/esm/stream/xlsx/worksheet-writer.js +12 -6
- package/dist/types/doc/table.d.ts +2 -2
- package/dist/types/index.d.ts +3 -0
- package/dist/types/stream/xlsx/hyperlink-reader.d.ts +11 -11
- package/dist/types/stream/xlsx/workbook-reader.d.ts +125 -36
- package/dist/types/stream/xlsx/workbook-writer.d.ts +105 -22
- package/dist/types/stream/xlsx/worksheet-reader.d.ts +40 -22
- package/dist/types/stream/xlsx/worksheet-writer.d.ts +83 -49
- package/dist/types/types.d.ts +4 -16
- package/package.json +1 -1
|
@@ -1,44 +1,133 @@
|
|
|
1
1
|
import { EventEmitter } from "events";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { Readable } from "stream";
|
|
3
|
+
import { StylesXform } from "../../xlsx/xform/style/styles-xform.js";
|
|
4
|
+
import { WorksheetReader } from "./worksheet-reader.js";
|
|
5
|
+
import { HyperlinkReader } from "./hyperlink-reader.js";
|
|
6
|
+
import type { WorksheetState, Font, WorkbookProperties } from "../../types.js";
|
|
7
|
+
/** Internal options type that includes undocumented 'prep' value */
|
|
8
|
+
export interface InternalWorksheetOptions {
|
|
9
|
+
worksheets?: "emit" | "ignore" | "prep";
|
|
10
|
+
sharedStrings?: "cache" | "emit" | "ignore";
|
|
11
|
+
hyperlinks?: "cache" | "emit" | "ignore";
|
|
12
|
+
styles?: "cache" | "ignore";
|
|
13
|
+
entries?: "emit" | "ignore";
|
|
8
14
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
sharedStrings?: any[];
|
|
15
|
-
workbookRels?: any[];
|
|
16
|
-
properties?: any;
|
|
17
|
-
model?: any;
|
|
18
|
-
constructor(input: any, options?: WorkbookReaderOptions);
|
|
19
|
-
_getStream(input: any): any;
|
|
20
|
-
read(input?: any, options?: WorkbookReaderOptions): Promise<void>;
|
|
21
|
-
[Symbol.asyncIterator](): AsyncIterableIterator<any>;
|
|
22
|
-
parse(input?: any, options?: WorkbookReaderOptions): AsyncIterableIterator<{
|
|
23
|
-
eventType: string;
|
|
24
|
-
value: any;
|
|
15
|
+
/** Rich text item from shared strings */
|
|
16
|
+
export interface SharedStringRichText {
|
|
17
|
+
richText: Array<{
|
|
18
|
+
font: Partial<Font> | null;
|
|
19
|
+
text: string | null;
|
|
25
20
|
}>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
}
|
|
22
|
+
/** Shared string value - either plain text or rich text */
|
|
23
|
+
export type SharedStringValue = string | SharedStringRichText;
|
|
24
|
+
/** Relationship entry from workbook.xml.rels */
|
|
25
|
+
export interface WorkbookRelationship {
|
|
26
|
+
Id: string;
|
|
27
|
+
Target: string;
|
|
28
|
+
Type?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Sheet metadata from workbook.xml */
|
|
31
|
+
export interface SheetMetadata {
|
|
32
|
+
id: number;
|
|
33
|
+
name: string;
|
|
34
|
+
state?: WorksheetState;
|
|
35
|
+
rId: string;
|
|
36
|
+
}
|
|
37
|
+
/** Workbook model parsed from workbook.xml */
|
|
38
|
+
export interface WorkbookModel {
|
|
39
|
+
sheets?: SheetMetadata[];
|
|
40
|
+
properties?: Partial<WorkbookProperties>;
|
|
41
|
+
views?: unknown[];
|
|
42
|
+
definedNames?: unknown[];
|
|
43
|
+
}
|
|
44
|
+
/** Properties parsed from workbook.xml (workbookPr element) */
|
|
45
|
+
export interface WorkbookPropertiesXform {
|
|
46
|
+
model?: Partial<WorkbookProperties>;
|
|
47
|
+
}
|
|
48
|
+
/** Entry event payload */
|
|
49
|
+
interface EntryPayload {
|
|
50
|
+
type: "shared-strings" | "styles" | "workbook" | "worksheet" | "hyperlinks";
|
|
51
|
+
id?: string;
|
|
52
|
+
}
|
|
53
|
+
/** Parse event types */
|
|
54
|
+
export type ParseEventType = "shared-strings" | "worksheet" | "hyperlinks";
|
|
55
|
+
export interface SharedStringEvent {
|
|
56
|
+
eventType: "shared-strings";
|
|
57
|
+
value: {
|
|
30
58
|
index: number;
|
|
31
|
-
text:
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
59
|
+
text: SharedStringValue;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export interface WorksheetReadyEvent {
|
|
63
|
+
eventType: "worksheet";
|
|
64
|
+
value: WorksheetReader;
|
|
65
|
+
}
|
|
66
|
+
export interface HyperlinksEvent {
|
|
67
|
+
eventType: "hyperlinks";
|
|
68
|
+
value: HyperlinkReader;
|
|
69
|
+
}
|
|
70
|
+
export type ParseEvent = SharedStringEvent | WorksheetReadyEvent | HyperlinksEvent;
|
|
71
|
+
/**
|
|
72
|
+
* Options for WorkbookReader
|
|
73
|
+
*/
|
|
74
|
+
export interface WorkbookReaderOptions {
|
|
75
|
+
/**
|
|
76
|
+
* Specifies whether to emit worksheets ('emit') or not ('ignore').
|
|
77
|
+
* @default 'emit'
|
|
78
|
+
*/
|
|
79
|
+
worksheets?: "emit" | "ignore";
|
|
80
|
+
/**
|
|
81
|
+
* Specifies whether to cache shared strings ('cache'), emit them ('emit'), or ignore them ('ignore').
|
|
82
|
+
* @default 'cache'
|
|
83
|
+
*/
|
|
84
|
+
sharedStrings?: "cache" | "emit" | "ignore";
|
|
85
|
+
/**
|
|
86
|
+
* Specifies whether to cache hyperlinks ('cache'), emit them ('emit'), or ignore them ('ignore').
|
|
87
|
+
* @default 'ignore'
|
|
88
|
+
*/
|
|
89
|
+
hyperlinks?: "cache" | "emit" | "ignore";
|
|
90
|
+
/**
|
|
91
|
+
* Specifies whether to cache styles ('cache') or ignore them ('ignore').
|
|
92
|
+
* @default 'ignore'
|
|
93
|
+
*/
|
|
94
|
+
styles?: "cache" | "ignore";
|
|
95
|
+
/**
|
|
96
|
+
* Specifies whether to emit entries ('emit') or not ('ignore').
|
|
97
|
+
* @default 'ignore'
|
|
98
|
+
*/
|
|
99
|
+
entries?: "emit" | "ignore";
|
|
100
|
+
}
|
|
101
|
+
declare class WorkbookReader extends EventEmitter {
|
|
102
|
+
input: string | Readable;
|
|
103
|
+
options: {
|
|
104
|
+
worksheets: "emit" | "ignore";
|
|
105
|
+
sharedStrings: "cache" | "emit" | "ignore";
|
|
106
|
+
hyperlinks: "cache" | "emit" | "ignore";
|
|
107
|
+
styles: "cache" | "ignore";
|
|
108
|
+
entries: "emit" | "ignore";
|
|
109
|
+
};
|
|
110
|
+
styles: StylesXform;
|
|
111
|
+
stream?: Readable;
|
|
112
|
+
sharedStrings?: SharedStringValue[];
|
|
113
|
+
workbookRels?: WorkbookRelationship[];
|
|
114
|
+
properties?: WorkbookPropertiesXform;
|
|
115
|
+
model?: WorkbookModel;
|
|
116
|
+
constructor(input: string | Readable, options?: WorkbookReaderOptions);
|
|
117
|
+
_getStream(input: string | Readable): Readable;
|
|
118
|
+
read(input?: string | Readable, options?: WorkbookReaderOptions): Promise<void>;
|
|
119
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<WorksheetReader>;
|
|
120
|
+
parse(input?: string | Readable, options?: WorkbookReaderOptions): AsyncIterableIterator<ParseEvent>;
|
|
121
|
+
_emitEntry(payload: EntryPayload): void;
|
|
122
|
+
_parseRels(entry: NodeJS.ReadableStream): Promise<void>;
|
|
123
|
+
_parseWorkbook(entry: NodeJS.ReadableStream): Promise<void>;
|
|
124
|
+
_parseSharedStrings(entry: NodeJS.ReadableStream): AsyncIterableIterator<{
|
|
125
|
+
index: number;
|
|
126
|
+
text: SharedStringValue;
|
|
41
127
|
}>;
|
|
128
|
+
_parseStyles(entry: NodeJS.ReadableStream): Promise<void>;
|
|
129
|
+
_parseWorksheet(iterator: AsyncIterable<unknown>, sheetNo: string): IterableIterator<WorksheetReadyEvent>;
|
|
130
|
+
_parseHyperlinks(iterator: AsyncIterable<unknown>, sheetNo: string): IterableIterator<HyperlinksEvent>;
|
|
42
131
|
}
|
|
43
132
|
declare const WorkbookReaderOptions: {
|
|
44
133
|
readonly worksheets: readonly ["emit", "ignore"];
|
|
@@ -1,51 +1,134 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { Zip } from "fflate";
|
|
3
|
+
import { StreamBuf } from "../../utils/stream-buf.js";
|
|
4
|
+
import { StylesXform } from "../../xlsx/xform/style/styles-xform.js";
|
|
5
|
+
import { SharedStrings } from "../../utils/shared-strings.js";
|
|
6
|
+
import { DefinedNames } from "../../doc/defined-names.js";
|
|
7
|
+
import { WorksheetWriter } from "./worksheet-writer.js";
|
|
1
8
|
import type Stream from "stream";
|
|
2
|
-
|
|
9
|
+
import type { Image, WorkbookView, AddWorksheetOptions } from "../../types.js";
|
|
10
|
+
/** Internal medium type for storing images in workbook */
|
|
11
|
+
interface Medium extends Image {
|
|
12
|
+
type: "image";
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
/** Internal comment reference type for tracking comment files */
|
|
16
|
+
interface CommentRef {
|
|
17
|
+
commentName: string;
|
|
18
|
+
vmlDrawing: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ZlibOptions {
|
|
21
|
+
/** @default constants.Z_NO_FLUSH */
|
|
22
|
+
flush?: number;
|
|
23
|
+
/** @default constants.Z_FINISH */
|
|
24
|
+
finishFlush?: number;
|
|
25
|
+
/** @default 16*1024 */
|
|
26
|
+
chunkSize?: number;
|
|
27
|
+
windowBits?: number;
|
|
28
|
+
/** compression level (0-9) */
|
|
29
|
+
level?: number;
|
|
30
|
+
memLevel?: number;
|
|
31
|
+
strategy?: number;
|
|
32
|
+
dictionary?: Buffer | NodeJS.TypedArray | DataView | ArrayBuffer;
|
|
33
|
+
}
|
|
34
|
+
export interface ZipOptions {
|
|
35
|
+
comment?: string;
|
|
36
|
+
forceLocalTime?: boolean;
|
|
37
|
+
forceZip64?: boolean;
|
|
38
|
+
store?: boolean;
|
|
39
|
+
zlib?: Partial<ZlibOptions>;
|
|
40
|
+
/** Alternative way to set compression level */
|
|
41
|
+
compressionOptions?: {
|
|
42
|
+
level?: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface WorkbookWriterOptions {
|
|
46
|
+
/** The date the workbook was created */
|
|
3
47
|
created?: Date;
|
|
48
|
+
/** The date the workbook was last modified */
|
|
4
49
|
modified?: Date;
|
|
50
|
+
/** The author of the workbook */
|
|
5
51
|
creator?: string;
|
|
52
|
+
/** Who last modified the workbook */
|
|
6
53
|
lastModifiedBy?: string;
|
|
54
|
+
/** The date the workbook was last printed */
|
|
7
55
|
lastPrinted?: Date;
|
|
56
|
+
/** Specifies whether to use shared strings in the workbook. Default is false */
|
|
8
57
|
useSharedStrings?: boolean;
|
|
58
|
+
/** Specifies whether to add style information to the workbook. Default is false */
|
|
9
59
|
useStyles?: boolean;
|
|
10
|
-
|
|
60
|
+
/** Zip compression options */
|
|
61
|
+
zip?: Partial<ZipOptions>;
|
|
62
|
+
/** Specifies a writable stream to write the XLSX workbook to */
|
|
11
63
|
stream?: Stream;
|
|
64
|
+
/** If stream not specified, this field specifies the path to a file to write the XLSX workbook to */
|
|
12
65
|
filename?: string;
|
|
13
66
|
}
|
|
14
67
|
declare class WorkbookWriter {
|
|
68
|
+
/** The date the workbook was created */
|
|
15
69
|
created: Date;
|
|
70
|
+
/** The date the workbook was last modified */
|
|
16
71
|
modified: Date;
|
|
72
|
+
/** The author of the workbook */
|
|
17
73
|
creator: string;
|
|
74
|
+
/** Who last modified the workbook */
|
|
18
75
|
lastModifiedBy: string;
|
|
76
|
+
/** The date the workbook was last printed */
|
|
19
77
|
lastPrinted?: Date;
|
|
78
|
+
/** Whether to use shared strings */
|
|
20
79
|
useSharedStrings: boolean;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
80
|
+
/** Shared strings collection - internal use */
|
|
81
|
+
sharedStrings: SharedStrings;
|
|
82
|
+
/** Style manager - internal use */
|
|
83
|
+
styles: StylesXform;
|
|
84
|
+
/** Defined names - internal use */
|
|
85
|
+
_definedNames: DefinedNames;
|
|
86
|
+
/** Worksheets collection */
|
|
87
|
+
_worksheets: WorksheetWriter[];
|
|
88
|
+
/** Workbook views controls how many separate windows Excel will open */
|
|
89
|
+
views: WorkbookView[];
|
|
90
|
+
/** Zip options - internal use */
|
|
91
|
+
zipOptions?: Partial<ZipOptions>;
|
|
92
|
+
/** Compression level (0-9) */
|
|
27
93
|
compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
94
|
+
/** Media collection (images) - internal use */
|
|
95
|
+
media: Medium[];
|
|
96
|
+
/** Comment references - internal use */
|
|
97
|
+
commentRefs: CommentRef[];
|
|
98
|
+
/** Zip instance - internal use */
|
|
99
|
+
zip: Zip;
|
|
100
|
+
/** Output stream - internal use */
|
|
101
|
+
stream: Stream | fs.WriteStream | InstanceType<typeof StreamBuf>;
|
|
102
|
+
/** Internal promise for async operations */
|
|
103
|
+
promise: Promise<void[]>;
|
|
33
104
|
constructor(options?: WorkbookWriterOptions);
|
|
34
|
-
get definedNames():
|
|
35
|
-
_openStream(path: string):
|
|
36
|
-
_addFile(data: string |
|
|
105
|
+
get definedNames(): DefinedNames;
|
|
106
|
+
_openStream(path: string): InstanceType<typeof StreamBuf>;
|
|
107
|
+
_addFile(data: string | Uint8Array, name: string, base64?: boolean): void;
|
|
37
108
|
_commitWorksheets(): Promise<void>;
|
|
38
|
-
commit(): Promise<
|
|
109
|
+
commit(): Promise<void>;
|
|
39
110
|
get nextId(): number;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Add Image to Workbook and return the id
|
|
113
|
+
*/
|
|
114
|
+
addImage(image: Image): number;
|
|
115
|
+
/**
|
|
116
|
+
* Get image by id
|
|
117
|
+
*/
|
|
118
|
+
getImage(id: number): Image | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Add a new worksheet and return a reference to it
|
|
121
|
+
*/
|
|
122
|
+
addWorksheet(name?: string, options?: Partial<AddWorksheetOptions>): WorksheetWriter;
|
|
123
|
+
/**
|
|
124
|
+
* Fetch sheet by name or id
|
|
125
|
+
*/
|
|
126
|
+
getWorksheet(id?: string | number): WorksheetWriter | undefined;
|
|
44
127
|
addStyles(): Promise<void>;
|
|
45
128
|
addThemes(): Promise<void>;
|
|
46
129
|
addOfficeRels(): Promise<void>;
|
|
47
130
|
addContentTypes(): Promise<void>;
|
|
48
|
-
addMedia(): Promise<
|
|
131
|
+
addMedia(): Promise<void[]>;
|
|
49
132
|
addApp(): Promise<void>;
|
|
50
133
|
addCore(): Promise<void>;
|
|
51
134
|
addSharedStrings(): Promise<void>;
|
|
@@ -1,37 +1,55 @@
|
|
|
1
1
|
import { EventEmitter } from "events";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { Dimensions } from "../../doc/range.js";
|
|
3
|
+
import { Row } from "../../doc/row.js";
|
|
4
|
+
import { Column } from "../../doc/column.js";
|
|
5
|
+
import type { WorkbookReader, InternalWorksheetOptions } from "./workbook-reader.js";
|
|
6
|
+
import type { WorksheetState } from "../../types.js";
|
|
7
|
+
/** Hyperlink reference from worksheet XML */
|
|
8
|
+
export interface WorksheetHyperlink {
|
|
9
|
+
ref: string;
|
|
10
|
+
rId: string;
|
|
11
|
+
}
|
|
12
|
+
/** Events emitted during worksheet parsing */
|
|
13
|
+
export type WorksheetEventType = "row" | "hyperlink";
|
|
14
|
+
/** Row event emitted during parsing */
|
|
15
|
+
export interface RowEvent {
|
|
16
|
+
eventType: "row";
|
|
17
|
+
value: Row;
|
|
18
|
+
}
|
|
19
|
+
/** Hyperlink event emitted during parsing */
|
|
20
|
+
export interface HyperlinkEvent {
|
|
21
|
+
eventType: "hyperlink";
|
|
22
|
+
value: WorksheetHyperlink;
|
|
23
|
+
}
|
|
24
|
+
export type WorksheetEvent = RowEvent | HyperlinkEvent;
|
|
25
|
+
export interface WorksheetReaderOptions {
|
|
26
|
+
workbook: WorkbookReader;
|
|
4
27
|
id: number;
|
|
5
|
-
iterator:
|
|
6
|
-
options?:
|
|
28
|
+
iterator: AsyncIterable<unknown>;
|
|
29
|
+
options?: InternalWorksheetOptions;
|
|
7
30
|
}
|
|
8
31
|
declare class WorksheetReader extends EventEmitter {
|
|
9
|
-
workbook:
|
|
32
|
+
workbook: WorkbookReader;
|
|
10
33
|
id: number | string;
|
|
11
|
-
iterator:
|
|
12
|
-
options:
|
|
34
|
+
iterator: AsyncIterable<unknown>;
|
|
35
|
+
options: InternalWorksheetOptions;
|
|
13
36
|
name: string;
|
|
14
|
-
state?:
|
|
37
|
+
state?: WorksheetState;
|
|
15
38
|
private _columns;
|
|
16
39
|
private _keys;
|
|
17
40
|
private _dimensions;
|
|
18
|
-
hyperlinks?:
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
};
|
|
41
|
+
hyperlinks?: Record<string, WorksheetHyperlink>;
|
|
21
42
|
constructor({ workbook, id, iterator, options }: WorksheetReaderOptions);
|
|
22
43
|
destroy(): void;
|
|
23
|
-
get dimensions():
|
|
24
|
-
get columns():
|
|
25
|
-
getColumn(c: string | number):
|
|
26
|
-
getColumnKey(key: string):
|
|
27
|
-
setColumnKey(key: string, value:
|
|
44
|
+
get dimensions(): Dimensions;
|
|
45
|
+
get columns(): Column[] | null;
|
|
46
|
+
getColumn(c: string | number): Column;
|
|
47
|
+
getColumnKey(key: string): Column | undefined;
|
|
48
|
+
setColumnKey(key: string, value: Column): void;
|
|
28
49
|
deleteColumnKey(key: string): void;
|
|
29
|
-
eachColumnKey(f: (column:
|
|
50
|
+
eachColumnKey(f: (column: Column, key: string) => void): void;
|
|
30
51
|
read(): Promise<void>;
|
|
31
|
-
[Symbol.asyncIterator](): AsyncIterableIterator<
|
|
32
|
-
parse(): AsyncIterableIterator<
|
|
33
|
-
eventType: string;
|
|
34
|
-
value: any;
|
|
35
|
-
}>>;
|
|
52
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<Row>;
|
|
53
|
+
parse(): AsyncIterableIterator<WorksheetEvent[]>;
|
|
36
54
|
}
|
|
37
55
|
export { WorksheetReader };
|
|
@@ -1,85 +1,119 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Dimensions } from "../../doc/range.js";
|
|
2
|
+
import { StringBuf } from "../../utils/string-buf.js";
|
|
3
|
+
import { Row } from "../../doc/row.js";
|
|
4
|
+
import { Column } from "../../doc/column.js";
|
|
5
|
+
import { SheetRelsWriter } from "./sheet-rels-writer.js";
|
|
6
|
+
import { SheetCommentsWriter } from "./sheet-comments-writer.js";
|
|
7
|
+
import { DataValidations } from "../../doc/data-validations.js";
|
|
8
|
+
import type { StreamBuf } from "../../utils/stream-buf.js";
|
|
9
|
+
import type { RowBreak, PageSetup, HeaderFooter, WorksheetProperties, WorksheetView, WorksheetState, AutoFilter, WorksheetProtection, ConditionalFormattingOptions } from "../../types.js";
|
|
2
10
|
interface WorksheetWriterOptions {
|
|
3
11
|
id: number;
|
|
4
12
|
name?: string;
|
|
5
13
|
workbook: any;
|
|
6
14
|
useSharedStrings?: boolean;
|
|
7
|
-
properties?:
|
|
8
|
-
state?:
|
|
9
|
-
pageSetup?:
|
|
10
|
-
views?:
|
|
11
|
-
autoFilter?:
|
|
12
|
-
headerFooter?:
|
|
15
|
+
properties?: Partial<WorksheetProperties>;
|
|
16
|
+
state?: WorksheetState;
|
|
17
|
+
pageSetup?: Partial<PageSetup>;
|
|
18
|
+
views?: Partial<WorksheetView>[];
|
|
19
|
+
autoFilter?: AutoFilter;
|
|
20
|
+
headerFooter?: Partial<HeaderFooter>;
|
|
13
21
|
}
|
|
14
22
|
declare class WorksheetWriter {
|
|
15
23
|
id: number;
|
|
16
24
|
name: string;
|
|
17
|
-
state:
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
state: WorksheetState;
|
|
26
|
+
/** Rows stored while being worked on. Set to null after commit. */
|
|
27
|
+
_rows: Row[] | null;
|
|
28
|
+
/** Column definitions */
|
|
29
|
+
_columns: Column[] | null;
|
|
30
|
+
/** Column keys mapping: key => Column */
|
|
20
31
|
_keys: {
|
|
21
|
-
[key: string]:
|
|
32
|
+
[key: string]: Column;
|
|
22
33
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
/** Merged cell ranges */
|
|
35
|
+
_merges: Dimensions[];
|
|
36
|
+
_sheetRelsWriter: SheetRelsWriter;
|
|
37
|
+
_sheetCommentsWriter: SheetCommentsWriter;
|
|
38
|
+
_dimensions: Dimensions;
|
|
27
39
|
_rowZero: number;
|
|
28
40
|
committed: boolean;
|
|
29
|
-
dataValidations:
|
|
41
|
+
dataValidations: DataValidations;
|
|
42
|
+
/** Shared formulae by address */
|
|
30
43
|
_formulae: {
|
|
31
|
-
[key: string]:
|
|
44
|
+
[key: string]: unknown;
|
|
32
45
|
};
|
|
33
46
|
_siFormulae: number;
|
|
34
|
-
conditionalFormatting:
|
|
47
|
+
conditionalFormatting: ConditionalFormattingOptions[];
|
|
35
48
|
rowBreaks: RowBreak[];
|
|
36
|
-
properties:
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
properties: Partial<WorksheetProperties> & {
|
|
50
|
+
defaultRowHeight: number;
|
|
51
|
+
dyDescent: number;
|
|
52
|
+
outlineLevelCol: number;
|
|
53
|
+
outlineLevelRow: number;
|
|
54
|
+
};
|
|
55
|
+
headerFooter: Partial<HeaderFooter>;
|
|
56
|
+
pageSetup: Partial<PageSetup> & {
|
|
57
|
+
margins: PageSetup["margins"];
|
|
58
|
+
};
|
|
39
59
|
useSharedStrings: boolean;
|
|
40
60
|
_workbook: any;
|
|
41
61
|
hasComments: boolean;
|
|
42
|
-
_views:
|
|
43
|
-
autoFilter:
|
|
44
|
-
_media:
|
|
45
|
-
sheetProtection:
|
|
46
|
-
|
|
62
|
+
_views: Partial<WorksheetView>[];
|
|
63
|
+
autoFilter: AutoFilter | null;
|
|
64
|
+
_media: unknown[];
|
|
65
|
+
sheetProtection: {
|
|
66
|
+
sheet?: boolean;
|
|
67
|
+
algorithmName?: string;
|
|
68
|
+
saltValue?: string;
|
|
69
|
+
spinCount?: number;
|
|
70
|
+
hashValue?: string;
|
|
71
|
+
[key: string]: unknown;
|
|
72
|
+
} | null;
|
|
73
|
+
_stream?: InstanceType<typeof StreamBuf>;
|
|
47
74
|
startedData: boolean;
|
|
48
|
-
_background?:
|
|
75
|
+
_background?: {
|
|
76
|
+
imageId?: number;
|
|
77
|
+
rId?: string;
|
|
78
|
+
};
|
|
49
79
|
_headerRowCount?: number;
|
|
80
|
+
/** Relationship Id - assigned by WorkbookWriter */
|
|
81
|
+
rId?: string;
|
|
50
82
|
constructor(options: WorksheetWriterOptions);
|
|
51
83
|
get workbook(): any;
|
|
52
84
|
get stream(): any;
|
|
53
85
|
destroy(): void;
|
|
54
86
|
commit(): void;
|
|
55
|
-
get dimensions():
|
|
56
|
-
get views():
|
|
57
|
-
get columns():
|
|
58
|
-
set columns(value:
|
|
59
|
-
getColumnKey(key: string):
|
|
60
|
-
setColumnKey(key: string, value:
|
|
87
|
+
get dimensions(): Dimensions;
|
|
88
|
+
get views(): Partial<WorksheetView>[];
|
|
89
|
+
get columns(): Column[] | null;
|
|
90
|
+
set columns(value: Partial<Column>[]);
|
|
91
|
+
getColumnKey(key: string): Column | undefined;
|
|
92
|
+
setColumnKey(key: string, value: Column): void;
|
|
61
93
|
deleteColumnKey(key: string): void;
|
|
62
|
-
eachColumnKey(f: (column:
|
|
63
|
-
getColumn(c: string | number):
|
|
94
|
+
eachColumnKey(f: (column: Column, key: string) => void): void;
|
|
95
|
+
getColumn(c: string | number): Column;
|
|
64
96
|
get _nextRow(): number;
|
|
65
|
-
eachRow(options:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
97
|
+
eachRow(options: {
|
|
98
|
+
includeEmpty?: boolean;
|
|
99
|
+
} | ((row: Row, rowNumber: number) => void), iteratee?: (row: Row, rowNumber: number) => void): void;
|
|
100
|
+
_commitRow(cRow: Row): void;
|
|
101
|
+
get lastRow(): Row | undefined;
|
|
102
|
+
findRow(rowNumber: number): Row | undefined;
|
|
103
|
+
getRow(rowNumber: number): Row;
|
|
104
|
+
addRow(value: any[] | Record<string, any>): Row;
|
|
105
|
+
findCell(r: string | number, c?: number): any;
|
|
106
|
+
getCell(r: string | number, c?: number): any;
|
|
107
|
+
mergeCells(...cells: (string | number)[]): void;
|
|
108
|
+
addConditionalFormatting(cf: ConditionalFormattingOptions): void;
|
|
109
|
+
removeConditionalFormatting(filter?: number | ((cf: ConditionalFormattingOptions) => boolean)): void;
|
|
76
110
|
addBackgroundImage(imageId: number): void;
|
|
77
111
|
getBackgroundImageId(): number | undefined;
|
|
78
|
-
protect(password?: string, options?:
|
|
112
|
+
protect(password?: string, options?: Partial<WorksheetProtection>): Promise<void>;
|
|
79
113
|
unprotect(): void;
|
|
80
114
|
_write(text: string): void;
|
|
81
|
-
_writeSheetProperties(xmlBuf:
|
|
82
|
-
_writeSheetFormatProperties(xmlBuf:
|
|
115
|
+
_writeSheetProperties(xmlBuf: StringBuf, properties: Partial<WorksheetProperties> | undefined, pageSetup: Partial<PageSetup> | undefined): void;
|
|
116
|
+
_writeSheetFormatProperties(xmlBuf: StringBuf, properties: Partial<WorksheetProperties> | undefined): void;
|
|
83
117
|
_writeOpenWorksheet(): void;
|
|
84
118
|
_writeColumns(): void;
|
|
85
119
|
_writeOpenSheetData(): void;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -481,22 +481,6 @@ export interface TableProperties {
|
|
|
481
481
|
rows: any[][];
|
|
482
482
|
}
|
|
483
483
|
export type TableColumn = Required<TableColumnProperties>;
|
|
484
|
-
export interface JSZipGeneratorOptions {
|
|
485
|
-
compression: "STORE" | "DEFLATE";
|
|
486
|
-
compressionOptions: null | {
|
|
487
|
-
level: number;
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
export interface XlsxReadOptions {
|
|
491
|
-
ignoreNodes?: string[];
|
|
492
|
-
maxRows?: number;
|
|
493
|
-
maxCols?: number;
|
|
494
|
-
}
|
|
495
|
-
export interface XlsxWriteOptions {
|
|
496
|
-
zip?: Partial<JSZipGeneratorOptions>;
|
|
497
|
-
useSharedStrings?: boolean;
|
|
498
|
-
useStyles?: boolean;
|
|
499
|
-
}
|
|
500
484
|
export interface Media {
|
|
501
485
|
type: string;
|
|
502
486
|
name: string;
|
|
@@ -509,6 +493,10 @@ export interface AddWorksheetOptions {
|
|
|
509
493
|
headerFooter?: Partial<HeaderFooter>;
|
|
510
494
|
views?: Array<Partial<WorksheetView>>;
|
|
511
495
|
state?: WorksheetState;
|
|
496
|
+
/** Specifies whether to use shared strings. Overrides workbook setting. */
|
|
497
|
+
useSharedStrings?: boolean;
|
|
498
|
+
/** Apply an auto filter to the worksheet */
|
|
499
|
+
autoFilter?: AutoFilter;
|
|
512
500
|
}
|
|
513
501
|
export interface DefinedNamesRanges {
|
|
514
502
|
name: string;
|