@elbstack/xlsx-populate
Version:
Excel XLSX parser/generator written in JavaScript with Node.js and browser support, jQuery/d3-style method chaining, and a focus on keeping existing workbook features and styles in tact.
1 lines • 620 kB
JavaScript
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).XlsxPopulate=e()}}(function(){var define,module,exports;return function a(o,s,f){function u(r,e){if(!s[r]){if(!o[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(c)return c(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var i=s[r]={exports:{}};o[r][0].call(i.exports,function(e){var t=o[r][1][e];return u(t||e)},i,i.exports,a,o,s,f)}return s[r].exports}for(var c="function"==typeof require&&require,e=0;e<f.length;e++)u(f[e]);return u}({1:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();e("lodash");var i=e("./xmlq"),a=e("./ArgHandler"),o=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._node=e}return n(t,[{key:"isSecure",value:function(e){var t=this;return new a("Range.formula").case(function(){var e=i.findChild(t._node,"DocSecurity");return!!e&&1===e.children[0]}).case("boolean",function(e){return i.appendChildIfNotFound(t._node,"DocSecurity").children=[e?1:0],t}).handle(arguments)}},{key:"toXml",value:function(){return this._node}}]),t}();t.exports=o},{"./ArgHandler":2,"./xmlq":26,lodash:191}],2:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=e("lodash"),a=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._name=e,this._cases=[]}return n(t,[{key:"case",value:function(e,t){return 1===arguments.length&&(t=e,e=[]),Array.isArray(e)||(e=[e]),this._cases.push({types:e,handler:t}),this}},{key:"handle",value:function(e){for(var t=0;t<this._cases.length;t++){var r=this._cases[t];if(this._argsMatchTypes(e,r.types))return r.handler.apply(null,e)}throw new Error(this._name+": Invalid arguments.")}},{key:"_argsMatchTypes",value:function(e,n){return e.length===n.length&&i.every(e,function(e,t){var r=n[t];if("*"===r)return!0;if("nil"===r)return i.isNil(e);if("string"===r)return"string"==typeof e;if("boolean"===r)return"boolean"==typeof e;if("number"===r)return"number"==typeof e;if("integer"===r)return"number"==typeof e&&i.isInteger(e);if("function"===r)return"function"==typeof e;if("array"===r)return Array.isArray(e);if("date"===r)return e&&e.constructor===Date;if("object"===r)return e&&e.constructor===Object;if(e&&e.constructor&&e.constructor.name===r)return!0;throw new Error("Unknown type: "+r)})}}]),t}();t.exports=a},{lodash:191}],3:[function(e,t,r){"use strict";var i=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var c=e("lodash"),a=e("./ArgHandler"),h=e("./addressConverter"),o=e("./dateConverter"),s=e("./regexify"),l=e("./xmlq"),d=e("./FormulaError"),f=e("./Style"),n=function(){function n(e,t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this._row=e,this._init(t,r)}return i(n,[{key:"active",value:function(){var t=this;return new a("Cell.active").case(function(){return t.sheet().activeCell()===t}).case("boolean",function(e){if(!e)throw new Error("Deactivating cell directly not supported. Activate a different cell instead.");return t.sheet().activeCell(t),t}).handle(arguments)}},{key:"address",value:function(e){return h.toAddress({type:"cell",rowNumber:this.rowNumber(),columnNumber:this.columnNumber(),sheetName:e&&e.includeSheetName&&this.sheet().name(),rowAnchored:e&&(e.rowAnchored||e.anchored),columnAnchored:e&&(e.columnAnchored||e.anchored)})}},{key:"column",value:function(){return this.sheet().column(this.columnNumber())}},{key:"clear",value:function(){var e=this._formulaRef&&this._sharedFormulaId;return delete this._value,delete this._formulaType,delete this._formula,delete this._sharedFormulaId,delete this._formulaRef,c.isNil(e)||this.sheet().clearCellsUsingSharedFormula(e),this}},{key:"columnName",value:function(){return h.columnNumberToName(this.columnNumber())}},{key:"columnNumber",value:function(){return this._columnNumber}},{key:"find",value:function(e,t){e=s(e);var r=this.value();if("string"!=typeof r)return!1;if(c.isNil(t))return e.test(r);var n=r.replace(e,t);return n!==r&&(this.value(n),!0)}},{key:"formula",value:function(){var t=this;return new a("Cell.formula").case(function(){return"shared"!==t._formulaType||t._formulaRef?t._formula:"SHARED"}).case("nil",function(){return t.clear(),t}).case("string",function(e){return t.clear(),t._formulaType="normal",t._formula=e,t}).handle(arguments)}},{key:"hyperlink",value:function(){var t=this;return new a("Cell.hyperlink").case(function(){return t.sheet().hyperlink(t.address())}).case("*",function(e){return t.sheet().hyperlink(t.address(),e),t}).handle(arguments)}},{key:"dataValidation",value:function(){var t=this;return new a("Cell.dataValidation").case(function(){return t.sheet().dataValidation(t.address())}).case("boolean",function(e){return t.sheet().dataValidation(t.address(),e)}).case("*",function(e){return t.sheet().dataValidation(t.address(),e),t}).handle(arguments)}},{key:"tap",value:function(e){return e(this),this}},{key:"thru",value:function(e){return e(this)}},{key:"rangeTo",value:function(e){return this.sheet().range(this,e)}},{key:"relativeCell",value:function(e,t){var r=e+this.rowNumber(),n=t+this.columnNumber();return this.sheet().cell(r,n)}},{key:"row",value:function(){return this._row}},{key:"rowNumber",value:function(){return this.row().rowNumber()}},{key:"sheet",value:function(){return this.row().sheet()}},{key:"style",value:function(){var i=this;return this._style||arguments[0]instanceof f||(this._style=this.workbook().styleSheet().createStyle(this._styleId)),new a("Cell.style").case("string",function(e){return i._style.style(e)}).case("array",function(e){var t={};return e.forEach(function(e){t[e]=i.style(e)}),t}).case(["string","array"],function(e,t){var r=t.length,n=t[0].length;return i.rangeTo(i.relativeCell(r-1,n-1)).style(e,t)}).case(["string","*"],function(e,t){return i._style.style(e,t),i}).case("object",function(e){for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];i.style(t,r)}return i}).case("Style",function(e){return i._style=e,i._styleId=e.id(),i}).handle(arguments)}},{key:"value",value:function(){var n=this;return new a("Cell.value").case(function(){return n._value}).case("array",function(e){var t=e.length,r=e[0].length;return n.rangeTo(n.relativeCell(t-1,r-1)).value(e)}).case("*",function(e){return n.clear(),n._value=e,n}).handle(arguments)}},{key:"workbook",value:function(){return this.row().workbook()}},{key:"getSharedRefFormula",value:function(){return"shared"===this._formulaType?this._formulaRef&&this._formula:void 0}},{key:"sharesFormula",value:function(e){return"shared"===this._formulaType&&this._sharedFormulaId===e}},{key:"setSharedFormula",value:function(e,t,r){this.clear(),this._formulaType="shared",this._sharedFormulaId=e,this._formula=t,this._formulaRef=r}},{key:"toXml",value:function(){var e={name:"c",attributes:this._remainingAttributes||{},children:[]};if(e.attributes.r=this.address(),c.isNil(this._formulaType)){if(!c.isNil(this._value)){var t=void 0,r=void 0;"string"==typeof this._value||c.isArray(this._value)?(t="s",r=this.workbook().sharedStrings().getIndexForString(this._value)):"boolean"==typeof this._value?(t="b",r=this._value?1:0):"number"==typeof this._value?r=this._value:this._value instanceof Date&&(r=o.dateToNumber(this._value)),t&&(e.attributes.t=t);var n={name:"v",children:[r]};e.children.push(n)}}else{var i={name:"f",attributes:this._remainingFormulaAttributes||{}};"normal"!==this._formulaType&&(i.attributes.t=this._formulaType),c.isNil(this._formulaRef)||(i.attributes.ref=this._formulaRef),c.isNil(this._sharedFormulaId)||(i.attributes.si=this._sharedFormulaId),c.isNil(this._formula)||(i.children=[this._formula]),e.children.push(i)}return c.isNil(this._style)?c.isNil(this._styleId)||(e.attributes.s=this._styleId):e.attributes.s=this._style.id(),this._remainingChildren&&(e.children=e.children.concat(this._remainingChildren)),e}},{key:"_init",value:function(e,t){c.isObject(e)?this._parseNode(e):(this._columnNumber=e,c.isNil(t)||(this._styleId=t))}},{key:"_parseNode",value:function(e){var t=h.fromAddress(e.attributes.r);this._columnNumber=t.columnNumber,c.isNil(e.attributes.s)||(this._styleId=e.attributes.s);var r=l.findChild(e,"f");r&&(this._formulaType=r.attributes.t||"normal",this._formulaRef=r.attributes.ref,this._formula=r.children[0],this._sharedFormulaId=r.attributes.si,c.isNil(this._sharedFormulaId)||this.sheet().updateMaxSharedFormulaId(this._sharedFormulaId),delete r.attributes.t,delete r.attributes.ref,delete r.attributes.si,c.isEmpty(r.attributes)||(this._remainingFormulaAttributes=r.attributes));var n=e.attributes.t;if("s"===n){var i=l.findChild(e,"v").children[0];this._value=this.workbook().sharedStrings().getStringByIndex(i)}else if("str"===n){var a=l.findChild(e,"v");this._value=a&&a.children[0]}else if("inlineStr"===n){var o=l.findChild(e,"is");if("t"===o.children[0].name){var s=o.children[0];this._value=s.children[0]}else this._value=o.children}else if("b"===n)this._value=1===l.findChild(e,"v").children[0];else if("e"===n){var f=l.findChild(e,"v").children[0];this._value=d.getError(f)}else{var u=l.findChild(e,"v");this._value=u&&Number(u.children[0])}delete e.attributes.r,delete e.attributes.s,delete e.attributes.t,c.isEmpty(e.attributes)||(this._remainingAttributes=e.attributes),l.removeChild(e,"f"),l.removeChild(e,"v"),l.removeChild(e,"is"),c.isEmpty(e.children)||(this._remainingChildren=e.children)}}]),n}();t.exports=n},{"./ArgHandler":2,"./FormulaError":8,"./Style":14,"./addressConverter":20,"./dateConverter":23,"./regexify":25,"./xmlq":26,lodash:191}],4:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=e("./ArgHandler"),a=e("./addressConverter"),o=function(){function r(e,t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this._sheet=e,this._node=t}return n(r,[{key:"address",value:function(e){return a.toAddress({type:"column",columnName:this.columnName(),sheetName:e&&e.includeSheetName&&this.sheet().name(),columnAnchored:e&&e.anchored})}},{key:"cell",value:function(e){return this.sheet().cell(e,this.columnNumber())}},{key:"columnName",value:function(){return a.columnNumberToName(this.columnNumber())}},{key:"columnNumber",value:function(){return this._node.attributes.min}},{key:"hidden",value:function(){var t=this;return new i("Column.hidden").case(function(){return 1===t._node.attributes.hidden}).case("boolean",function(e){return e?t._node.attributes.hidden=1:delete t._node.attributes.hidden,t}).handle(arguments)}},{key:"sheet",value:function(){return this._sheet}},{key:"style",value:function(){var n=this;return new i("Column.style").case("string",function(e){return n._createStyleIfNeeded(),n._style.style(e)}).case("array",function(e){var t={};return e.forEach(function(e){t[e]=n.style(e)}),t}).case(["string","*"],function(t,r){return n.sheet().forEachExistingRow(function(e){(e.hasStyle()||e.hasCell(n.columnNumber()))&&e.cell(n.columnNumber()).style(t,r)}),n._createStyleIfNeeded(),n._style.style(t,r),n}).case("object",function(e){for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];n.style(t,r)}return n}).case("Style",function(t){return n.sheet().forEachExistingRow(function(e){(e.hasStyle()||e.hasCell(n.columnNumber()))&&e.cell(n.columnNumber()).style(t)}),n._style=t,n._node.attributes.style=t.id(),n}).handle(arguments)}},{key:"width",value:function(e){var t=this;return new i("Column.width").case(function(){return t._node.attributes.customWidth?t._node.attributes.width:void 0}).case("number",function(e){return t._node.attributes.width=e,t._node.attributes.customWidth=1,t}).case("nil",function(){return delete t._node.attributes.width,delete t._node.attributes.customWidth,t}).handle(arguments)}},{key:"workbook",value:function(){return this.sheet().workbook()}},{key:"toXml",value:function(){return this._node}},{key:"_createStyleIfNeeded",value:function(){if(!this._style){var e=this._node.attributes.style;this._style=this.workbook().styleSheet().createStyle(e),this._node.attributes.style=this._style.id(),this.width()||this.width(9.140625)}}}]),r}();t.exports=o},{"./ArgHandler":2,"./addressConverter":20}],5:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=e("lodash"),a=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._node=e}return n(t,[{key:"add",value:function(e,t){var r={name:"Override",attributes:{PartName:e,ContentType:t}};return this._node.children.push(r),r}},{key:"findByPartName",value:function(t){return i.find(this._node.children,function(e){return e.attributes.PartName===t})}},{key:"toXml",value:function(){return this._node}}]),t}();t.exports=a},{lodash:191}],6:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i={title:"dc:title",subject:"dc:subject",author:"dc:creator",creator:"dc:creator",description:"dc:description",keywords:"cp:keywords",category:"cp:category"},a=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._node=e,this._properties={}}return n(t,[{key:"set",value:function(e,t){var r=e.toLowerCase();if(void 0===i[r])throw new Error('Unknown property name: "'+e+'"');return this._properties[r]=t,this}},{key:"get",value:function(e){var t=e.toLowerCase();if(void 0===i[t])throw new Error('Unknown property name: "'+e+'"');return this._properties[t]}},{key:"toXml",value:function(){for(var e in this._properties)this._properties.hasOwnProperty(e)&&this._node.children.push({name:i[e],children:[this._properties[e]]});return this._node}}]),t}();t.exports=a},{}],7:[function(f,u,e){(function(y){"use strict";var t=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var o=f("lodash"),g=f("cfb"),_=f("crypto"),s=f("./externals"),r=f("./XmlParser"),n=f("./XmlBuilder"),a=f("./xmlq"),i=y.from([4,0,4,0,64,0,0,0]),w={dataIntegrity:{hmacKey:y.from([95,178,173,1,12,185,225,246]),hmacValue:y.from([160,103,127,2,178,44,132,51])},key:y.from([20,110,11,231,171,172,208,214]),verifierHash:{input:y.from([254,167,210,118,59,75,158,121]),value:y.from([215,170,15,109,48,97,52,78])}},e=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return t(e,[{key:"encrypt",value:function(e,t){var r=_.randomBytes(32),n={package:{cipherAlgorithm:"AES",cipherChaining:"ChainingModeCBC",saltValue:_.randomBytes(16),hashAlgorithm:"SHA512",hashSize:64,blockSize:16,keyBits:8*r.length},key:{cipherAlgorithm:"AES",cipherChaining:"ChainingModeCBC",saltValue:_.randomBytes(16),hashAlgorithm:"SHA512",hashSize:64,blockSize:16,spinCount:1e5,keyBits:256}},i=this._cryptPackage(!0,n.package.cipherAlgorithm,n.package.cipherChaining,n.package.hashAlgorithm,n.package.blockSize,n.package.saltValue,r,e),a=_.randomBytes(64),o=this._createIV(n.package.hashAlgorithm,n.package.saltValue,n.package.blockSize,w.dataIntegrity.hmacKey),s=this._crypt(!0,n.package.cipherAlgorithm,n.package.cipherChaining,r,o,a),f=this._hmac(n.package.hashAlgorithm,a,i),u=this._createIV(n.package.hashAlgorithm,n.package.saltValue,n.package.blockSize,w.dataIntegrity.hmacValue),c=this._crypt(!0,n.package.cipherAlgorithm,n.package.cipherChaining,r,u,f);n.dataIntegrity={encryptedHmacKey:s,encryptedHmacValue:c};var h=this._convertPasswordToKey(t,n.key.hashAlgorithm,n.key.saltValue,n.key.spinCount,n.key.keyBits,w.key);n.key.encryptedKeyValue=this._crypt(!0,n.key.cipherAlgorithm,n.key.cipherChaining,h,n.key.saltValue,r);var l=_.randomBytes(16),d=this._convertPasswordToKey(t,n.key.hashAlgorithm,n.key.saltValue,n.key.spinCount,n.key.keyBits,w.verifierHash.input);n.key.encryptedVerifierHashInput=this._crypt(!0,n.key.cipherAlgorithm,n.key.cipherChaining,d,n.key.saltValue,l);var p=this._hash(n.key.hashAlgorithm,l),b=this._convertPasswordToKey(t,n.key.hashAlgorithm,n.key.saltValue,n.key.spinCount,n.key.keyBits,w.verifierHash.value);n.key.encryptedVerifierHashValue=this._crypt(!0,n.key.cipherAlgorithm,n.key.cipherChaining,b,n.key.saltValue,p);var m=this._buildEncryptionInfo(n),v=g.utils.cfb_new();return g.utils.cfb_add(v,"EncryptionInfo",m),g.utils.cfb_add(v,"EncryptedPackage",i),g.utils.cfb_del(v,"Sh33tJ5"),v=g.write(v),y.isBuffer(v)||(v=y.from(v)),v}},{key:"decryptAsync",value:function(e,n){var i=this,t=g.parse(e),r=o.find(t.FileIndex,{name:"EncryptionInfo"}).content,a=o.find(t.FileIndex,{name:"EncryptedPackage"}).content;return y.isBuffer(r)||(r=y.from(r)),y.isBuffer(a)||(a=y.from(a)),s.Promise.resolve().then(function(){return i._parseEncryptionInfoAsync(r)}).then(function(e){var t=i._convertPasswordToKey(n,e.key.hashAlgorithm,e.key.saltValue,e.key.spinCount,e.key.keyBits,w.key),r=i._crypt(!1,e.key.cipherAlgorithm,e.key.cipherChaining,t,e.key.saltValue,e.key.encryptedKeyValue);return i._cryptPackage(!1,e.package.cipherAlgorithm,e.package.cipherChaining,e.package.hashAlgorithm,e.package.blockSize,e.package.saltValue,r,a)})}},{key:"_buildEncryptionInfo",value:function(e){var t={name:"encryption",attributes:{xmlns:"http://schemas.microsoft.com/office/2006/encryption","xmlns:p":"http://schemas.microsoft.com/office/2006/keyEncryptor/password","xmlns:c":"http://schemas.microsoft.com/office/2006/keyEncryptor/certificate"},children:[{name:"keyData",attributes:{saltSize:e.package.saltValue.length,blockSize:e.package.blockSize,keyBits:e.package.keyBits,hashSize:e.package.hashSize,cipherAlgorithm:e.package.cipherAlgorithm,cipherChaining:e.package.cipherChaining,hashAlgorithm:e.package.hashAlgorithm,saltValue:e.package.saltValue.toString("base64")}},{name:"dataIntegrity",attributes:{encryptedHmacKey:e.dataIntegrity.encryptedHmacKey.toString("base64"),encryptedHmacValue:e.dataIntegrity.encryptedHmacValue.toString("base64")}},{name:"keyEncryptors",children:[{name:"keyEncryptor",attributes:{uri:"http://schemas.microsoft.com/office/2006/keyEncryptor/password"},children:[{name:"p:encryptedKey",attributes:{spinCount:e.key.spinCount,saltSize:e.key.saltValue.length,blockSize:e.key.blockSize,keyBits:e.key.keyBits,hashSize:e.key.hashSize,cipherAlgorithm:e.key.cipherAlgorithm,cipherChaining:e.key.cipherChaining,hashAlgorithm:e.key.hashAlgorithm,saltValue:e.key.saltValue.toString("base64"),encryptedVerifierHashInput:e.key.encryptedVerifierHashInput.toString("base64"),encryptedVerifierHashValue:e.key.encryptedVerifierHashValue.toString("base64"),encryptedKeyValue:e.key.encryptedKeyValue.toString("base64")}}]}]}]},r=(new n).build(t);return y.concat([i,y.from(r,"utf8")])}},{key:"_parseEncryptionInfoAsync",value:function(e){var t=e.slice(i.length).toString("utf8");return(new r).parseAsync(t).then(function(e){var t=a.findChild(e,"keyData"),r=a.findChild(e,"keyEncryptors"),n=a.findChild(r,"keyEncryptor"),i=a.findChild(n,"p:encryptedKey");return{package:{cipherAlgorithm:t.attributes.cipherAlgorithm,cipherChaining:t.attributes.cipherChaining,saltValue:y.from(t.attributes.saltValue,"base64"),hashAlgorithm:t.attributes.hashAlgorithm,blockSize:t.attributes.blockSize},key:{encryptedKeyValue:y.from(i.attributes.encryptedKeyValue,"base64"),cipherAlgorithm:i.attributes.cipherAlgorithm,cipherChaining:i.attributes.cipherChaining,saltValue:y.from(i.attributes.saltValue,"base64"),hashAlgorithm:i.attributes.hashAlgorithm,spinCount:i.attributes.spinCount,keyBits:i.attributes.keyBits}}})}},{key:"_hash",value:function(e){if(e=e.toLowerCase(),_.getHashes().indexOf(e)<0)throw new Error("Hash algorithm '"+e+"' not supported!");for(var t=_.createHash(e),r=arguments.length,n=Array(1<r?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return t.update(y.concat(n)),t.digest()}},{key:"_hmac",value:function(e,t){if(e=e.toLowerCase(),_.getHashes().indexOf(e)<0)throw new Error("HMAC algorithm '"+e+"' not supported!");for(var r=_.createHmac(e,t),n=arguments.length,i=Array(2<n?n-2:0),a=2;a<n;a++)i[a-2]=arguments[a];return r.update(y.concat(i)),r.digest()}},{key:"_crypt",value:function(e,t,r,n,i,a){var o=t.toLowerCase()+"-"+8*n.length;if("ChainingModeCBC"!==r)throw new Error("Unknown cipher chaining: "+r);o+="-cbc";var s=_[e?"createCipheriv":"createDecipheriv"](o,n,i);s.setAutoPadding(!1);var f=s.update(a);return f=y.concat([f,s.final()])}},{key:"_cryptPackage",value:function(e,t,r,n,i,a,o,s){for(var f=[],u=e?0:8,c=0,h=0,l=0;l<s.length;){(l=(h=l)+4096)>s.length&&(l=s.length);var d=s.slice(h+u,l+u),p=d.length%i;p&&(d=y.concat([d,y.alloc(i-p)]));var b=this._createIV(n,a,i,c),m=this._crypt(e,t,r,o,b,d);f.push(m),c++}var v=y.concat(f);if(e)v=y.concat([this._createUInt32LEBuffer(s.length,8),v]);else{var g=s.readUInt32LE(0);v=v.slice(0,g)}return v}},{key:"_createUInt32LEBuffer",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:4,r=new y(t);return r.writeUInt32LE(e,0),r}},{key:"_convertPasswordToKey",value:function(e,t,r,n,i,a){for(var o=y.from(e,"utf16le"),s=this._hash(t,r,o),f=0;f<n;f++){var u=this._createUInt32LEBuffer(f);s=this._hash(t,u,s)}var c=i/8;if((s=this._hash(t,s,a)).length<c){var h=y.alloc(c,54);s.copy(h),s=h}else s.length>c&&(s=s.slice(0,c));return s}},{key:"_createIV",value:function(e,t,r,n){"number"==typeof n&&(n=this._createUInt32LEBuffer(n));var i=this._hash(e,t,n);if(i.length<r){var a=y.alloc(r,54);i.copy(a),i=a}else i.length>r&&(i=i.slice(0,r));return i}}]),e}();u.exports=e}).call(this,f("buffer").Buffer)},{"./XmlBuilder":18,"./XmlParser":19,"./externals":24,"./xmlq":26,buffer:77,cfb:78,crypto:108,lodash:191}],8:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=e("lodash"),a=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._error=e}return n(t,[{key:"error",value:function(){return this._error}}]),t}();a.DIV0=new a("#DIV/0!"),a.NA=new a("#N/A"),a.NAME=new a("#NAME?"),a.NULL=new a("#NULL!"),a.NUM=new a("#NUM!"),a.REF=new a("#REF!"),a.VALUE=new a("#VALUE!"),a.getError=function(t){return i.find(a,function(e){return e instanceof a&&e.error()===t})||new a(t)},t.exports=a},{lodash:191}],9:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var o=e("./ArgHandler"),i=e("./addressConverter"),a=function(){function r(e,t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this._startCell=e,this._endCell=t,this._findRangeExtent(e,t)}return n(r,[{key:"address",value:function(e){return i.toAddress({type:"range",startRowNumber:this.startCell().rowNumber(),startRowAnchored:e&&(e.startRowAnchored||e.anchored),startColumnName:this.startCell().columnName(),startColumnAnchored:e&&(e.startColumnAnchored||e.anchored),endRowNumber:this.endCell().rowNumber(),endRowAnchored:e&&(e.endRowAnchored||e.anchored),endColumnName:this.endCell().columnName(),endColumnAnchored:e&&(e.endColumnAnchored||e.anchored),sheetName:e&&e.includeSheetName&&this.sheet().name()})}},{key:"cell",value:function(e,t){return this.sheet().cell(this._minRowNumber+e,this._minColumnNumber+t)}},{key:"autoFilter",value:function(){return this.sheet().autoFilter(this),this}},{key:"cells",value:function(){return this.map(function(e){return e})}},{key:"clear",value:function(){return this.value(void 0)}},{key:"endCell",value:function(){return this._endCell}},{key:"forEach",value:function(e){for(var t=0;t<this._numRows;t++)for(var r=0;r<this._numColumns;r++)e(this.cell(t,r),t,r,this);return this}},{key:"formula",value:function(){var a=this;return new o("Range.formula").case(function(){return a.startCell().getSharedRefFormula()}).case("string",function(n){var i=a.sheet().incrementMaxSharedFormulaId();return a.forEach(function(e,t,r){0===t&&0===r?e.setSharedFormula(i,n,a.address()):e.setSharedFormula(i)}),a}).handle(arguments)}},{key:"map",value:function(n){var i=this,a=[];return this.forEach(function(e,t,r){a[t]||(a[t]=[]),a[t][r]=n(e,t,r,i)}),a}},{key:"merged",value:function(e){var t=this;return new o("Range.merged").case(function(){return t.sheet().merged(t.address())}).case("*",function(e){return t.sheet().merged(t.address(),e),t}).handle(arguments)}},{key:"dataValidation",value:function(){var t=this;return new o("Range.dataValidation").case(function(){return t.sheet().dataValidation(t.address())}).case("boolean",function(e){return t.sheet().dataValidation(t.address(),e)}).case("*",function(e){return t.sheet().dataValidation(t.address(),e),t}).handle(arguments)}},{key:"reduce",value:function(n,e){var i=this,a=e;return this.forEach(function(e,t,r){a=n(a,e,t,r,i)}),a}},{key:"sheet",value:function(){return this.startCell().sheet()}},{key:"startCell",value:function(){return this._startCell}},{key:"style",value:function(){var a=this;return new o("Range.style").case("string",function(t){return a.map(function(e){return e.style(t)})}).case("array",function(e){var t={};return e.forEach(function(e){t[e]=a.style(e)}),t}).case(["string","function"],function(n,i){return a.forEach(function(e,t,r){e.style(n,i(e,t,r,a))})}).case(["string","array"],function(n,i){return a.forEach(function(e,t,r){i[t]&&void 0!==i[t][r]&&e.style(n,i[t][r])})}).case(["string","*"],function(t,r){return a.forEach(function(e){return e.style(t,r)})}).case("object",function(e){for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];a.style(t,r)}return a}).case("Style",function(t){return a._style=t,a.forEach(function(e){return e.style(t)})}).handle(arguments)}},{key:"tap",value:function(e){return e(this),this}},{key:"thru",value:function(e){return e(this)}},{key:"value",value:function(){var i=this;return new o("Range.value").case(function(){return i.map(function(e){return e.value()})}).case("function",function(n){return i.forEach(function(e,t,r){e.value(n(e,t,r,i))})}).case("array",function(n){return i.forEach(function(e,t,r){n[t]&&void 0!==n[t][r]&&e.value(n[t][r])})}).case("*",function(t){return i.forEach(function(e){return e.value(t)})}).handle(arguments)}},{key:"workbook",value:function(){return this.sheet().workbook()}},{key:"_findRangeExtent",value:function(){this._minRowNumber=Math.min(this._startCell.rowNumber(),this._endCell.rowNumber()),this._maxRowNumber=Math.max(this._startCell.rowNumber(),this._endCell.rowNumber()),this._minColumnNumber=Math.min(this._startCell.columnNumber(),this._endCell.columnNumber()),this._maxColumnNumber=Math.max(this._startCell.columnNumber(),this._endCell.columnNumber()),this._numRows=this._maxRowNumber-this._minRowNumber+1,this._numColumns=this._maxColumnNumber-this._minColumnNumber+1}}]),r}();t.exports=a},{"./ArgHandler":2,"./addressConverter":20}],10:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=e("lodash"),a="http://schemas.openxmlformats.org/officeDocument/2006/relationships/",o=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._init(e),this._getStartingId()}return n(t,[{key:"add",value:function(e,t,r){var n={name:"Relationship",attributes:{Id:"rId"+this._nextId++,Type:""+a+e,Target:t}};return r&&(n.attributes.TargetMode=r),this._node.children.push(n),n}},{key:"findById",value:function(t){return i.find(this._node.children,function(e){return e.attributes.Id===t})}},{key:"findByType",value:function(t){return i.find(this._node.children,function(e){return e.attributes.Type===""+a+t})}},{key:"toXml",value:function(){if(this._node.children.length)return this._node}},{key:"_getStartingId",value:function(){var r=this;this._nextId=1,this._node.children.forEach(function(e){var t=parseInt(e.attributes.Id.substr(3));t>=r._nextId&&(r._nextId=t+1)})}},{key:"_init",value:function(e){e||(e={name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},children:[]}),this._node=e}}]),t}();t.exports=o},{lodash:191}],11:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var o=e("lodash"),s=e("./Cell"),i=e("./regexify"),a=e("./ArgHandler"),f=e("./addressConverter"),u=function(){function r(e,t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this._sheet=e,this._init(t)}return n(r,[{key:"address",value:function(e){return f.toAddress({type:"row",rowNumber:this.rowNumber(),sheetName:e&&e.includeSheetName&&this.sheet().name(),rowAnchored:e&&e.anchored})}},{key:"cell",value:function(e){var t=e;if("string"==typeof e&&(t=f.columnNameToNumber(e)),this._cells[t])return this._cells[t];var r=void 0,n=this._node.attributes.s,i=this.sheet().existingColumnStyleId(t);o.isNil(n)?o.isNil(i)||(r=i):r=n;var a=new s(this,t,r);return this._cells[t]=a}},{key:"height",value:function(){var t=this;return new a("Row.height").case(function(){return t._node.attributes.customHeight?t._node.attributes.ht:void 0}).case("number",function(e){return t._node.attributes.ht=e,t._node.attributes.customHeight=1,t}).case("nil",function(){return delete t._node.attributes.ht,delete t._node.attributes.customHeight,t}).handle(arguments)}},{key:"hidden",value:function(){var t=this;return new a("Row.hidden").case(function(){return 1===t._node.attributes.hidden}).case("boolean",function(e){return e?t._node.attributes.hidden=1:delete t._node.attributes.hidden,t}).handle(arguments)}},{key:"rowNumber",value:function(){return this._node.attributes.r}},{key:"sheet",value:function(){return this._sheet}},{key:"style",value:function(){var n=this;return new a("Row.style").case("string",function(e){return n._createStyleIfNeeded(),n._style.style(e)}).case("array",function(e){var t={};return e.forEach(function(e){t[e]=n.style(e)}),t}).case(["string","*"],function(t,r){return n._createCellStylesIfNeeded(),o.forEach(n._cells,function(e){e&&e.style(t,r)}),n._createStyleIfNeeded(),n._style.style(t,r),n}).case("object",function(e){for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];n.style(t,r)}return n}).case("Style",function(t){return n._createCellStylesIfNeeded(),o.forEach(n._cells,function(e){e&&e.style(t)}),n._style=t,n._node.attributes.s=t.id(),n._node.attributes.customFormat=1,n}).handle(arguments)}},{key:"workbook",value:function(){return this.sheet().workbook()}},{key:"clearCellsUsingSharedFormula",value:function(t){this._cells.forEach(function(e){e&&e.sharesFormula(t)&&e.clear()})}},{key:"find",value:function(t,r){t=i(t);var n=[];return this._cells.forEach(function(e){e&&e.find(t,r)&&n.push(e)}),n}},{key:"hasCell",value:function(e){return!!this._cells[e]}},{key:"hasStyle",value:function(){return!o.isNil(this._node.attributes.s)}},{key:"minUsedColumnNumber",value:function(){return o.findIndex(this._cells)}},{key:"maxUsedColumnNumber",value:function(){return this._cells.length-1}},{key:"toXml",value:function(){return this._node}},{key:"_createCellStylesIfNeeded",value:function(){var t=this;this.sheet().forEachExistingColumnNumber(function(e){o.isNil(t.sheet().existingColumnStyleId(e))||t.cell(e)})}},{key:"_createStyleIfNeeded",value:function(){if(!this._style){var e=this._node.attributes.s;this._style=this.workbook().styleSheet().createStyle(e),this._node.attributes.s=this._style.id(),this._node.attributes.customFormat=1}}},{key:"_init",value:function(e){var r=this;this._node=e,this._cells=[],this._node.children.forEach(function(e){var t=new s(r,e);r._cells[t.columnNumber()]=t}),this._node.children=this._cells}}]),r}();t.exports=u},{"./ArgHandler":2,"./Cell":3,"./addressConverter":20,"./regexify":25,lodash:191}],12:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=e("lodash"),a=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._stringArray=[],this._indexMap={},this._init(e),this._cacheExistingSharedStrings()}return n(t,[{key:"getIndexForString",value:function(e){var t=i.isArray(e)?JSON.stringify(e):e,r=this._indexMap[t];return 0<=r||(r=this._stringArray.length,this._stringArray.push(e),this._indexMap[t]=r,this._node.children.push({name:"si",children:i.isArray(e)?e:[{name:"t",attributes:{"xml:space":"preserve"},children:[e]}]})),r}},{key:"getStringByIndex",value:function(e){return this._stringArray[e]}},{key:"toXml",value:function(){return this._node}},{key:"_cacheExistingSharedStrings",value:function(){var i=this;this._node.children.forEach(function(e,t){var r=e.children[0];if("t"===r.name){var n=r.children[0];i._stringArray.push(n),i._indexMap[n]=t}else i._stringArray.push(e.children),i._indexMap[JSON.stringify(e.children)]=t})}},{key:"_init",value:function(e){e||(e={name:"sst",attributes:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main"},children:[]}),this._node=e,delete this._node.attributes.count,delete this._node.attributes.uniqueCount}}]),t}();t.exports=a},{lodash:191}],13:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var u=e("lodash"),o=e("./Cell"),f=e("./Row"),c=e("./Column"),s=e("./Range"),h=e("./Relationships"),l=e("./xmlq"),d=e("./regexify"),p=e("./addressConverter"),b=e("./ArgHandler"),m=e("./colorIndexes"),v=["sheetPr","dimension","sheetViews","sheetFormatPr","cols","sheetData","sheetCalcPr","sheetProtection","autoFilter","protectedRanges","scenarios","autoFilter","sortState","dataConsolidate","customSheetViews","mergeCells","phoneticPr","conditionalFormatting","dataValidations","hyperlinks","printOptions","pageMargins","pageSetup","headerFooter","rowBreaks","colBreaks","customProperties","cellWatches","ignoredErrors","smartTags","drawing","drawingHF","picture","oleObjects","controls","webPublishItems","tableParts","extLst"],i=function(){function i(e,t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),this._init(e,t,r,n)}return a(i,[{key:"active",value:function(){var t=this;return new b("Sheet.active").case(function(){return t.workbook().activeSheet()===t}).case("boolean",function(e){if(!e)throw new Error("Deactivating sheet directly not supported. Activate a different sheet instead.");return t.workbook().activeSheet(t),t}).handle(arguments)}},{key:"activeCell",value:function(){var n=this,t=this._getOrCreateSheetViewNode(),r=l.findChild(t,"selection");return new b("Sheet.activeCell").case(function(){var e=r?r.attributes.activeCell:"A1";return n.cell(e)}).case(["number","*"],function(e,t){var r=n.cell(e,t);return n.activeCell(r)}).case("*",function(e){return r||(r={name:"selection",attributes:{},children:[]},l.appendChild(t,r)),e instanceof o||(e=n.cell(e)),r.attributes.activeCell=r.attributes.sqref=e.address(),n}).handle(arguments)}},{key:"cell",value:function(){var r=this;return new b("Sheet.cell").case("string",function(e){var t=p.fromAddress(e);if("cell"!==t.type)throw new Error("Sheet.cell: Invalid address.");return r.row(t.rowNumber).cell(t.columnNumber)}).case(["number","*"],function(e,t){return r.row(e).cell(t)}).handle(arguments)}},{key:"column",value:function(e){var t="string"==typeof e?p.columnNameToNumber(e):e;if(this._columns[t])return this._columns[t];var r=this._colNodes[t],n=void 0;if(r){if(r.attributes.min<t){var i=u.cloneDeep(r);i.attributes.max=t-1;for(var a=i.attributes.min;a<=i.attributes.max;a++)this._colNodes[a]=i}if((n=u.cloneDeep(r)).attributes.min=t,n.attributes.max=t,this._colNodes[t]=n,r.attributes.max>t){var o=u.cloneDeep(r);o.attributes.min=t+1;for(var s=o.attributes.min;s<=o.attributes.max;s++)this._colNodes[s]=o}}else n={name:"col",attributes:{min:t,max:t},children:[]},this._colNodes[t]=n;var f=new c(this,n);return this._columns[t]=f}},{key:"definedName",value:function(){var r=this;return new b("Workbook.definedName").case("string",function(e){return r.workbook().scopedDefinedName(r,e)}).case(["string","*"],function(e,t){return r.workbook().scopedDefinedName(r,e,t),r}).handle(arguments)}},{key:"delete",value:function(){return this.workbook().deleteSheet(this),this.workbook()}},{key:"find",value:function(t,r){t=d(t);var n=[];return this._rows.forEach(function(e){e&&(n=n.concat(e.find(t,r)))}),n}},{key:"gridLinesVisible",value:function(){var t=this,r=this._getOrCreateSheetViewNode();return new b("Sheet.gridLinesVisible").case(function(){return 1===r.attributes.showGridLines||void 0===r.attributes.showGridLines}).case("boolean",function(e){return r.attributes.showGridLines=e?1:0,t}).handle(arguments)}},{key:"hidden",value:function(){var r=this;return new b("Sheet.hidden").case(function(){return"hidden"===r._idNode.attributes.state||"veryHidden"===r._idNode.attributes.state&&"very"}).case("*",function(e){if(e){var t=u.filter(r.workbook().sheets(),function(e){return!e.hidden()});if(1===t.length&&t[0]===r)throw new Error("This sheet may not be hidden as a workbook must contain at least one visible sheet.");if(r.active())t[t[0]===r?1:0].active(!0)}return"very"===e?r._idNode.attributes.state="veryHidden":e?r._idNode.attributes.state="hidden":delete r._idNode.attributes.state,r}).handle(arguments)}},{key:"move",value:function(e){return this.workbook().moveSheet(this,e),this}},{key:"name",value:function(){var t=this;return new b("Sheet.name").case(function(){return t._idNode.attributes.name}).case("string",function(e){return t._idNode.attributes.name=e,t}).handle(arguments)}},{key:"range",value:function(){var i=this;return new b("Sheet.range").case("string",function(e){var t=p.fromAddress(e);if("range"!==t.type)throw new Error("Sheet.range: Invalid address");return i.range(t.startRowNumber,t.startColumnNumber,t.endRowNumber,t.endColumnNumber)}).case(["*","*"],function(e,t){return"string"==typeof e&&(e=i.cell(e)),"string"==typeof t&&(t=i.cell(t)),new s(e,t)}).case(["number","*","number","*"],function(e,t,r,n){return i.range(i.cell(e,t),i.cell(r,n))}).handle(arguments)}},{key:"autoFilter",value:function(e){return this._autoFilter=e,this}},{key:"row",value:function(e){if(this._rows[e])return this._rows[e];var t=new f(this,{name:"row",attributes:{r:e},children:[]});return this._rows[e]=t}},{key:"tabColor",value:function(){var r=this;return new b("Sheet.tabColor").case(function(){var e=l.findChild(r._sheetPrNode,"tabColor");if(e){var t={};return e.attributes.hasOwnProperty("rgb")?t.rgb=e.attributes.rgb:e.attributes.hasOwnProperty("theme")?t.theme=e.attributes.theme:e.attributes.hasOwnProperty("indexed")&&(t.rgb=m[e.attributes.indexed]),e.attributes.hasOwnProperty("tint")&&(t.tint=e.attributes.tint),t}}).case("string",function(e){return r.tabColor({rgb:e})}).case("integer",function(e){return r.tabColor({theme:e})}).case("nil",function(){return l.removeChild(r._sheetPrNode,"tabColor"),r}).case("object",function(e){var t=l.appendChildIfNotFound(r._sheetPrNode,"tabColor");return l.setAttributes(t,{rgb:e.rgb&&e.rgb.toUpperCase(),indexed:null,theme:e.theme,tint:e.tint}),r}).handle(arguments)}},{key:"tabSelected",value:function(){var t=this,r=this._getOrCreateSheetViewNode();return new b("Sheet.tabSelected").case(function(){return 1===r.attributes.tabSelected}).case("boolean",function(e){return e?r.attributes.tabSelected=1:delete r.attributes.tabSelected,t}).handle(arguments)}},{key:"usedRange",value:function(){for(var e=u.findIndex(this._rows),t=this._rows.length-1,r=0,n=0,i=0;i<this._rows.length;i++){var a=this._rows[i];if(a){var o=a.minUsedColumnNumber(),s=a.maxUsedColumnNumber();0<o&&(!r||o<r)&&(r=o),0<s&&(!n||n<s)&&(n=s)}}if(!(e<=0||r<=0||t<=0||n<=0))return this.range(e,r,t,n)}},{key:"workbook",value:function(){return this._workbook}},{key:"clearCellsUsingSharedFormula",value:function(t){this._rows.forEach(function(e){e&&e.clearCellsUsingSharedFormula(t)})}},{key:"existingColumnStyleId",value:function(e){var t=this._colNodes[e];return t&&t.attributes.style}},{key:"forEachExistingColumnNumber",value:function(r){u.forEach(this._colNodes,function(e,t){e&&r(t)})}},{key:"forEachExistingRow",value:function(r){return u.forEach(this._rows,function(e,t){e&&r(e,t)}),this}},{key:"hyperlink",value:function(){var n=this;return new b("Sheet.hyperlink").case("string",function(e){var t=n._hyperlinks[e];if(t){var r=n._relationships.findById(t.attributes["r:id"]);return r&&r.attributes.Target}}).case(["string","nil"],function(e){return delete n._hyperlinks[e],n}).case(["string","string"],function(e,t){var r=n._relationships.add("hyperlink",t,"External");return n._hyperlinks[e]={name:"hyperlink",attributes:{ref:e,"r:id":r.attributes.Id},children:[]},n}).handle(arguments)}},{key:"incrementMaxSharedFormulaId",value:function(){return++this._maxSharedFormulaId}},{key:"merged",value:function(){var r=this;return new b("Sheet.merge").case("string",function(e){return r._mergeCells.hasOwnProperty(e)}).case(["string","*"],function(e,t){return t?r._mergeCells[e]={name:"mergeCell",attributes:{ref:e},children:[]}:delete r._mergeCells[e],r}).handle(arguments)}},{key:"dataValidation",value:function(){var r=this;return new b("Sheet.dataValidation").case("string",function(e){return!!r._dataValidations[e]&&{type:r._dataValidations[e].attributes.type,allowBlank:r._dataValidations[e].attributes.allowBlank,showInputMessage:r._dataValidations[e].attributes.showInputMessage,prompt:r._dataValidations[e].attributes.prompt,promptTitle:r._dataValidations[e].attributes.promptTitle,showErrorMessage:r._dataValidations[e].attributes.showErrorMessage,error:r._dataValidations[e].attributes.error,errorTitle:r._dataValidations[e].attributes.errorTitle,operator:r._dataValidations[e].attributes.operator,formula1:r._dataValidations[e].children[0].children[0],formula2:r._dataValidations[e].children[1]?r._dataValidations[e].children[1].children[0]:void 0}}).case(["string","boolean"],function(e,t){return!!r._dataValidations[e]&&(!1===t?delete r._dataValidations[e]:void 0)}).case(["string","*"],function(e,t){return"string"==typeof t?r._dataValidations[e]={name:"dataValidation",attributes:{type:"list",allowBlank:!1,showInputMessage:!1,prompt:"",promptTitle:"",showErrorMessage:!1,error:"",errorTitle:"",operator:"",sqref:e},children:[{name:"formula1",atrributes:{},children:[t]},{name:"formula2",atrributes:{},children:[""]}]}:"object"===(void 0===t?"undefined":n(t))&&(r._dataValidations[e]={name:"dataValidation",attributes:{type:t.type?t.type:"list",allowBlank:t.allowBlank,showInputMessage:t.showInputMessage,prompt:t.prompt,promptTitle:t.promptTitle,showErrorMessage:t.showErrorMessage,error:t.error,errorTitle:t.errorTitle,operator:t.operator,sqref:e},children:[{name:"formula1",atrributes:{},children:[t.formula1]},{name:"formula2",atrributes:{},children:[t.formula2]}]}),r}).handle(arguments)}},{key:"toXmls",value:function(){var e=u.clone(this._node);return e.children=e.children.slice(),this._colsNode.children=u.filter(this._colNodes,function(e,t){return e&&t===e.attributes.min&&2<Object.keys(e.attributes).length}),this._colsNode.children.length&&l.insertInOrder(e,this._colsNode,v),this._hyperlinksNode.children=u.values(this._hyperlinks),this._hyperlinksNode.children.length&&l.insertInOrder(e,this._hyperlinksNode,v),this._mergeCellsNode.children=u.values(this._mergeCells),this._mergeCellsNode.children.length&&l.insertInOrder(e,this._mergeCellsNode,v),this._dataValidationsNode.children=u.values(this._dataValidations),this._dataValidationsNode.children.length&&l.insertInOrder(e,this._dataValidationsNode,v),this._autoFilter&&l.insertInOrder(e,{name:"autoFilter",children:[],attributes:{ref:this._autoFilter.address()}},v),{id:this._idNode,sheet:e,relationships:this._relationships}}},{key:"updateMaxSharedFormulaId",value:function(e){e>this._maxSharedFormulaId&&(this._maxSharedFormulaId=e)}},{key:"_getOrCreateSheetViewNode",value:function(){var e=l.findChild(this._node,"sheetViews");return e||(e={name:"sheetViews",attributes:{},children:[{name:"sheetView",attributes:{workbookViewId:0},children:[]}]},l.insertInOrder(this._node,e,v)),l.findChild(e,"sheetView")}},{key:"_init",value:function(e,t,r,n){var i=this;r||(r={name:"worksheet",attributes:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"},children:[{name:"sheetData",attributes:{},children:[]}]}),this._workbook=e,this._idNode=t,this._node=r,this._maxSharedFormulaId=-1,this._mergeCells={},this._dataValidations={},this._hyperlinks={},this._autoFilter=null,this._relationships=new h(n),l.removeChild(this._node,"dimension"),this._rows=[],this._sheetDataNode=l.findChild(this._node,"sheetData"),this._sheetDataNode.children.forEach(function(e){var t=new f(i,e);i._rows[t.rowNumber()]=t}),this._sheetDataNode.children=this._rows,this._columns=[],this._colsNode=l.findChild(this._node,"cols"),this._colsNode?l.removeChild(this._node,this._colsNode):this._colsNode={name:"cols",attributes:{},children:[]},this._colNodes=[],u.forEach(this._colsNode.children,function(e){for(var t=e.attributes.min,r=e.attributes.max,n=t;n<=r;n++)i._colNodes[n]=e}),this._sheetPrNode=l.findChild(this._node,"sheetPr"),this._sheetPrNode||(this._sheetPrNode={name:"sheetPr",attributes:{},children:[]},l.insertInOrder(this._node,this._sheetPrNode,v)),this._mergeCellsNode=l.findChild(this._node,"mergeCells"),this._mergeCellsNode?l.removeChild(this._node,this._mergeCellsNode):this._mergeCellsNode={name:"mergeCells",attributes:{},children:[]};var a=this._mergeCellsNode.children;this._mergeCellsNode.children=[],a.forEach(function(e){i._mergeCells[e.attributes.ref]=e}),this._dataValidationsNode=l.findChild(this._node,"dataValidations"),this._dataValidationsNode?l.removeChild(this._node,this._dataValidationsNode):this._dataValidationsNode={name:"dataValidations",attributes:{},children:[]};var o=this._dataValidationsNode.children;this._dataValidationsNode.children=[],o.forEach(function(e){i._dataValidations[e.attributes.sqref]=e}),this._hyperlinksNode=l.findChild(this._node,"hyperlinks"),this._hyperlinksNode?l.removeChild(this._node,this._hyperlinksNode):this._hyperlinksNode={name:"hyperlinks",attributes:{},children:[]};var s=this._hyperlinksNode.children;this._hyperlinksNode.children=[],s.forEach(function(e){i._hyperlinks[e.attributes.ref]=e})}}]),i}();t.exports=i},{"./ArgHandler":2,"./Cell":3,"./Column":4,"./Range":9,"./Relationships":10,"./Row":11,"./addressConverter":20,"./colorIndexes":22,"./regexify":25,"./xmlq":26,lodash:191}],14:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var a=e("./ArgHandler"),c=e("lodash"),h=e("./xmlq"),s=e("./colorIndexes"),o=function(){function o(e,t,r,n,i,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),this._styleSheet=e,this._id=t,this._xfNode=r,this._fontNode=n,this._fillNode=i,this._borderNode=a}return n(o,[{key:"id",value:function(){return this._id}},