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
2 changes: 1 addition & 1 deletion lib/utils/shared-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class SharedStrings {
constructor() {
this._values = [];
this._totalRefs = 0;
this._hash = {};
this._hash = Object.create(null);
}

get count() {
Expand Down
43 changes: 43 additions & 0 deletions spec/integration/issues/issue-1339-speciel-cell-file.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const ExcelJS = verquire('exceljs');

// this file to contain integration tests created from github issues
const TEST_XLSX_FILE_NAME = './spec/out/wb.test.xlsx';

describe('github issues', () => {
it('issue 1339 - Special cell value results invalid file', async () => {
const wb = new ExcelJS.stream.xlsx.WorkbookWriter({
filename: TEST_XLSX_FILE_NAME,
useStyles: true,
useSharedStrings: true,
});
const ws = wb.addWorksheet('Sheet1');
const specialValues = [
'constructor',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'toLocaleString',
'toString',
'valueOf',
'__defineGetter__',
'__defineSetter__',
'__lookupGetter__',
'__lookupSetter__',
'__proto__',
];
for (let i = 0, len = specialValues.length; i < len; i++) {
const value = specialValues[i];
ws.addRow([value]);
ws.getCell(`B${i + 1}`).value = value;
}
await wb.commit();
const wb2 = new ExcelJS.Workbook();
await wb2.xlsx.readFile(TEST_XLSX_FILE_NAME);
const ws2 = wb2.getWorksheet('Sheet1');
for (let i = 0, len = specialValues.length; i < len; i++) {
const value = specialValues[i];
expect(ws2.getCell(`A${i + 1}`).value).to.equal(value);
expect(ws2.getCell(`B${i + 1}`).value).to.equal(value);
}
});
});