Skip to content

Fixed undefined ref error when setting a data validation that is a range of cells at the worksheet level #1480

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 2 commits into from
Oct 1, 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
9 changes: 8 additions & 1 deletion lib/xlsx/xform/sheet/data-validations-xform.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ function optimiseDataValidations(model) {
return dvList
.map(dv => {
if (!dv.marked) {
const addr = colCache.decodeAddress(dv.address);
const addr = colCache.decodeEx(dv.address);
if (addr.dimensions) {
dvMap[addr.dimensions].marked = true;
return {
...dv.dataValidation,
sqref: dv.address,
};
}

// iterate downwards - finding matching cells
let height = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const ExcelJS = verquire('exceljs');

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

describe('github issues', () => {
it('issue 1027 - Broken due to Cannot set property \'marked\' of undefined error', () => {
const wb = new ExcelJS.Workbook();
const ws = wb.addWorksheet('Sheet1');

const range = 'A2:A1048576';

ws.dataValidations.model[range] = {
allowBlank: true,
error: 'Please use the drop down to select a valid value',
errorTitle: 'Invalid Selection',
formulae: ['"Apples,Bananas,Oranges"'],
showErrorMessage: true,
type: 'list',
};

return wb.xlsx.writeFile(TEST_XLSX_FILE_NAME);
});
});