From ff629a225335dc784933c06aabd20ddca5fcdbef Mon Sep 17 00:00:00 2001 From: Nater Jorde Date: Sun, 12 Nov 2017 15:08:17 -0600 Subject: [PATCH] fix issue with multiple data validations as described in https://github.com/natergj/excel4node/issues/94#issuecomment-342922699 --- source/lib/worksheet/classes/dataValidation.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/lib/worksheet/classes/dataValidation.js b/source/lib/worksheet/classes/dataValidation.js index 0153dc4..9780d3f 100644 --- a/source/lib/worksheet/classes/dataValidation.js +++ b/source/lib/worksheet/classes/dataValidation.js @@ -152,8 +152,13 @@ class DataValidation { // §18.3.1.32 dataValidation (Data Validation) this.promptTitle !== undefined ? valEle.att('promptTitle', this.promptTitle) : null; this.prompt !== undefined ? valEle.att('prompt', this.prompt) : null; this.sqref !== undefined ? valEle.att('sqref', this.sqref) : null; - this.formula1 !== undefined ? valEle.ele('formula1').text(cleanFormula(this.formula1)) : null; - this.formula2 !== undefined ? valEle.ele('formula2').text(cleanFormula(this.formula2)) : null; + if (this.formula1 !== undefined) { + valEle.ele('formula1').text(cleanFormula(this.formula1)); + if (this.formula2 !== undefined) { + valEle.up(); + valEle.ele('formula2').text(cleanFormula(this.formula2)); + } + } valEle.up(); } } @@ -178,8 +183,8 @@ class DataValidationCollection { // §18.3.1.33 dataValidations (Data Validation let valsEle = ele.ele('dataValidations').att('count', this.length); this.items.forEach((val) => { val.addToXMLele(valsEle); + valsEle.up(); }); - valsEle.up(); } }