Skip to content

Commit aa16b15

Browse files
Merge pull request #31 from zurmokeeper/bugfix/rich_text_error
fix rich text tags bug and add type definitions
2 parents 0120757 + 79a0191 commit aa16b15

File tree

9 files changed

+33
-18
lines changed

9 files changed

+33
-18
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
node-version: [10.x, 12.x, 14.x, 16.x, 18.x, 20.x]
16+
node-version: [10.x, 12.x, 14.x, 16.x, 18.x, 20.x, 21.x]
1717
os: [ubuntu-latest, macOS-latest, windows-latest]
1818
runs-on: ${{ matrix.os }}
1919

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2345,7 +2345,7 @@ Options supported when reading CSV files.
23452345
| dateFormats | N | Array | Specify the date encoding format of dayjs. |
23462346
| map | N | Function | Custom Array.prototype.map() callback function for processing data. |
23472347
| sheetName | N | String | Specify worksheet name. |
2348-
| parserOptions | N | Object | [parseOptions options](https://c2fo.io/fast-csv/docs/parsing/options) @fast-csv/format module to write csv data. |
2348+
| parserOptions | N | Object | [parseOptions options](https://c2fo.github.io/fast-csv/docs/parsing/options) @fast-csv/format module to write csv data. |
23492349

23502350
```javascript
23512351
// read from a file
@@ -2388,7 +2388,7 @@ const options = {
23882388
return parseFloat(value);
23892389
}
23902390
},
2391-
// https://c2fo.io/fast-csv/docs/parsing/options
2391+
// https://c2fo.github.io/fast-csv/docs/parsing/options
23922392
parserOptions: {
23932393
delimiter: '\t',
23942394
quote: false,
@@ -2424,7 +2424,7 @@ Options supported when writing to a CSV file.
24242424
| map | N | Function | Custom Array.prototype.map() callback function for processing row values. |
24252425
| sheetName | N | String | Specify worksheet name. |
24262426
| sheetId | N | Number | Specify worksheet ID. |
2427-
| formatterOptions | N | Object | [formatterOptions options](https://c2fo.io/fast-csv/docs/formatting/options/) @fast-csv/format module to write csv data. |
2427+
| formatterOptions | N | Object | [formatterOptions options](https://c2fo.github.io/fast-csv/docs/formatting/options/) @fast-csv/format module to write csv data. |
24282428

24292429
```javascript
24302430

@@ -2465,7 +2465,7 @@ const options = {
24652465
return value;
24662466
}
24672467
},
2468-
// https://c2fo.io/fast-csv/docs/formatting/options
2468+
// https://c2fo.github.io/fast-csv/docs/formatting/options
24692469
formatterOptions: {
24702470
delimiter: '\t',
24712471
quote: false,

README_zh.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2236,7 +2236,7 @@ const buffer = await workbook.xlsx.writeBuffer({password: '123456'});
22362236
| dateFormats | N | Array | 指定 dayjs 的日期编码格式。 |
22372237
| map | N | Function | 自定义`Array.prototype.map()` 回调函数,用于处理数据。 |
22382238
| sheetName | N | String | 指定工作表名称。 |
2239-
| parserOptions | N | Object | [parseOptions 选项](https://c2fo.io/fast-csv/docs/parsing/options) @fast-csv/format 模块以写入 csv 数据。 |
2239+
| parserOptions | N | Object | [parseOptions 选项](https://c2fo.github.io/fast-csv/docs/parsing/options) @fast-csv/format 模块以写入 csv 数据。 |
22402240

22412241
```javascript
22422242
// 从文件读取
@@ -2279,7 +2279,7 @@ const options = {
22792279
return parseFloat(value);
22802280
}
22812281
},
2282-
// https://c2fo.io/fast-csv/docs/parsing/options
2282+
// https://c2fo.github.io/fast-csv/docs/parsing/options
22832283
parserOptions: {
22842284
delimiter: '\t',
22852285
quote: false,
@@ -2312,7 +2312,7 @@ CSV 解析器使用 [fast-csv](https://www.npmjs.com/package/fast-csv) 读取CSV
23122312
| map | N | Function | 自定义`Array.prototype.map()` 回调函数,用于处理行值。 |
23132313
| sheetName | N | String | 指定工作表名称。 |
23142314
| sheetId | N | Number | 指定工作表 ID。 |
2315-
| formatterOptions | N | Object | [formatterOptions 选项](https://c2fo.io/fast-csv/docs/formatting/options/) @fast-csv/format 模块写入csv 数据。 |
2315+
| formatterOptions | N | Object | [formatterOptions 选项](https://c2fo.github.io/fast-csv/docs/formatting/options/) @fast-csv/format 模块写入csv 数据。 |
23162316

23172317
```javascript
23182318

@@ -2352,7 +2352,7 @@ const options = {
23522352
return value;
23532353
}
23542354
},
2355-
// https://c2fo.io/fast-csv/docs/formatting/options
2355+
// https://c2fo.github.io/fast-csv/docs/formatting/options
23562356
formatterOptions: {
23572357
delimiter: '\t',
23582358
quote: false,

index.d.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export interface Font {
230230
}
231231

232232
export type BorderStyle =
233-
| 'thin' | 'dotted' | 'hair' | 'medium' | 'double' | 'thick' | 'dashDot'
233+
| 'thin' | 'dotted' | 'hair' | 'medium' | 'double' | 'thick' | 'dashed' | 'dashDot'
234234
| 'dashDotDot' | 'slantDashDot' | 'mediumDashed' | 'mediumDashDotDot' | 'mediumDashDot';
235235

236236
export type ColorIndexes = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
@@ -371,6 +371,7 @@ export interface Alignment {
371371

372372
export interface Protection {
373373
locked: boolean;
374+
hidden: boolean;
374375
}
375376

376377
export interface Style {
@@ -426,19 +427,20 @@ export interface CellRichTextValue {
426427
export interface CellHyperlinkValue {
427428
text: string;
428429
hyperlink: string;
430+
tooltip?: string;
429431
}
430432

431433
export interface CellFormulaValue {
432434
formula: string;
433-
result?: number | string | Date | { error: CellErrorValue };
434-
date1904: boolean;
435+
result?: number | string | boolean | Date | CellErrorValue;
436+
date1904?: boolean;
435437
}
436438

437439
export interface CellSharedFormulaValue {
438440
sharedFormula: string;
439441
readonly formula?: string;
440-
result?: number | string | Date | { error: CellErrorValue };
441-
date1904: boolean;
442+
result?: number | string | boolean | Date | CellErrorValue;
443+
date1904?: boolean;
442444
}
443445

444446
export declare enum ValueType {
@@ -1234,7 +1236,7 @@ export interface Worksheet {
12341236
/**
12351237
* Get the last column in a worksheet
12361238
*/
1237-
readonly lastColumn: Column;
1239+
readonly lastColumn: Column | undefined;
12381240

12391241
/**
12401242
* A count of the number of columns that have values.
@@ -1667,7 +1669,7 @@ export interface Xlsx {
16671669
write(stream: import('stream').Stream, options?: Partial<XlsxWriteOptions>): Promise<void>;
16681670
}
16691671

1670-
// https://c2fo.io/fast-csv/docs/parsing/options
1672+
// https://c2fo.github.io/fast-csv/docs/parsing/options
16711673

16721674
type HeaderArray = (string | undefined | null)[];
16731675
type HeaderTransformFunction = (headers: HeaderArray) => HeaderArray;
@@ -1708,7 +1710,7 @@ interface RowTransformFunction {
17081710
(row: Rows): Rows;
17091711
}
17101712

1711-
// https://c2fo.io/fast-csv/docs/formatting/options/
1713+
// https://c2fo.github.io/fast-csv/docs/formatting/options/
17121714
export interface FastCsvFormatterOptionsArgs {
17131715
objectMode: boolean;
17141716
delimiter: string;

lib/xlsx/xform/strings/shared-string-xform.js

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class SharedStringXform extends BaseXform {
7575
case 'r': {
7676
let rt = this.model.richText;
7777
if (!rt) {
78+
if (!this.model) {
79+
this.model = {};
80+
}
7881
rt = this.model.richText = [];
7982
}
8083
rt.push(this.parser.model);

lib/xlsx/xform/style/border-xform.js

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class EdgeXform extends BaseXform {
8989

9090
EdgeXform.validStyleValues = [
9191
'thin',
92+
'dashed',
9293
'dotted',
9394
'dashDot',
9495
'hair',

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zurmokeeper/exceljs",
3-
"version": "4.4.6",
3+
"version": "4.4.7",
44
"description": "Excel Workbook Manager - Read and Write xlsx and csv Files.",
55
"private": false,
66
"license": "MIT",
7.61 KB
Binary file not shown.

spec/integration/workbook-xlsx-reader.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -428,4 +428,13 @@ describe('WorkbookReader', () => {
428428
);
429429
});
430430
});
431+
432+
describe('with rich text to describe a hyperlink', () => {
433+
it('should parse with no errors', () => {
434+
const workbook = new ExcelJS.Workbook();
435+
return workbook.xlsx.read(
436+
fs.createReadStream('./spec/integration/data/rich-text-parse-test.xlsx')
437+
);
438+
});
439+
});
431440
});

0 commit comments

Comments
 (0)