Skip to content

Commit ab776ef

Browse files
authored
Merge pull request #1480 from Bene-Graham/fix-bug-1027
Fixed undefined ref error when setting a data validation that is a range of cells at the worksheet level
2 parents ebb31f2 + 02c7dab commit ab776ef

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

lib/xlsx/xform/sheet/data-validations-xform.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ function optimiseDataValidations(model) {
5151
return dvList
5252
.map(dv => {
5353
if (!dv.marked) {
54-
const addr = colCache.decodeAddress(dv.address);
54+
const addr = colCache.decodeEx(dv.address);
55+
if (addr.dimensions) {
56+
dvMap[addr.dimensions].marked = true;
57+
return {
58+
...dv.dataValidation,
59+
sqref: dv.address,
60+
};
61+
}
5562

5663
// iterate downwards - finding matching cells
5764
let height = 1;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const ExcelJS = verquire('exceljs');
2+
3+
const TEST_XLSX_FILE_NAME = './spec/out/wb.test.xlsx';
4+
5+
describe('github issues', () => {
6+
it('issue 1027 - Broken due to Cannot set property \'marked\' of undefined error', () => {
7+
const wb = new ExcelJS.Workbook();
8+
const ws = wb.addWorksheet('Sheet1');
9+
10+
const range = 'A2:A1048576';
11+
12+
ws.dataValidations.model[range] = {
13+
allowBlank: true,
14+
error: 'Please use the drop down to select a valid value',
15+
errorTitle: 'Invalid Selection',
16+
formulae: ['"Apples,Bananas,Oranges"'],
17+
showErrorMessage: true,
18+
type: 'list',
19+
};
20+
21+
return wb.xlsx.writeFile(TEST_XLSX_FILE_NAME);
22+
});
23+
});

0 commit comments

Comments
 (0)