@justybase/spreadsheet-tasks 1.0.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 +169 -0
- package/dist/BiffReaderWriter.d.ts +44 -0
- package/dist/BiffReaderWriter.d.ts.map +1 -0
- package/dist/BiffReaderWriter.js +282 -0
- package/dist/BiffReaderWriter.js.map +1 -0
- package/dist/BigBuffer.d.ts +24 -0
- package/dist/BigBuffer.d.ts.map +1 -0
- package/dist/BigBuffer.js +120 -0
- package/dist/BigBuffer.js.map +1 -0
- package/dist/ExcelReaderAbstract.d.ts +17 -0
- package/dist/ExcelReaderAbstract.d.ts.map +1 -0
- package/dist/ExcelReaderAbstract.js +25 -0
- package/dist/ExcelReaderAbstract.js.map +1 -0
- package/dist/ReaderFactory.d.ts +6 -0
- package/dist/ReaderFactory.d.ts.map +1 -0
- package/dist/ReaderFactory.js +56 -0
- package/dist/ReaderFactory.js.map +1 -0
- package/dist/XlsbReader.d.ts +24 -0
- package/dist/XlsbReader.d.ts.map +1 -0
- package/dist/XlsbReader.js +186 -0
- package/dist/XlsbReader.js.map +1 -0
- package/dist/XlsbWriter.d.ts +69 -0
- package/dist/XlsbWriter.d.ts.map +1 -0
- package/dist/XlsbWriter.js +802 -0
- package/dist/XlsbWriter.js.map +1 -0
- package/dist/XlsxReader.d.ts +30 -0
- package/dist/XlsxReader.d.ts.map +1 -0
- package/dist/XlsxReader.js +341 -0
- package/dist/XlsxReader.js.map +1 -0
- package/dist/XlsxWriter.d.ts +31 -0
- package/dist/XlsxWriter.d.ts.map +1 -0
- package/dist/XlsxWriter.js +415 -0
- package/dist/XlsxWriter.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/docs/API.md +271 -0
- package/docs/BENCHMARK.md +129 -0
- package/docs/PUBLISHING.md +89 -0
- package/examples/basic-read.ts +109 -0
- package/examples/basic-write.ts +84 -0
- package/examples/large-dataset.ts +216 -0
- package/examples/multiple-sheets.ts +126 -0
- package/examples/streaming-example.ts +181 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Krzysztof Dusko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# SpreadsheetTasks
|
|
2
|
+
|
|
3
|
+
A high-performance TypeScript library for reading and writing Excel files in XLSB and XLSX formats.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@justybase/spreadsheet-tasks)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## 🚀 Features
|
|
9
|
+
|
|
10
|
+
- **High Performance** - XLSB format is 3.3x faster to write and 2.1x faster to read than XLSX
|
|
11
|
+
- **Small File Size** - XLSB files are ~47% smaller than equivalent XLSX files
|
|
12
|
+
- **TypeScript First** - Full TypeScript support with type definitions
|
|
13
|
+
- **Dual Format Support** - Read and write both XLSB and XLSX formats
|
|
14
|
+
- **Zero External Dependencies** - Uses only Node.js built-in modules and minimal zip libraries
|
|
15
|
+
- **Streaming Support** - Efficient memory usage for large files
|
|
16
|
+
- **Multiple Sheets** - Support for multiple worksheets per workbook
|
|
17
|
+
- **Auto-filter** - Automatic filter headers support
|
|
18
|
+
|
|
19
|
+
## 📊 Benchmark Results
|
|
20
|
+
|
|
21
|
+
| Operation | XLSB | XLSX | Performance Gain |
|
|
22
|
+
|-----------|------|------|------------------|
|
|
23
|
+
| Write (50K rows) | 140 ms | 467 ms | **3.3x faster** |
|
|
24
|
+
| Read (50K rows) | 118 ms | 276 ms | **2.3x faster** |
|
|
25
|
+
| File Size | 1.49 MB | 2.83 MB | **47% smaller** |
|
|
26
|
+
|
|
27
|
+
## 📦 Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @justybase/spreadsheet-tasks
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 🔧 Quick Start
|
|
34
|
+
|
|
35
|
+
### Writing Excel Files
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { XlsbWriter, XlsxWriter } from '@justybase/spreadsheet-tasks';
|
|
39
|
+
|
|
40
|
+
// Create XLSB file (recommended for performance)
|
|
41
|
+
const xlsbWriter = new XlsbWriter('output.xlsb');
|
|
42
|
+
xlsbWriter.addSheet('Sheet1');
|
|
43
|
+
xlsbWriter.writeSheet([
|
|
44
|
+
['Name', 'Age', 'City'],
|
|
45
|
+
['Alice', 30, 'New York'],
|
|
46
|
+
['Bob', 25, 'Los Angeles'],
|
|
47
|
+
['Charlie', 35, 'Chicago']
|
|
48
|
+
]);
|
|
49
|
+
await xlsbWriter.finalize();
|
|
50
|
+
|
|
51
|
+
// Or create XLSX file for compatibility
|
|
52
|
+
const xlsxWriter = new XlsxWriter('output.xlsx');
|
|
53
|
+
xlsxWriter.addSheet('Sheet1');
|
|
54
|
+
xlsxWriter.writeSheet([
|
|
55
|
+
['Name', 'Age', 'City'],
|
|
56
|
+
['Alice', 30, 'New York'],
|
|
57
|
+
['Bob', 25, 'Los Angeles'],
|
|
58
|
+
['Charlie', 35, 'Chicago']
|
|
59
|
+
]);
|
|
60
|
+
await xlsxWriter.finalize();
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Streaming API (for Large Datasets)
|
|
64
|
+
|
|
65
|
+
For large datasets that don't fit in memory, use the streaming API to write rows one at a time:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { XlsbWriter } from '@justybase/spreadsheet-tasks';
|
|
69
|
+
|
|
70
|
+
const writer = new XlsbWriter('large-output.xlsb');
|
|
71
|
+
|
|
72
|
+
// Start a sheet with column count and optional headers
|
|
73
|
+
writer.startSheet('Data', 5, ['ID', 'Name', 'Value', 'Date', 'Active']);
|
|
74
|
+
|
|
75
|
+
// Write rows one at a time - no need to load all data in memory
|
|
76
|
+
for (let i = 0; i < 1_000_000; i++) {
|
|
77
|
+
writer.writeRow([
|
|
78
|
+
i + 1,
|
|
79
|
+
`User_${i + 1}`,
|
|
80
|
+
Math.random() * 10000,
|
|
81
|
+
new Date(),
|
|
82
|
+
i % 2 === 0
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Finalize the sheet
|
|
87
|
+
writer.endSheet();
|
|
88
|
+
|
|
89
|
+
// You can create multiple sheets
|
|
90
|
+
writer.startSheet('MoreData', 3, ['Col1', 'Col2', 'Col3']);
|
|
91
|
+
// ... write more rows
|
|
92
|
+
writer.endSheet();
|
|
93
|
+
|
|
94
|
+
await writer.finalize();
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Benefits of Streaming API:**
|
|
98
|
+
- ✅ Constant memory usage regardless of dataset size
|
|
99
|
+
- ✅ Write millions of rows without loading all data into RAM
|
|
100
|
+
- ✅ Generate data on-the-fly from databases, APIs, or other sources
|
|
101
|
+
- ✅ Same performance as batch mode
|
|
102
|
+
|
|
103
|
+
### Reading Excel Files
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { XlsbReader, XlsxReader, ReaderFactory } from '@justybase/spreadsheet-tasks';
|
|
108
|
+
|
|
109
|
+
// Using ReaderFactory (auto-detects format)
|
|
110
|
+
const reader = ReaderFactory.create('data.xlsb');
|
|
111
|
+
await reader.open('data.xlsb');
|
|
112
|
+
|
|
113
|
+
console.log('Sheet names:', reader.getSheetNames());
|
|
114
|
+
|
|
115
|
+
while (reader.read()) {
|
|
116
|
+
const row = [];
|
|
117
|
+
for (let i = 0; i < reader.fieldCount; i++) {
|
|
118
|
+
row.push(reader.getValue(i));
|
|
119
|
+
}
|
|
120
|
+
console.log(row);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Or use specific reader
|
|
124
|
+
const xlsbReader = new XlsbReader();
|
|
125
|
+
await xlsbReader.open('data.xlsb');
|
|
126
|
+
// ... same API as above
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## 📖 API Documentation
|
|
130
|
+
|
|
131
|
+
See [API Documentation](./docs/API.md) for detailed API reference.
|
|
132
|
+
|
|
133
|
+
## 💡 Examples
|
|
134
|
+
|
|
135
|
+
Check out the [examples](./examples) folder for more usage examples:
|
|
136
|
+
|
|
137
|
+
- [Basic Write](./examples/basic-write.ts) - Writing data to Excel files
|
|
138
|
+
- [Basic Read](./examples/basic-read.ts) - Reading data from Excel files
|
|
139
|
+
- [Multiple Sheets](./examples/multiple-sheets.ts) - Working with multiple worksheets
|
|
140
|
+
- [Large Dataset](./examples/large-dataset.ts) - Handling large datasets efficiently
|
|
141
|
+
- [Streaming Example](./examples/streaming-example.ts) - Write millions of rows without loading all data in memory
|
|
142
|
+
|
|
143
|
+
Run examples with:
|
|
144
|
+
```bash
|
|
145
|
+
npm run build
|
|
146
|
+
npx ts-node examples/basic-write.ts
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
## 🔍 When to Use XLSB vs XLSX
|
|
151
|
+
|
|
152
|
+
| Use XLSB When | Use XLSX When |
|
|
153
|
+
|---------------|---------------|
|
|
154
|
+
| Performance is critical | Need maximum compatibility |
|
|
155
|
+
| Working with large datasets | Sharing with older Excel versions |
|
|
156
|
+
| Internal/backend processing | Human-readable XML is needed |
|
|
157
|
+
| Storage space is limited | Third-party integrations require it |
|
|
158
|
+
|
|
159
|
+
## 🤝 Contributing
|
|
160
|
+
|
|
161
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
162
|
+
|
|
163
|
+
## 📄 License
|
|
164
|
+
|
|
165
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
166
|
+
|
|
167
|
+
## 🙏 Acknowledgments
|
|
168
|
+
|
|
169
|
+
- Inspired by and reimplemented from [SpreadSheetTasks](https://github.com/KrzysztofDusko/SpreadSheetTasks)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare class BiffReaderWriter {
|
|
2
|
+
private buffer;
|
|
3
|
+
private pos;
|
|
4
|
+
private length;
|
|
5
|
+
_isSheet: boolean;
|
|
6
|
+
_workbookId: number;
|
|
7
|
+
_recId: string | null;
|
|
8
|
+
_workbookName: string | null;
|
|
9
|
+
private _inCellXf;
|
|
10
|
+
private _inNumberFormat;
|
|
11
|
+
private _numberFormatIndex;
|
|
12
|
+
private _format;
|
|
13
|
+
private _formatString;
|
|
14
|
+
_sharedStringValue: string | null;
|
|
15
|
+
_sharedStringUniqueCount: number;
|
|
16
|
+
_cellType: number;
|
|
17
|
+
_intValue: number;
|
|
18
|
+
_doubleVal: number;
|
|
19
|
+
_boolValue: boolean;
|
|
20
|
+
_stringValue: string | null;
|
|
21
|
+
_columnNum: number;
|
|
22
|
+
_xfIndex: number;
|
|
23
|
+
_readCell: boolean;
|
|
24
|
+
_rowIndex: number;
|
|
25
|
+
private _recordStart;
|
|
26
|
+
_xfIndexToNumFmtId: number[];
|
|
27
|
+
_customNumFmts: Set<number>;
|
|
28
|
+
constructor(buffer: Buffer);
|
|
29
|
+
private _tryReadVariableValue;
|
|
30
|
+
private _getDWord;
|
|
31
|
+
private _getInt32;
|
|
32
|
+
private _getWord;
|
|
33
|
+
private _getByte;
|
|
34
|
+
private _getDouble;
|
|
35
|
+
private _getString;
|
|
36
|
+
private _getNullableString;
|
|
37
|
+
readWorkbook(): boolean;
|
|
38
|
+
readSharedStrings(): boolean;
|
|
39
|
+
readStyles(): boolean;
|
|
40
|
+
private _getRkNumber;
|
|
41
|
+
readWorksheet(): boolean;
|
|
42
|
+
}
|
|
43
|
+
export default BiffReaderWriter;
|
|
44
|
+
//# sourceMappingURL=BiffReaderWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BiffReaderWriter.d.ts","sourceRoot":"","sources":["../src/BiffReaderWriter.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAgB;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAS;IAEvB,QAAQ,EAAE,OAAO,CAAS;IAC1B,WAAW,EAAE,MAAM,CAAK;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEpC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,kBAAkB,CAAa;IACvC,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,aAAa,CAAuB;IAE5C,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAQ;IACzC,wBAAwB,EAAE,MAAM,CAAK;IAErC,SAAS,EAAE,MAAM,CAAK;IACtB,SAAS,EAAE,MAAM,CAAK;IACtB,UAAU,EAAE,MAAM,CAAO;IACzB,UAAU,EAAE,OAAO,CAAS;IAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAQ;IACnC,UAAU,EAAE,MAAM,CAAM;IACxB,QAAQ,EAAE,MAAM,CAAK;IACrB,SAAS,EAAE,OAAO,CAAS;IAC3B,SAAS,EAAE,MAAM,CAAM;IAGvB,OAAO,CAAC,YAAY,CAAa;IAEjC,kBAAkB,EAAE,MAAM,EAAE,CAAM;IAClC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;gBAE5B,MAAM,EAAE,MAAM;IAS1B,OAAO,CAAC,qBAAqB;IA2B7B,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,kBAAkB;IAW1B,YAAY,IAAI,OAAO;IA4BvB,iBAAiB,IAAI,OAAO;IAyB5B,UAAU,IAAI,OAAO;IAyDrB,OAAO,CAAC,YAAY;IA6BpB,aAAa,IAAI,OAAO;CAoF3B;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BiffReaderWriter = void 0;
|
|
4
|
+
class BiffReaderWriter {
|
|
5
|
+
constructor(buffer) {
|
|
6
|
+
this._isSheet = false;
|
|
7
|
+
this._workbookId = 0;
|
|
8
|
+
this._recId = null;
|
|
9
|
+
this._workbookName = null;
|
|
10
|
+
this._inCellXf = false;
|
|
11
|
+
this._inNumberFormat = false;
|
|
12
|
+
this._numberFormatIndex = 0;
|
|
13
|
+
this._format = 0;
|
|
14
|
+
this._formatString = null;
|
|
15
|
+
this._sharedStringValue = null;
|
|
16
|
+
this._sharedStringUniqueCount = 0;
|
|
17
|
+
this._cellType = 0;
|
|
18
|
+
this._intValue = 0;
|
|
19
|
+
this._doubleVal = 0.0;
|
|
20
|
+
this._boolValue = false;
|
|
21
|
+
this._stringValue = null;
|
|
22
|
+
this._columnNum = -1;
|
|
23
|
+
this._xfIndex = 0;
|
|
24
|
+
this._readCell = false;
|
|
25
|
+
this._rowIndex = -1;
|
|
26
|
+
// Start of the current record data (excluding ID and Length)
|
|
27
|
+
this._recordStart = 0;
|
|
28
|
+
this._xfIndexToNumFmtId = [];
|
|
29
|
+
this._customNumFmts = new Set();
|
|
30
|
+
if (!Buffer.isBuffer(buffer)) {
|
|
31
|
+
throw new Error("BiffReaderWriter expects a Buffer");
|
|
32
|
+
}
|
|
33
|
+
this.buffer = buffer;
|
|
34
|
+
this.pos = 0;
|
|
35
|
+
this.length = buffer.length;
|
|
36
|
+
}
|
|
37
|
+
_tryReadVariableValue() {
|
|
38
|
+
if (this.pos >= this.length)
|
|
39
|
+
return null;
|
|
40
|
+
const b1 = this.buffer[this.pos++];
|
|
41
|
+
let value = (b1 & 0x7F) >>> 0;
|
|
42
|
+
if ((b1 & 0x80) === 0)
|
|
43
|
+
return value;
|
|
44
|
+
if (this.pos >= this.length)
|
|
45
|
+
return null;
|
|
46
|
+
const b2 = this.buffer[this.pos++];
|
|
47
|
+
value = (((b2 & 0x7F) << 7) | value) >>> 0;
|
|
48
|
+
if ((b2 & 0x80) === 0)
|
|
49
|
+
return value;
|
|
50
|
+
if (this.pos >= this.length)
|
|
51
|
+
return null;
|
|
52
|
+
const b3 = this.buffer[this.pos++];
|
|
53
|
+
value = (((b3 & 0x7F) << 14) | value) >>> 0;
|
|
54
|
+
if ((b3 & 0x80) === 0)
|
|
55
|
+
return value;
|
|
56
|
+
if (this.pos >= this.length)
|
|
57
|
+
return null;
|
|
58
|
+
const b4 = this.buffer[this.pos++];
|
|
59
|
+
value = (((b4 & 0x7F) << 21) | value) >>> 0;
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
_getDWord(offset) {
|
|
63
|
+
return this.buffer.readUInt32LE(this._recordStart + offset);
|
|
64
|
+
}
|
|
65
|
+
_getInt32(offset) {
|
|
66
|
+
return this.buffer.readInt32LE(this._recordStart + offset);
|
|
67
|
+
}
|
|
68
|
+
_getWord(offset) {
|
|
69
|
+
return this.buffer.readUInt16LE(this._recordStart + offset);
|
|
70
|
+
}
|
|
71
|
+
_getByte(offset) {
|
|
72
|
+
return this.buffer[this._recordStart + offset];
|
|
73
|
+
}
|
|
74
|
+
_getDouble(offset) {
|
|
75
|
+
return this.buffer.readDoubleLE(this._recordStart + offset);
|
|
76
|
+
}
|
|
77
|
+
_getString(offset, length) {
|
|
78
|
+
const start = this._recordStart + offset;
|
|
79
|
+
const end = start + (length * 2);
|
|
80
|
+
if (end > this.buffer.length)
|
|
81
|
+
return "";
|
|
82
|
+
return this.buffer.toString('utf16le', start, end);
|
|
83
|
+
}
|
|
84
|
+
_getNullableString(offsetRef) {
|
|
85
|
+
const length = this._getDWord(offsetRef.val);
|
|
86
|
+
offsetRef.val += 4;
|
|
87
|
+
if (length === 0xFFFFFFFF)
|
|
88
|
+
return null;
|
|
89
|
+
const str = this._getString(offsetRef.val, length);
|
|
90
|
+
offsetRef.val += (length * 2);
|
|
91
|
+
return str;
|
|
92
|
+
}
|
|
93
|
+
readWorkbook() {
|
|
94
|
+
const recordId = this._tryReadVariableValue();
|
|
95
|
+
const recordLength = this._tryReadVariableValue();
|
|
96
|
+
if (recordId === null || recordLength === null)
|
|
97
|
+
return false;
|
|
98
|
+
const startPos = this.pos;
|
|
99
|
+
if (startPos + recordLength > this.length)
|
|
100
|
+
return false;
|
|
101
|
+
this._recordStart = startPos;
|
|
102
|
+
this.pos += recordLength;
|
|
103
|
+
this._isSheet = false;
|
|
104
|
+
if (recordId === 0x9C) {
|
|
105
|
+
this._workbookId = this._getDWord(4);
|
|
106
|
+
const offsetRef = { val: 8 };
|
|
107
|
+
this._recId = this._getNullableString(offsetRef);
|
|
108
|
+
const nameLength = this._getDWord(offsetRef.val);
|
|
109
|
+
this._workbookName = this._getString(offsetRef.val + 4, nameLength);
|
|
110
|
+
this._isSheet = true;
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
readSharedStrings() {
|
|
115
|
+
const recordId = this._tryReadVariableValue();
|
|
116
|
+
const recordLength = this._tryReadVariableValue();
|
|
117
|
+
if (recordId === null || recordLength === null)
|
|
118
|
+
return false;
|
|
119
|
+
const startPos = this.pos;
|
|
120
|
+
if (startPos + recordLength > this.length)
|
|
121
|
+
return false;
|
|
122
|
+
this._recordStart = startPos;
|
|
123
|
+
this.pos += recordLength;
|
|
124
|
+
this._sharedStringValue = null;
|
|
125
|
+
if (recordId === 0x13) {
|
|
126
|
+
const length = this._getDWord(1);
|
|
127
|
+
this._sharedStringValue = this._getString(5, length);
|
|
128
|
+
}
|
|
129
|
+
else if (recordId === 159) {
|
|
130
|
+
this._sharedStringUniqueCount = this._getDWord(4);
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
readStyles() {
|
|
135
|
+
const recordId = this._tryReadVariableValue();
|
|
136
|
+
const recordLength = this._tryReadVariableValue();
|
|
137
|
+
if (recordId === null || recordLength === null)
|
|
138
|
+
return false;
|
|
139
|
+
const startPos = this.pos;
|
|
140
|
+
if (startPos + recordLength > this.length)
|
|
141
|
+
return false;
|
|
142
|
+
this._recordStart = startPos;
|
|
143
|
+
this.pos += recordLength;
|
|
144
|
+
const _cellXfStart = 0x269;
|
|
145
|
+
const _cellXfEnd = 0x26a;
|
|
146
|
+
const _numberFormatStart = 0x267;
|
|
147
|
+
const _numberFormatEnd = 0x268;
|
|
148
|
+
const _xf = 0x2f;
|
|
149
|
+
const _numberFormat = 0x2c;
|
|
150
|
+
switch (recordId) {
|
|
151
|
+
case _cellXfStart:
|
|
152
|
+
this._inCellXf = true;
|
|
153
|
+
break;
|
|
154
|
+
case _cellXfEnd:
|
|
155
|
+
this._inCellXf = false;
|
|
156
|
+
break;
|
|
157
|
+
case _numberFormatStart:
|
|
158
|
+
this._inNumberFormat = true;
|
|
159
|
+
break;
|
|
160
|
+
case _numberFormatEnd:
|
|
161
|
+
this._inNumberFormat = false;
|
|
162
|
+
break;
|
|
163
|
+
case _xf:
|
|
164
|
+
if (this._inCellXf) {
|
|
165
|
+
this._numberFormatIndex = this._getWord(2);
|
|
166
|
+
this._xfIndexToNumFmtId.push(this._numberFormatIndex);
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
case _numberFormat:
|
|
170
|
+
if (this._inNumberFormat) {
|
|
171
|
+
this._format = this._getWord(0);
|
|
172
|
+
const length = this._getDWord(2);
|
|
173
|
+
this._formatString = this._getString(6, length);
|
|
174
|
+
const code = this._formatString.toLowerCase();
|
|
175
|
+
if (code.includes('yy') || code.includes('mm') || code.includes('dd') || code.includes('h:mm')) {
|
|
176
|
+
this._customNumFmts.add(this._format);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
_getRkNumber(offset) {
|
|
184
|
+
const flags = this._getByte(offset);
|
|
185
|
+
let result = 0;
|
|
186
|
+
if ((flags & 0x02) !== 0) {
|
|
187
|
+
const intVal = this._getInt32(offset);
|
|
188
|
+
result = intVal >> 2;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const raw = this._getInt32(offset);
|
|
192
|
+
const highBits = (raw & 0xFFFFFFFC);
|
|
193
|
+
// Need to construct a double from high bits.
|
|
194
|
+
// Since we can't easily write to a reused buffer without risk,
|
|
195
|
+
// we'll just alloc 8 bytes here. It's rare for RK to be double.
|
|
196
|
+
// Alternatively, we could reuse a small buffer if we cared enough.
|
|
197
|
+
const dBuf = Buffer.allocUnsafe(8);
|
|
198
|
+
dBuf.writeInt32LE(0, 0);
|
|
199
|
+
dBuf.writeInt32LE(highBits, 4);
|
|
200
|
+
result = dBuf.readDoubleLE(0);
|
|
201
|
+
}
|
|
202
|
+
if ((flags & 0x01) !== 0) {
|
|
203
|
+
result /= 100;
|
|
204
|
+
}
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
readWorksheet() {
|
|
208
|
+
const recordId = this._tryReadVariableValue();
|
|
209
|
+
const recordLength = this._tryReadVariableValue();
|
|
210
|
+
if (recordId === null || recordLength === null)
|
|
211
|
+
return false;
|
|
212
|
+
const startPos = this.pos;
|
|
213
|
+
if (startPos + recordLength > this.length)
|
|
214
|
+
return false;
|
|
215
|
+
this._recordStart = startPos;
|
|
216
|
+
this.pos += recordLength;
|
|
217
|
+
this._readCell = false;
|
|
218
|
+
this._columnNum = -1;
|
|
219
|
+
const _row = 0x00;
|
|
220
|
+
const _blank = 0x01;
|
|
221
|
+
const _number = 0x02;
|
|
222
|
+
const _boolError = 0x03;
|
|
223
|
+
const _bool = 0x04;
|
|
224
|
+
const _float = 0x05;
|
|
225
|
+
const _string = 0x06;
|
|
226
|
+
const _sharedString = 0x07;
|
|
227
|
+
const _formulaString = 0x08;
|
|
228
|
+
const _formulaNumber = 0x09;
|
|
229
|
+
const _formulaBool = 0x0a;
|
|
230
|
+
const _formulaError = 0x0b;
|
|
231
|
+
switch (recordId) {
|
|
232
|
+
case _row:
|
|
233
|
+
this._rowIndex = this._getInt32(0);
|
|
234
|
+
break;
|
|
235
|
+
case _blank:
|
|
236
|
+
case _boolError:
|
|
237
|
+
case _formulaError:
|
|
238
|
+
this._readCell = true;
|
|
239
|
+
this._cellType = 0;
|
|
240
|
+
break;
|
|
241
|
+
case _number:
|
|
242
|
+
this._doubleVal = this._getRkNumber(8);
|
|
243
|
+
this._readCell = true;
|
|
244
|
+
this._cellType = 3;
|
|
245
|
+
break;
|
|
246
|
+
case _bool:
|
|
247
|
+
case _formulaBool:
|
|
248
|
+
this._boolValue = (this._getByte(8) === 1);
|
|
249
|
+
this._readCell = true;
|
|
250
|
+
this._cellType = 4;
|
|
251
|
+
break;
|
|
252
|
+
case _formulaNumber:
|
|
253
|
+
case _float:
|
|
254
|
+
this._doubleVal = this._getDouble(8);
|
|
255
|
+
this._readCell = true;
|
|
256
|
+
this._cellType = 3;
|
|
257
|
+
break;
|
|
258
|
+
case _string:
|
|
259
|
+
case _formulaString:
|
|
260
|
+
{
|
|
261
|
+
const length = this._getDWord(8);
|
|
262
|
+
this._stringValue = this._getString(12, length);
|
|
263
|
+
this._readCell = true;
|
|
264
|
+
this._cellType = 5;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
case _sharedString:
|
|
268
|
+
this._intValue = this._getDWord(8);
|
|
269
|
+
this._readCell = true;
|
|
270
|
+
this._cellType = 2;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
if (this._readCell) {
|
|
274
|
+
this._columnNum = this._getDWord(0);
|
|
275
|
+
this._xfIndex = this._getDWord(4) & 0xffffff;
|
|
276
|
+
}
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
exports.BiffReaderWriter = BiffReaderWriter;
|
|
281
|
+
exports.default = BiffReaderWriter;
|
|
282
|
+
//# sourceMappingURL=BiffReaderWriter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BiffReaderWriter.js","sourceRoot":"","sources":["../src/BiffReaderWriter.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;IAmCzB,YAAY,MAAc;QA9B1B,aAAQ,GAAY,KAAK,CAAC;QAC1B,gBAAW,GAAW,CAAC,CAAC;QACxB,WAAM,GAAkB,IAAI,CAAC;QAC7B,kBAAa,GAAkB,IAAI,CAAC;QAE5B,cAAS,GAAY,KAAK,CAAC;QAC3B,oBAAe,GAAY,KAAK,CAAC;QACjC,uBAAkB,GAAW,CAAC,CAAC;QAC/B,YAAO,GAAW,CAAC,CAAC;QACpB,kBAAa,GAAkB,IAAI,CAA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,CAAC;gBACnB,MAAM;YAEV,KAAK,cAAc,CAAC;YACpB,KAAK,MAAM;gBACP,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBACrC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;gBACnB,MAAM;YAEV,KAAK,OAAO,CAAC;YACb,KAAK,cAAc;gBACf,CAAC;oBACG,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;oBACjC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;oBAChD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;oBACtB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;oBACnB,MAAM;gBACV,CAAC;YAEL,KAAK,aAAa;gBACd,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;gBACnB,MAAM;QACd,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC;QACjD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA5UD,4CA4UC;AAED,kBAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
export declare class BigBuffer {
|
|
3
|
+
private chunkSize;
|
|
4
|
+
private chunks;
|
|
5
|
+
private currentBuffer;
|
|
6
|
+
private cursor;
|
|
7
|
+
constructor(chunkSize?: number);
|
|
8
|
+
ensureCapacity(size: number): void;
|
|
9
|
+
private _ensureCapacity;
|
|
10
|
+
private _flush;
|
|
11
|
+
write(buffer: Buffer): void;
|
|
12
|
+
writeByte(val: number): void;
|
|
13
|
+
writeUnsafeByte(val: number): void;
|
|
14
|
+
writeInt32LE(val: number): void;
|
|
15
|
+
writeUnsafeInt32LE(val: number): void;
|
|
16
|
+
writeDoubleLE(val: number): void;
|
|
17
|
+
writeUnsafeDoubleLE(val: number): void;
|
|
18
|
+
writeString(str: string): void;
|
|
19
|
+
writeUtf16LE(str: string): void;
|
|
20
|
+
getChunks(): Buffer[];
|
|
21
|
+
reset(): void;
|
|
22
|
+
}
|
|
23
|
+
export default BigBuffer;
|
|
24
|
+
//# sourceMappingURL=BigBuffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BigBuffer.d.ts","sourceRoot":"","sources":["../src/BigBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,qBAAa,SAAS;IAClB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,MAAM,CAAS;gBAEX,SAAS,GAAE,MAAc;IAOrC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAMlC,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,MAAM;IAQd,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAoB3B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAM5B,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIlC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAM/B,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKrC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMhC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKtC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAiB9B,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAwB/B,SAAS,IAAI,MAAM,EAAE;IASrB,KAAK,IAAI,IAAI;CAIhB;AAED,eAAe,SAAS,CAAC"}
|