@origints/xlsx 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/dist/convert.d.ts +85 -0
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.es.js +2257 -0
- package/dist/index.es.js.map +1 -0
- package/dist/parse.d.ts +85 -0
- package/dist/util.d.ts +68 -0
- package/dist/xlsx-cell.d.ts +212 -0
- package/dist/xlsx-cursor.d.ts +203 -0
- package/dist/xlsx-query.d.ts +155 -0
- package/dist/xlsx-range.d.ts +166 -0
- package/dist/xlsx-result.d.ts +94 -0
- package/dist/xlsx-sheet.d.ts +149 -0
- package/dist/xlsx-workbook.d.ts +128 -0
- package/package.json +46 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Worksheet } from 'exceljs';
|
|
2
|
+
import { XlsxCell } from './xlsx-cell';
|
|
3
|
+
import { XlsxResult, XlsxPath, CellValue } from './xlsx-result';
|
|
4
|
+
import { CellPredicate } from './xlsx-query';
|
|
5
|
+
/**
|
|
6
|
+
* A range of cells in an XLSX sheet.
|
|
7
|
+
*
|
|
8
|
+
* XlsxRange enables iteration over cells, rows, and columns within
|
|
9
|
+
* a defined rectangular region. It supports predicate-based queries
|
|
10
|
+
* and conversion to various formats.
|
|
11
|
+
*/
|
|
12
|
+
export declare class XlsxRange {
|
|
13
|
+
private readonly worksheet;
|
|
14
|
+
private readonly _startRow;
|
|
15
|
+
private readonly _startCol;
|
|
16
|
+
private readonly _endRow;
|
|
17
|
+
private readonly _endCol;
|
|
18
|
+
private readonly _path;
|
|
19
|
+
private readonly _sheetName;
|
|
20
|
+
private readonly _file?;
|
|
21
|
+
private constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Creates an XlsxRange from coordinates.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
static fromCoords(worksheet: Worksheet, startRow: number, startCol: number, endRow: number, endCol: number, sheetName: string, file?: string): XlsxRange;
|
|
27
|
+
/**
|
|
28
|
+
* Creates an XlsxRange from an address string.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
static fromAddress(worksheet: Worksheet, address: string, sheetName: string, file?: string): XlsxResult<XlsxRange>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the range address (e.g., "A1:C10").
|
|
34
|
+
*/
|
|
35
|
+
get address(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the start row (1-based).
|
|
38
|
+
*/
|
|
39
|
+
get startRow(): number;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the start column (1-based).
|
|
42
|
+
*/
|
|
43
|
+
get startCol(): number;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the end row (1-based).
|
|
46
|
+
*/
|
|
47
|
+
get endRow(): number;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the end column (1-based).
|
|
50
|
+
*/
|
|
51
|
+
get endCol(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the current path for lineage tracking.
|
|
54
|
+
*/
|
|
55
|
+
get path(): XlsxPath;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the number of rows in the range.
|
|
58
|
+
*/
|
|
59
|
+
get rowCount(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the number of columns in the range.
|
|
62
|
+
*/
|
|
63
|
+
get colCount(): number;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the total number of cells in the range.
|
|
66
|
+
*/
|
|
67
|
+
get cellCount(): number;
|
|
68
|
+
/**
|
|
69
|
+
* Get a cell at specific row and column within this range.
|
|
70
|
+
* Coordinates are relative to the range start (0-indexed).
|
|
71
|
+
*/
|
|
72
|
+
cellAt(rowOffset: number, colOffset: number): XlsxResult<XlsxCell>;
|
|
73
|
+
/**
|
|
74
|
+
* Get a cell by its address within this range.
|
|
75
|
+
*/
|
|
76
|
+
cell(address: string): XlsxResult<XlsxCell>;
|
|
77
|
+
/**
|
|
78
|
+
* Iterate over all cells in the range (row by row).
|
|
79
|
+
*/
|
|
80
|
+
cells(): Iterable<XlsxCell>;
|
|
81
|
+
/**
|
|
82
|
+
* Iterate over rows, returning arrays of cells.
|
|
83
|
+
*/
|
|
84
|
+
rows(): Iterable<XlsxCell[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Iterate over columns, returning arrays of cells.
|
|
87
|
+
*/
|
|
88
|
+
cols(): Iterable<XlsxCell[]>;
|
|
89
|
+
/**
|
|
90
|
+
* Get all values in the range as a 2D array.
|
|
91
|
+
*/
|
|
92
|
+
values(): CellValue[][];
|
|
93
|
+
/**
|
|
94
|
+
* Get all cells as a flat array.
|
|
95
|
+
*/
|
|
96
|
+
cellsArray(): XlsxCell[];
|
|
97
|
+
/**
|
|
98
|
+
* Get a subrange within this range.
|
|
99
|
+
*/
|
|
100
|
+
subRange(address: string): XlsxResult<XlsxRange>;
|
|
101
|
+
/**
|
|
102
|
+
* Get the first row as a range.
|
|
103
|
+
*/
|
|
104
|
+
firstRow(): XlsxRange;
|
|
105
|
+
/**
|
|
106
|
+
* Get the last row as a range.
|
|
107
|
+
*/
|
|
108
|
+
lastRow(): XlsxRange;
|
|
109
|
+
/**
|
|
110
|
+
* Get the first column as a range.
|
|
111
|
+
*/
|
|
112
|
+
firstCol(): XlsxRange;
|
|
113
|
+
/**
|
|
114
|
+
* Get the last column as a range.
|
|
115
|
+
*/
|
|
116
|
+
lastCol(): XlsxRange;
|
|
117
|
+
/**
|
|
118
|
+
* Get a specific row as a range (0-indexed offset from start).
|
|
119
|
+
*/
|
|
120
|
+
rowAt(offset: number): XlsxResult<XlsxRange>;
|
|
121
|
+
/**
|
|
122
|
+
* Get a specific column as a range (0-indexed offset from start).
|
|
123
|
+
*/
|
|
124
|
+
colAt(offset: number): XlsxResult<XlsxRange>;
|
|
125
|
+
/**
|
|
126
|
+
* Find the first cell matching the predicate.
|
|
127
|
+
*/
|
|
128
|
+
find(predicate: CellPredicate): XlsxResult<XlsxCell>;
|
|
129
|
+
/**
|
|
130
|
+
* Find all cells matching the predicate.
|
|
131
|
+
*/
|
|
132
|
+
findAll(predicate: CellPredicate): XlsxCell[];
|
|
133
|
+
/**
|
|
134
|
+
* Find the first cell with the specified value.
|
|
135
|
+
*/
|
|
136
|
+
findValue(value: CellValue): XlsxResult<XlsxCell>;
|
|
137
|
+
/**
|
|
138
|
+
* Check if any cell matches the predicate.
|
|
139
|
+
*/
|
|
140
|
+
some(predicate: CellPredicate): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Check if all cells match the predicate.
|
|
143
|
+
*/
|
|
144
|
+
every(predicate: CellPredicate): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Count cells matching the predicate.
|
|
147
|
+
*/
|
|
148
|
+
count(predicate: CellPredicate): number;
|
|
149
|
+
/**
|
|
150
|
+
* Convert range to a 2D array of values.
|
|
151
|
+
*/
|
|
152
|
+
toArray(): CellValue[][];
|
|
153
|
+
/**
|
|
154
|
+
* Convert range to array of objects using a header row.
|
|
155
|
+
* @param headerRowOffset - Row offset for headers (default: 0, first row)
|
|
156
|
+
* @param dataStartOffset - Row offset where data starts (default: 1, second row)
|
|
157
|
+
*/
|
|
158
|
+
toObjects(headerRowOffset?: number, dataStartOffset?: number): Record<string, CellValue>[];
|
|
159
|
+
/**
|
|
160
|
+
* Convert range to JSON-compatible structure.
|
|
161
|
+
*/
|
|
162
|
+
toJson(): {
|
|
163
|
+
address: string;
|
|
164
|
+
rows: Array<Array<CellValue>>;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result types for XLSX operations.
|
|
3
|
+
*
|
|
4
|
+
* @module xlsx/xlsx-result
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Excel source location for lineage tracking.
|
|
8
|
+
* Compatible with @origints/core ExcelLocation.
|
|
9
|
+
*/
|
|
10
|
+
export interface ExcelLocation {
|
|
11
|
+
readonly kind: 'excel';
|
|
12
|
+
readonly file: string;
|
|
13
|
+
readonly sheet: string;
|
|
14
|
+
readonly range: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Path through an XLSX structure, tracking how we arrived at a value.
|
|
18
|
+
*/
|
|
19
|
+
export interface XlsxPath {
|
|
20
|
+
/** Source file name (if known) */
|
|
21
|
+
readonly file?: string;
|
|
22
|
+
/** Sheet name */
|
|
23
|
+
readonly sheet?: string;
|
|
24
|
+
/** Cell address (e.g., "A1") */
|
|
25
|
+
readonly cell?: string;
|
|
26
|
+
/** Range address (e.g., "A1:C10") */
|
|
27
|
+
readonly range?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Failure kinds specific to XLSX operations.
|
|
31
|
+
*/
|
|
32
|
+
export type XlsxFailureKind = 'parse' | 'type' | 'missing' | 'range' | 'format' | 'bounds' | 'merged' | 'formula';
|
|
33
|
+
/**
|
|
34
|
+
* A failure during XLSX traversal or extraction.
|
|
35
|
+
*/
|
|
36
|
+
export interface XlsxFailure {
|
|
37
|
+
readonly kind: XlsxFailureKind;
|
|
38
|
+
readonly message: string;
|
|
39
|
+
readonly path: XlsxPath;
|
|
40
|
+
readonly sourceLocation?: ExcelLocation;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Result of an XLSX extraction - either a successful value or a failure.
|
|
44
|
+
*/
|
|
45
|
+
export type XlsxResult<T> = {
|
|
46
|
+
readonly ok: true;
|
|
47
|
+
readonly value: T;
|
|
48
|
+
readonly path: XlsxPath;
|
|
49
|
+
} | {
|
|
50
|
+
readonly ok: false;
|
|
51
|
+
readonly failure: XlsxFailure;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Creates a success result.
|
|
55
|
+
*/
|
|
56
|
+
export declare function ok<T>(value: T, path: XlsxPath): XlsxResult<T>;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a failure result.
|
|
59
|
+
*/
|
|
60
|
+
export declare function fail(kind: XlsxFailureKind, message: string, path: XlsxPath, sourceLocation?: ExcelLocation): XlsxResult<never>;
|
|
61
|
+
/**
|
|
62
|
+
* Formats a path for display.
|
|
63
|
+
*/
|
|
64
|
+
export declare function formatXlsxPath(path: XlsxPath): string;
|
|
65
|
+
/**
|
|
66
|
+
* Creates an ExcelLocation from a path.
|
|
67
|
+
*/
|
|
68
|
+
export declare function toExcelLocation(path: XlsxPath): ExcelLocation | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Cell value types in XLSX.
|
|
71
|
+
*/
|
|
72
|
+
export type CellValue = string | number | boolean | Date | null;
|
|
73
|
+
/**
|
|
74
|
+
* Extended cell value including formula and error types.
|
|
75
|
+
*/
|
|
76
|
+
export type ExtendedCellValue = CellValue | {
|
|
77
|
+
readonly formula: string;
|
|
78
|
+
readonly result?: CellValue;
|
|
79
|
+
} | {
|
|
80
|
+
readonly error: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Type guard for formula values.
|
|
84
|
+
*/
|
|
85
|
+
export declare function isFormula(value: ExtendedCellValue): value is {
|
|
86
|
+
formula: string;
|
|
87
|
+
result?: CellValue;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Type guard for error values.
|
|
91
|
+
*/
|
|
92
|
+
export declare function isError(value: ExtendedCellValue): value is {
|
|
93
|
+
error: string;
|
|
94
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Worksheet } from 'exceljs';
|
|
2
|
+
import { XlsxCell } from './xlsx-cell';
|
|
3
|
+
import { XlsxRange } from './xlsx-range';
|
|
4
|
+
import { XlsxCursor } from './xlsx-cursor';
|
|
5
|
+
import { XlsxResult, XlsxPath, CellValue } from './xlsx-result';
|
|
6
|
+
import { CellPredicate } from './xlsx-query';
|
|
7
|
+
/**
|
|
8
|
+
* Dimensions of a sheet's used range.
|
|
9
|
+
*/
|
|
10
|
+
export interface SheetDimensions {
|
|
11
|
+
readonly startRow: number;
|
|
12
|
+
readonly endRow: number;
|
|
13
|
+
readonly startCol: number;
|
|
14
|
+
readonly endCol: number;
|
|
15
|
+
readonly rowCount: number;
|
|
16
|
+
readonly colCount: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A wrapper around ExcelJS Worksheet with navigation and query capabilities.
|
|
20
|
+
*
|
|
21
|
+
* XlsxSheet provides a rich API for navigating cells, ranges, and rows
|
|
22
|
+
* within a worksheet. It supports predicate-based queries and cursor-based
|
|
23
|
+
* navigation for complex data extraction scenarios.
|
|
24
|
+
*/
|
|
25
|
+
export declare class XlsxSheet {
|
|
26
|
+
private readonly worksheet;
|
|
27
|
+
private readonly _path;
|
|
28
|
+
private readonly _file?;
|
|
29
|
+
private constructor();
|
|
30
|
+
/**
|
|
31
|
+
* Creates an XlsxSheet from an ExcelJS worksheet.
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
static fromExcelJS(worksheet: Worksheet, file?: string): XlsxSheet;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the sheet name.
|
|
37
|
+
*/
|
|
38
|
+
get name(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the sheet index (1-based).
|
|
41
|
+
*/
|
|
42
|
+
get index(): number;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the current path for lineage tracking.
|
|
45
|
+
*/
|
|
46
|
+
get path(): XlsxPath;
|
|
47
|
+
/**
|
|
48
|
+
* Get a cell by its address (e.g., "A1", "B2").
|
|
49
|
+
*/
|
|
50
|
+
cell(address: string): XlsxResult<XlsxCell>;
|
|
51
|
+
/**
|
|
52
|
+
* Get a cell by row and column numbers (1-based).
|
|
53
|
+
*/
|
|
54
|
+
cellAt(row: number, col: number): XlsxResult<XlsxCell>;
|
|
55
|
+
/**
|
|
56
|
+
* Get the value of a cell directly.
|
|
57
|
+
*/
|
|
58
|
+
getValue(address: string): XlsxResult<CellValue>;
|
|
59
|
+
/**
|
|
60
|
+
* Get a range by its address (e.g., "A1:C10").
|
|
61
|
+
*/
|
|
62
|
+
range(address: string): XlsxResult<XlsxRange>;
|
|
63
|
+
/**
|
|
64
|
+
* Get a range from start to end addresses.
|
|
65
|
+
*/
|
|
66
|
+
rangeFrom(start: string, end: string): XlsxResult<XlsxRange>;
|
|
67
|
+
/**
|
|
68
|
+
* Get a range by coordinates (1-based).
|
|
69
|
+
*/
|
|
70
|
+
rangeAt(startRow: number, startCol: number, endRow: number, endCol: number): XlsxResult<XlsxRange>;
|
|
71
|
+
/**
|
|
72
|
+
* Get the used range of the sheet (cells with data).
|
|
73
|
+
*/
|
|
74
|
+
usedRange(): XlsxResult<XlsxRange>;
|
|
75
|
+
/**
|
|
76
|
+
* Get a row as a range.
|
|
77
|
+
*/
|
|
78
|
+
row(rowNum: number): XlsxResult<XlsxRange>;
|
|
79
|
+
/**
|
|
80
|
+
* Get a column as a range.
|
|
81
|
+
*/
|
|
82
|
+
col(colId: string | number): XlsxResult<XlsxRange>;
|
|
83
|
+
/**
|
|
84
|
+
* Iterate over all rows with data.
|
|
85
|
+
*/
|
|
86
|
+
rows(): Iterable<XlsxRange>;
|
|
87
|
+
/**
|
|
88
|
+
* Iterate over all columns with data.
|
|
89
|
+
*/
|
|
90
|
+
cols(): Iterable<XlsxRange>;
|
|
91
|
+
/**
|
|
92
|
+
* Create a cursor starting at the specified address.
|
|
93
|
+
*/
|
|
94
|
+
cursor(startAddress?: string): XlsxCursor;
|
|
95
|
+
/**
|
|
96
|
+
* Create a cursor starting at the specified coordinates (1-based).
|
|
97
|
+
*/
|
|
98
|
+
cursorAt(row: number, col: number): XlsxCursor;
|
|
99
|
+
/**
|
|
100
|
+
* Find the first cell matching the predicate.
|
|
101
|
+
*/
|
|
102
|
+
find(predicate: CellPredicate): XlsxResult<XlsxCell>;
|
|
103
|
+
/**
|
|
104
|
+
* Find all cells matching the predicate.
|
|
105
|
+
*/
|
|
106
|
+
findAll(predicate: CellPredicate): XlsxCell[];
|
|
107
|
+
/**
|
|
108
|
+
* Find the first cell with the specified value.
|
|
109
|
+
*/
|
|
110
|
+
findValue(value: CellValue): XlsxResult<XlsxCell>;
|
|
111
|
+
/**
|
|
112
|
+
* Find cells within a specific range matching the predicate.
|
|
113
|
+
*/
|
|
114
|
+
findInRange(rangeAddress: string, predicate: CellPredicate): XlsxResult<XlsxCell>;
|
|
115
|
+
/**
|
|
116
|
+
* Find all cells within a specific range matching the predicate.
|
|
117
|
+
*/
|
|
118
|
+
findAllInRange(rangeAddress: string, predicate: CellPredicate): XlsxCell[];
|
|
119
|
+
/**
|
|
120
|
+
* Get the dimensions of the used area.
|
|
121
|
+
*/
|
|
122
|
+
dimensions(): SheetDimensions;
|
|
123
|
+
/**
|
|
124
|
+
* Get the number of rows with data.
|
|
125
|
+
*/
|
|
126
|
+
rowCount(): number;
|
|
127
|
+
/**
|
|
128
|
+
* Get the number of columns with data.
|
|
129
|
+
*/
|
|
130
|
+
colCount(): number;
|
|
131
|
+
/**
|
|
132
|
+
* Get all merged cell ranges.
|
|
133
|
+
*/
|
|
134
|
+
mergedRanges(): string[];
|
|
135
|
+
/**
|
|
136
|
+
* Check if a cell is part of a merged range.
|
|
137
|
+
*/
|
|
138
|
+
isMerged(address: string): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Get the underlying ExcelJS worksheet.
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
143
|
+
getWorksheet(): Worksheet;
|
|
144
|
+
/**
|
|
145
|
+
* Get a cell by coordinates for internal use.
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
getCellInternal(row: number, col: number): XlsxCell | undefined;
|
|
149
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Workbook } from 'exceljs';
|
|
2
|
+
import { XlsxSheet } from './xlsx-sheet';
|
|
3
|
+
import { XlsxResult, XlsxPath } from './xlsx-result';
|
|
4
|
+
/**
|
|
5
|
+
* Predicate function for matching sheets.
|
|
6
|
+
*/
|
|
7
|
+
export type SheetPredicate = (sheet: XlsxSheet) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Workbook properties.
|
|
10
|
+
*/
|
|
11
|
+
export interface WorkbookProperties {
|
|
12
|
+
readonly title?: string;
|
|
13
|
+
readonly subject?: string;
|
|
14
|
+
readonly creator?: string;
|
|
15
|
+
readonly lastModifiedBy?: string;
|
|
16
|
+
readonly created?: Date;
|
|
17
|
+
readonly modified?: Date;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A wrapper around ExcelJS Workbook with navigation and query capabilities.
|
|
21
|
+
*
|
|
22
|
+
* XlsxWorkbook provides access to sheets, workbook properties, and
|
|
23
|
+
* supports predicate-based queries for finding sheets.
|
|
24
|
+
*/
|
|
25
|
+
export declare class XlsxWorkbook {
|
|
26
|
+
private readonly workbook;
|
|
27
|
+
private readonly _path;
|
|
28
|
+
private readonly sheetsCache;
|
|
29
|
+
private constructor();
|
|
30
|
+
/**
|
|
31
|
+
* Creates an XlsxWorkbook from an ExcelJS workbook.
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
static fromExcelJS(workbook: Workbook, file?: string): XlsxWorkbook;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the path for lineage tracking.
|
|
37
|
+
*/
|
|
38
|
+
get path(): XlsxPath;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the file name if known.
|
|
41
|
+
*/
|
|
42
|
+
get file(): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Get a sheet by name.
|
|
45
|
+
*/
|
|
46
|
+
sheet(name: string): XlsxResult<XlsxSheet>;
|
|
47
|
+
/**
|
|
48
|
+
* Get a sheet by index (1-based, as per Excel convention).
|
|
49
|
+
*/
|
|
50
|
+
sheetAt(index: number): XlsxResult<XlsxSheet>;
|
|
51
|
+
/**
|
|
52
|
+
* Get all sheets.
|
|
53
|
+
*/
|
|
54
|
+
sheets(): XlsxSheet[];
|
|
55
|
+
/**
|
|
56
|
+
* Get all sheet names.
|
|
57
|
+
*/
|
|
58
|
+
sheetNames(): string[];
|
|
59
|
+
/**
|
|
60
|
+
* Get the number of sheets.
|
|
61
|
+
*/
|
|
62
|
+
sheetCount(): number;
|
|
63
|
+
/**
|
|
64
|
+
* Get the first sheet.
|
|
65
|
+
*/
|
|
66
|
+
firstSheet(): XlsxResult<XlsxSheet>;
|
|
67
|
+
/**
|
|
68
|
+
* Get the last sheet.
|
|
69
|
+
*/
|
|
70
|
+
lastSheet(): XlsxResult<XlsxSheet>;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a sheet with the given name exists.
|
|
73
|
+
*/
|
|
74
|
+
hasSheet(name: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Find the first sheet matching the predicate.
|
|
77
|
+
*/
|
|
78
|
+
findSheet(predicate: SheetPredicate): XlsxResult<XlsxSheet>;
|
|
79
|
+
/**
|
|
80
|
+
* Find all sheets matching the predicate.
|
|
81
|
+
*/
|
|
82
|
+
filterSheets(predicate: SheetPredicate): XlsxSheet[];
|
|
83
|
+
/**
|
|
84
|
+
* Find a sheet by name pattern (regex).
|
|
85
|
+
*/
|
|
86
|
+
findSheetByPattern(pattern: RegExp): XlsxResult<XlsxSheet>;
|
|
87
|
+
/**
|
|
88
|
+
* Find all sheets by name pattern (regex).
|
|
89
|
+
*/
|
|
90
|
+
filterSheetsByPattern(pattern: RegExp): XlsxSheet[];
|
|
91
|
+
/**
|
|
92
|
+
* Get workbook properties.
|
|
93
|
+
*/
|
|
94
|
+
properties(): WorkbookProperties;
|
|
95
|
+
/**
|
|
96
|
+
* Get the workbook creator.
|
|
97
|
+
*/
|
|
98
|
+
creator(): string | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Get the workbook creation date.
|
|
101
|
+
*/
|
|
102
|
+
created(): Date | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Get the workbook modification date.
|
|
105
|
+
*/
|
|
106
|
+
modified(): Date | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Get all defined names in the workbook.
|
|
109
|
+
*/
|
|
110
|
+
definedNames(): string[];
|
|
111
|
+
/**
|
|
112
|
+
* Iterate over all sheets.
|
|
113
|
+
*/
|
|
114
|
+
[Symbol.iterator](): Iterator<XlsxSheet>;
|
|
115
|
+
/**
|
|
116
|
+
* Execute a function for each sheet.
|
|
117
|
+
*/
|
|
118
|
+
forEach(fn: (sheet: XlsxSheet, index: number) => void): void;
|
|
119
|
+
/**
|
|
120
|
+
* Map over all sheets.
|
|
121
|
+
*/
|
|
122
|
+
map<T>(fn: (sheet: XlsxSheet, index: number) => T): T[];
|
|
123
|
+
/**
|
|
124
|
+
* Get the underlying ExcelJS workbook.
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
getWorkbook(): Workbook;
|
|
128
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@origints/xlsx",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "XLSX parsing for Origins with full traceability to sheets, ranges, and cells.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.es.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.cjs",
|
|
15
|
+
"module": "./dist/index.es.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"exceljs": "^4.4.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@origints/core": "^0.1.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "25.0.6",
|
|
31
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
32
|
+
"eslint": "9.39.2",
|
|
33
|
+
"typescript": "5.9.3",
|
|
34
|
+
"vite": "7.3.1",
|
|
35
|
+
"vite-plugin-dts": "4.5.4",
|
|
36
|
+
"vitest": "4.0.16",
|
|
37
|
+
"@origints/core": "0.1.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "vite build",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"test:coverage": "vitest run --coverage",
|
|
43
|
+
"lint": "eslint \"{src,tests}/**/*.{ts,tsx}\" --max-warnings 0",
|
|
44
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
45
|
+
}
|
|
46
|
+
}
|