Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Don't break when loading an Excel file containing a chartsheet
  • Loading branch information
papandreou committed Dec 19, 2017
commit fd0bf4cac554d32a6e2cc389dbc97298dfd54d15
13 changes: 10 additions & 3 deletions lib/xlsx/xform/book/workbook-xform.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,16 @@ utils.inherits(WorkbookXform, BaseXform, {
return;
}
worksheet = model.worksheetHash['xl/' + rel.Target];
worksheet.name = sheet.name;
worksheet.id = sheet.id;
worksheets[index++] = worksheet;
// If there are "chartsheets" in the file, rel.Target will
// come out as chartsheets/sheet1.xml or similar here, and
// that won't be in model.worksheetHash.
// As we don't have the infrastructure to support chartsheets,
// we will ignore them for now:
if (worksheet) {
worksheet.name = sheet.name;
worksheet.id = sheet.id;
worksheets[index++] = worksheet;
}
});

// reconcile print areas
Expand Down
Binary file added spec/integration/data/chart-sheet.xlsx
Binary file not shown.
8 changes: 8 additions & 0 deletions spec/integration/worksheet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,12 @@ describe('Worksheet', function() {
});
});
});

it('Should not break when importing an Excel file that contains a chartsheet', function() {
return new Excel.Workbook().xlsx.readFile(path.resolve(__dirname, 'data', 'chart-sheet.xlsx'))
.then(function(workbook) {
expect(workbook).to.have.property('worksheets');
expect(workbook.worksheets).to.have.length(1);
});
});
});