Skip to content

Commit 24d7a5a

Browse files
committed
Merge branch 'master' into async-iterators
2 parents 6dec202 + 9596506 commit 24d7a5a

File tree

7 files changed

+29
-5
lines changed

7 files changed

+29
-5
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,21 @@ workbook.eachSheet(function(worksheet, sheetId) {
352352
const worksheet = workbook.getWorksheet('My Sheet');
353353

354354
// fetch sheet by id
355+
// INFO: Be careful when using it!
356+
// It tries to access to `worksheet.id` field. Sometimes (really very often) workbook has worksheets with id not starting from 1.
357+
// For instance It happens when any worksheet has been deleted.
358+
// It's much more safety when you assume that ids are random. And stop to use this function.
359+
// If you need to access all worksheets in a loop please look to the next example.
355360
const worksheet = workbook.getWorksheet(1);
361+
362+
// access by `worksheets` array:
363+
workbook.worksheets[0]; //the first one;
364+
356365
```
357366

367+
It's important to know that `workbook.getWorksheet(1) != Workbook.worksheets[0]` and `workbook.getWorksheet(1) != Workbook.worksheets[1]`,
368+
becouse `workbook.worksheets[0].id` may have any value.
369+
358370
## Worksheet State
359371

360372
```javascript

lib/csv/csv.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CSV {
4848
return new Promise((resolve, reject) => {
4949
const worksheet = this.workbook.addWorksheet(options.sheetName);
5050

51-
const dateFormats = options.dateFormats || ['YYYY-MM-DD[T]HH:mm:ss', 'MM-DD-YYYY', 'YYYY-MM-DD'];
51+
const dateFormats = options.dateFormats || ['YYYY-MM-DD[T]HH:mm:ssZ', 'YYYY-MM-DD[T]HH:mm:ss', 'MM-DD-YYYY', 'YYYY-MM-DD'];
5252
const map =
5353
options.map ||
5454
function(datum) {

lib/xlsx/xform/book/workbook-xform.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ class WorkbookXform extends BaseXform {
157157
if (!rel) {
158158
return;
159159
}
160-
worksheet = model.worksheetHash[`xl/${rel.Target}`];
160+
// if rel.Target start with `[space]/xl/` or `/xl/` , then it will be replaced with `''` and spliced behind `xl/`,
161+
// otherwise it will be spliced directly behind `xl/`. i.g.
162+
worksheet = model.worksheetHash[`xl/${rel.Target.replace(/^(\s|\/xl\/)+/, '')}`];
161163
// If there are "chartsheets" in the file, rel.Target will
162164
// come out as chartsheets/sheet1.xml or similar here, and
163165
// that won't be in model.worksheetHash.

lib/xlsx/xform/sheet/worksheet-xform.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,12 @@ class WorkSheetXform extends BaseXform {
379379
}
380380
switch (name) {
381381
case 'worksheet': {
382-
const properties = this.map.sheetFormatPr.model;
382+
const properties = this.map.sheetFormatPr.model || {};
383383
if (this.map.sheetPr.model && this.map.sheetPr.model.tabColor) {
384384
properties.tabColor = this.map.sheetPr.model.tabColor;
385385
}
386386
if (this.map.sheetPr.model && this.map.sheetPr.model.outlineProperties) {
387-
properties.outlineProperties = this.map.sheetPr.model.outlinePropertiesx;
387+
properties.outlineProperties = this.map.sheetPr.model.outlineProperties;
388388
}
389389
const sheetProperties = {
390390
fitToPage: (this.map.sheetPr.model && this.map.sheetPr.model.pageSetup && this.map.sheetPr.model.pageSetup.fitToPage) || false,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
],
9494
"dependencies": {
9595
"archiver": "^4.0.1",
96-
"dayjs": "^1.8.25",
96+
"dayjs": "^1.8.26",
9797
"fast-csv": "^4.1.2",
9898
"jszip": "^3.4.0",
9999
"readable-stream": "^3.6.0",
37.7 KB
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const ExcelJS = verquire('exceljs');
2+
3+
describe('github issues', () => {
4+
it('pull request 1220 - The worksheet should not be undefined', async () => {
5+
const wb = new ExcelJS.Workbook();
6+
await wb.xlsx.readFile('./spec/integration/data/test-pr-1220.xlsx');
7+
const ws = wb.getWorksheet(1);
8+
expect(ws).to.not.equal(undefined);
9+
});
10+
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy