Skip to content

fix issue #1157 marked Cannot set property #1204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2020
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
5 changes: 5 additions & 0 deletions lib/xlsx/xform/sheet/data-validations-xform.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ class DataValidationsXform extends BaseXform {
range.forEachAddress(address => {
this.model[address] = this._dataValidation;
});
} else if (/\s+/g.test(this._address)) {
const list = this._address.split(/\s+/g);
list.forEach(addr => {
this.model[addr] = this._dataValidation;
});
} else {
this.model[this._address] = this._dataValidation;
}
Expand Down
Binary file added spec/integration/data/test-pr-1204.xlsx
Binary file not shown.
29 changes: 29 additions & 0 deletions spec/integration/pr/test-pr-1157.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const ExcelJS = verquire('exceljs');

const TEST_XLSX_FILE_NAME = './spec/out/wb.test.xlsx';

describe('github issues', () => {
it('pull request 1204 - Read and write data validation should be successful', async () => {
const wb = new ExcelJS.Workbook();
await wb.xlsx.readFile('./spec/integration/data/test-pr-1204.xlsx');
const expected = {
E1: {
type: 'textLength',
formulae: [2],
showInputMessage: true,
showErrorMessage: true,
operator: 'greaterThan',
},
E4: {
type: 'textLength',
formulae: [2],
showInputMessage: true,
showErrorMessage: true,
operator: 'greaterThan',
},
};
const ws = wb.getWorksheet(1);
expect(ws.dataValidations.model).to.deep.equal(expected);
await wb.xlsx.writeFile(TEST_XLSX_FILE_NAME);
});
});