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 • 642 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(t,e){if(!s[t]){if(!o[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(c)return c(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=s[t]={exports:{}};o[t][0].call(i.exports,function(e){return u(o[t][1][e]||e)},i,i.exports,a,o,s,f)}return s[t].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";function i(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)}}e("lodash");var a=e("./xmlq"),o=e("./ArgHandler"),n=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}var e,r,n;return e=t,(r=[{key:"isSecure",value:function(e){var t=this;return new o("Range.formula").case(function(){var e=a.findChild(t._node,"DocSecurity");return!!e&&1===e.children[0]}).case("boolean",function(e){return a.appendChildIfNotFound(t._node,"DocSecurity").children=[e?1:0],t}).handle(arguments)}},{key:"toXml",value:function(){return this._node}}])&&i(e.prototype,r),n&&i(e,n),t}();t.exports=n},{"./ArgHandler":2,"./xmlq":29,lodash:170}],2:[function(e,t,r){"use strict";function i(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)}}var a=e("lodash"),n=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=[]}var e,r,n;return e=t,(r=[{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("".concat(this._name,": Invalid arguments."))}},{key:"_argsMatchTypes",value:function(e,n){return e.length===n.length&&a.every(e,function(e,t){var r=n[t];if("*"===r)return!0;if("nil"===r)return a.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&&a.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: ".concat(r))})}}])&&i(e.prototype,r),n&&i(e,n),t}();t.exports=n},{lodash:170}],3:[function(e,t,r){"use strict";function a(e){return(a="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})(e)}function i(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)}}var h=e("lodash"),o=e("./ArgHandler"),l=e("./addressConverter"),s=e("./dateConverter"),f=e("./regexify"),d=e("./xmlq"),p=e("./FormulaError"),u=e("./Style"),b=e("./RichText"),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)}var e,t,r;return e=n,(t=[{key:"active",value:function(){var t=this;return new o("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 l.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,h.isNil(e)||this.sheet().clearCellsUsingSharedFormula(e),this}},{key:"columnName",value:function(){return l.columnNumberToName(this.columnNumber())}},{key:"columnNumber",value:function(){return this._columnNumber}},{key:"find",value:function(e,t){e=f(e);var r=this.value();if("string"!=typeof r)return!1;if(h.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 o("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 o("Cell.hyperlink").case(function(){return t.sheet().hyperlink(t.address())}).case("string",function(e){return t.sheet().hyperlink(t.address(),e),t}).case(["object"],function(e){return t.sheet().hyperlink(t.address(),e),t}).handle(arguments)}},{key:"dataValidation",value:function(){var t=this;return new o("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(e){var i=this;return this._style||e instanceof u||(this._style=this.workbook().styleSheet().createStyle(this._styleId)),new o("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 o("Cell.value").case(function(){return n._value instanceof b?n._value.getInstanceWithCellRef(n):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 instanceof b?e.copy(n):e,n}).handle(arguments)}},{key:"workbook",value:function(){return this.row().workbook()}},{key:"addHorizontalPageBreak",value:function(){return this.row().addPageBreak(),this}},{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(),h.isNil(this._formulaType)){if(!h.isNil(this._value)){var t,r;"string"==typeof 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=s.dateToNumber(this._value):(this._value instanceof b||"object"===a(this._value)&&"RichText"===this._value.constructor.name)&&(t="s",r=this.workbook().sharedStrings().getIndexForString(this._value.toXml())),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),h.isNil(this._formulaRef)||(i.attributes.ref=this._formulaRef),h.isNil(this._sharedFormulaId)||(i.attributes.si=this._sharedFormulaId),h.isNil(this._formula)||(i.children=[this._formula]),e.children.push(i)}return h.isNil(this._style)?h.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){h.isObject(e)?this._parseNode(e):(this._columnNumber=e,h.isNil(t)||(this._styleId=t))}},{key:"_parseNode",value:function(e){var t=l.fromAddress(e.attributes.r);this._columnNumber=t.columnNumber,h.isNil(e.attributes.s)||(this._styleId=e.attributes.s);var r=d.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,h.isNil(this._sharedFormulaId)||this.sheet().updateMaxSharedFormulaId(this._sharedFormulaId),delete r.attributes.t,delete r.attributes.ref,delete r.attributes.si,h.isEmpty(r.attributes)||(this._remainingFormulaAttributes=r.attributes));var n=e.attributes.t;if("s"===n){var i=d.findChild(e,"v");if(i){var a=i.children[0];this._value=this.workbook().sharedStrings().getStringByIndex(a),h.isArray(this._value)&&(this._value=new b(this._value))}else this._value=""}else if("str"===n){var o=d.findChild(e,"v");this._value=o&&o.children[0]}else if("inlineStr"===n){var s=d.findChild(e,"is");if("t"===s.children[0].name){var f=s.children[0];this._value=f.children[0]}else this._value=s.children}else if("b"===n)this._value=1===d.findChild(e,"v").children[0];else if("e"===n){var u=d.findChild(e,"v").children[0];this._value=p.getError(u)}else{var c=d.findChild(e,"v");this._value=c&&Number(c.children[0])}delete e.attributes.r,delete e.attributes.s,delete e.attributes.t,h.isEmpty(e.attributes)||(this._remainingAttributes=e.attributes),d.removeChild(e,"f"),d.removeChild(e,"v"),d.removeChild(e,"is"),h.isEmpty(e.children)||(this._remainingChildren=e.children)}}])&&i(e.prototype,t),r&&i(e,r),n}();t.exports=n},{"./ArgHandler":2,"./FormulaError":8,"./RichText":12,"./Style":17,"./addressConverter":23,"./dateConverter":26,"./regexify":28,"./xmlq":29,lodash:170}],4:[function(e,t,r){"use strict";function i(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)}}var a=e("./ArgHandler"),o=e("./addressConverter"),n=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}var e,t,n;return e=r,(t=[{key:"address",value:function(e){return o.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 o.columnNumberToName(this.columnNumber())}},{key:"columnNumber",value:function(){return this._node.attributes.min}},{key:"hidden",value:function(){var t=this;return new a("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 a("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 a("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:"addPageBreak",value:function(){return this.sheet().verticalPageBreaks().add(this.columnNumber()),this}},{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)}}}])&&i(e.prototype,t),n&&i(e,n),r}();t.exports=n},{"./ArgHandler":2,"./addressConverter":23}],5:[function(e,t,r){"use strict";function i(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)}}var a=e("lodash"),n=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}var e,r,n;return e=t,(r=[{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 a.find(this._node.children,function(e){return e.attributes.PartName===t})}},{key:"toXml",value:function(){return this._node}}])&&i(e.prototype,r),n&&i(e,n),t}();t.exports=n},{lodash:170}],6:[function(e,t,r){"use strict";function i(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)}}var a={title:"dc:title",subject:"dc:subject",author:"dc:creator",creator:"dc:creator",description:"dc:description",keywords:"cp:keywords",category:"cp:category"},n=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={}}var e,r,n;return e=t,(r=[{key:"set",value:function(e,t){var r=e.toLowerCase();if(void 0===a[r])throw new Error('Unknown property name: "'.concat(e,'"'));return this._properties[r]=t,this}},{key:"get",value:function(e){var t=e.toLowerCase();if(void 0===a[t])throw new Error('Unknown property name: "'.concat(e,'"'));return this._properties[t]}},{key:"toXml",value:function(){for(var e in this._properties)this._properties.hasOwnProperty(e)&&this._node.children.push({name:a[e],children:[this._properties[e]]});return this._node}}])&&i(e.prototype,r),n&&i(e,n),t}();t.exports=n},{}],7:[function(t,r,e){(function(g){"use strict";function i(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)}}var o=t("lodash"),y=t("cfb"),_=t("crypto"),s=t("./externals"),a=t("./XmlParser"),f=t("./XmlBuilder"),u=t("./xmlq"),c=g.from([4,0,4,0,64,0,0,0]),w={dataIntegrity:{hmacKey:g.from([95,178,173,1,12,185,225,246]),hmacValue:g.from([160,103,127,2,178,44,132,51])},key:g.from([20,110,11,231,171,172,208,214]),verifierHash:{input:g.from([254,167,210,118,59,75,158,121]),value:g.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)}var t,r,n;return t=e,(r=[{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=y.utils.cfb_new();return y.utils.cfb_add(v,"EncryptionInfo",m),y.utils.cfb_add(v,"EncryptedPackage",i),y.utils.cfb_del(v,"Sh33tJ5"),v=y.write(v),g.isBuffer(v)||(v=g.from(v)),v}},{key:"decryptAsync",value:function(e,n){var i=this,t=y.parse(e),r=o.find(t.FileIndex,{name:"EncryptionInfo"}).content,a=o.find(t.FileIndex,{name:"EncryptedPackage"}).content;return g.isBuffer(r)||(r=g.from(r)),g.isBuffer(a)||(a=g.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 f).build(t);return g.concat([c,g.from(r,"utf8")])}},{key:"_parseEncryptionInfoAsync",value:function(e){var t=e.slice(c.length).toString("utf8");return(new a).parseAsync(t).then(function(e){var t=u.findChild(e,"keyData"),r=u.findChild(e,"keyEncryptors"),n=u.findChild(r,"keyEncryptor"),i=u.findChild(n,"p:encryptedKey");return{package:{cipherAlgorithm:t.attributes.cipherAlgorithm,cipherChaining:t.attributes.cipherChaining,saltValue:g.from(t.attributes.saltValue,"base64"),hashAlgorithm:t.attributes.hashAlgorithm,blockSize:t.attributes.blockSize},key:{encryptedKeyValue:g.from(i.attributes.encryptedKeyValue,"base64"),cipherAlgorithm:i.attributes.cipherAlgorithm,cipherChaining:i.attributes.cipherChaining,saltValue:g.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 '".concat(e,"' not supported!"));for(var t=_.createHash(e),r=arguments.length,n=new Array(1<r?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return t.update(g.concat(n)),t.digest()}},{key:"_hmac",value:function(e,t){if(e=e.toLowerCase(),_.getHashes().indexOf(e)<0)throw new Error("HMAC algorithm '".concat(e,"' not supported!"));for(var r=_.createHmac(e,t),n=arguments.length,i=new Array(2<n?n-2:0),a=2;a<n;a++)i[a-2]=arguments[a];return r.update(g.concat(i)),r.digest()}},{key:"_crypt",value:function(e,t,r,n,i,a){var o="".concat(t.toLowerCase(),"-").concat(8*n.length);if("ChainingModeCBC"!==r)throw new Error("Unknown cipher chaining: ".concat(r));o+="-cbc";var s=_[e?"createCipheriv":"createDecipheriv"](o,n,i);s.setAutoPadding(!1);var f=s.update(a);return f=g.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=g.concat([d,g.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=g.concat(f);if(e)v=g.concat([this._createUInt32LEBuffer(s.length,8),v]);else{var y=s.readUInt32LE(0);v=v.slice(0,y)}return v}},{key:"_createUInt32LEBuffer",value:function(e,t){var r=1<arguments.length&&void 0!==t?t:4,n=g.alloc(r);return n.writeUInt32LE(e,0),n}},{key:"_convertPasswordToKey",value:function(e,t,r,n,i,a){for(var o=g.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=g.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=g.alloc(r,54);i.copy(a),i=a}else i.length>r&&(i=i.slice(0,r));return i}}])&&i(t.prototype,r),n&&i(t,n),e}();r.exports=e}).call(this,t("buffer").Buffer)},{"./XmlBuilder":21,"./XmlParser":22,"./externals":27,"./xmlq":29,buffer:77,cfb:78,crypto:86,lodash:170}],8:[function(e,t,r){"use strict";function i(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)}}var n=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}var e,r,n;return e=t,(r=[{key:"error",value:function(){return this._error}}])&&i(e.prototype,r),n&&i(e,n),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 n.find(a,function(e){return e instanceof a&&e.error()===t})||new a(t)},t.exports=a},{lodash:170}],9:[function(e,t,r){"use strict";function i(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)}}var n=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}var e,r,n;return e=t,(r=[{key:"add",value:function(e){return this._node.children.push({name:"brk",children:[],attributes:{id:e,max:16383,man:1}}),this._node.attributes.count++,this._node.attributes.manualBreakCount++,this}},{key:"remove",value:function(e){var t=this._node.children[e];return t&&(this._node.children.splice(e,1),this._node.attributes.count--,t.man&&this._node.attributes.manualBreakCount--),this}},{key:"count",get:function(){return this._node.attributes.count}},{key:"list",get:function(){return this._node.children.map(function(e){return{id:e.id,isManual:!!e.man}})}}])&&i(e.prototype,r),n&&i(e,n),t}();t.exports=n},{}],10:[function(e,t,r){"use strict";function i(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)}}var o=e("./ArgHandler"),a=e("./addressConverter"),n=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)}var e,t,n;return e=r,(t=[{key:"address",value:function(e){return a.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}}])&&i(e.prototype,t),n&&i(e,n),r}();t.exports=n},{"./ArgHandler":2,"./addressConverter":23}],11:[function(e,t,r){"use strict";function i(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)}}var a=e("lodash"),o="http://schemas.openxmlformats.org/officeDocument/2006/relationships/",n=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()}var e,r,n;return e=t,(r=[{key:"add",value:function(e,t,r){var n={name:"Relationship",attributes:{Id:"rId".concat(this._nextId++),Type:"".concat(o).concat(e),Target:t}};return r&&(n.attributes.TargetMode=r),this._node.children.push(n),n}},{key:"findById",value:function(t){return a.find(this._node.children,function(e){return e.attributes.Id===t})}},{key:"findByType",value:function(t){return a.find(this._node.children,function(e){return e.attributes.Type==="".concat(o).concat(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}}])&&i(e.prototype,r),n&&i(e,n),t}();t.exports=n},{lodash:170}],12:[function(e,t,r){"use strict";function i(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)}}var a=e("lodash"),o=e("./RichTextFragment"),n=function(){function n(e){if(!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this._node=[],this._cell=null,this._remainingNodes=[],e)for(var t=0;t<e.length;t++){var r=e[t];"r"===r.name?this._node.push(new o(r,null,this)):this._remainingNodes.push(r)}}var e,t,r;return e=n,(t=[{key:"text",value:function(){for(var e="",t=0;t<this._node.length;t++)e+=this.get(t).value();return e}},{key:"getInstanceWithCellRef",value:function(e){return this._cell=e,this}},{key:"copy",value:function(e){var t=new n(a.cloneDeep(this.toXml()));return e&&a.includes(this.text(),"\n")&&e.style("wrapText",!0),t}},{key:"get",value:function(e){return this._node[e]}},{key:"remove",value:function(e){return this._node.splice(e,1),this.removeUnsupportedNodes(),this}},{key:"add",value:function(e,t,r){return null==r?this._node.push(new o(e,t,this)):this._node.splice(r,0,new o(e,t,this)),this.removeUnsupportedNodes(),this}},{key:"clear",value:function(){return this._node=[],this._remainingNodes=[],this._cell=void 0,this}},{key:"removeUnsupportedNodes",value:function(){this._remainingNodes=[]}},{key:"toXml",value:function(){for(var e=[],t=0;t<this._node.length;t++)e.push(this._node[t].toXml());return e.concat(this._remainingNodes)}},{key:"cell",get:function(){return this._cell}},{key:"length",get:function(){return this._node.length}}])&&i(e.prototype,t),r&&i(e,r),n}();n.name||(n.name="RichText"),t.exports=n},{"./RichTextFragment":13,lodash:170}],13:[function(e,t,r){"use strict";function i(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)}}var a=e("./ArgHandler"),o=e("lodash"),s=e("./xmlq"),f=e("./colorIndexes"),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._richText=r,"r"===e.name?(this._node=e,this._fontNode=s.findChild(this._node,"rPr"),this._fontNode||(this._fontNode={name:"rPr",attributes:{},children:[]},this._node.children.unshift(this._fontNode)),this._valueNode=s.findChild(this._node,"t")):(this._node={name:"r",attributes:{},children:[{name:"rPr",attributes:{},children:[]},{name:"t",attributes:{},children:[]}]},this._fontNode=s.findChild(this._node,"rPr"),this._valueNode=s.findChild(this._node,"t"),this.value(e),t&&this.style(t))}var e,t,r;return e=n,(t=[{key:"value",value:function(){var r=this;return new a("_RichText.value").case(function(){return r._valueNode.children[0]}).case("string",function(e){var t=-1!==(e=e.replace(/(?:\r\n|\r|\n)/g,"\r\n")).indexOf("\r\n");return" "===(r._valueNode.children[0]=e).charAt(0)&&s.setAttributes(r._valueNode,{"xml:space":"preserve"}),r._richText&&r._richText.removeUnsupportedNodes(),t&&(r._richText.cell&&r._richText.cell.style("wrapText",!0),s.setAttributes(r._valueNode,{"xml:space":"preserve"})),r}).handle(arguments)}},{key:"toXml",value:function(){return this._node}},{key:"style",value:function(){var n=this;return new a("_RichText.style").case("string",function(e){var t="_get_".concat(e);if(!n[t])throw new Error("_RichText.style: '".concat(e,"' is not a valid style"));return n[t]()}).case("array",function(e){var t={};return e.forEach(function(e){t[e]=n.style(e)}),t}).case(["string","*"],function(e,t){var r="_set_".concat(e);if(!n[r])throw new Error("_RichText.style: '".concat(e,"' is not a valid style"));return n[r](t)}).case("object",function(e){for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];n.style(t,r)}return n}).handle(arguments)}},{key:"_getColor",value:function(e,t){var r=s.findChild(e,t);if(r&&r.attributes){var n={};if(r.attributes.hasOwnProperty("rgb")?n.rgb=r.attributes.rgb:r.attributes.hasOwnProperty("theme")?n.theme=r.attributes.theme:r.attributes.hasOwnProperty("indexed")&&(n.rgb=f[r.attributes.indexed]),r.attributes.hasOwnProperty("tint")&&(n.tint=r.attributes.tint),!o.isEmpty(n))return n}}},{key:"_setColor",value:function(e,t,r){"string"==typeof r?r={rgb:r}:"number"==typeof r&&(r={theme:r}),s.setChildAttributes(e,t,{rgb:r&&r.rgb&&r.rgb.toUpperCase(),indexed:null,theme:r&&r.theme,tint:r&&r.tint}),s.removeChildIfEmpty(e,"color")}},{key:"_get_bold",value:function(){return s.hasChild(this._fontNode,"b")}},{key:"_set_bold",value:function(e){e?s.appendChildIfNotFound(this._fontNode,"b"):s.removeChild(this._fontNode,"b")}},{key:"_get_italic",value:function(){return s.hasChild(this._fontNode,"i")}},{key:"_set_italic",value:function(e){e?s.appendChildIfNotFound(this._fontNode,"i"):s.removeChild(this._fontNode,"i")}},{key:"_get_underline",value:function(){var e=s.findChild(this._fontNode,"u");return!!e&&(e.attributes.val||!0)}},{key:"_set_underline",value:function(e){if(e){var t=s.appendChildIfNotFound(this._fontNode,"u"),r="string"==typeof e?e:null;s.setAttributes(t,{val:r})}else s.removeChild(this._fontNode,"u")}},{key:"_get_strikethrough",value:function(){return s.hasChild(this._fontNode,"strike")}},{key:"_set_strikethrough",value:function(e){e?s.appendChildIfNotFound(this._fontNode,"strike"):s.removeChild(this._fontNode,"strike")}},{key:"_getFontVerticalAlignment",value:function(){return s.getChildAttribute(this._fontNode,"vertAlign","val")}},{key:"_setFontVerticalAlignment",value:function(e){s.setChildAttributes(this._fontNode,"vertAlign",{val:e}),s.removeChildIfEmpty(this._fontNode,"vertAlign")}},{key:"_get_subscript",value:function(){return"subscript"===this._getFontVerticalAlignment()}},{key:"_set_subscript",value:function(e){this._setFontVerticalAlignment(e?"subscript":null)}},{key:"_get_superscript",value:function(){return"superscript"===this._getFontVerticalAlignment()}},{key:"_set_superscript",value:function(e){this._setFontVerticalAlignment(e?"superscript":null)}},{key:"_get_fontSize",value:function(){return s.getChildAttribute(this._fontNode,"sz","val")}},{key:"_set_fontSize",value:function(e){s.setChildAttributes(this._fontNode,"sz",{val:e}),s.removeChildIfEmpty(this._fontNode,"sz")}},{key:"_get_fontFamily",value:function(){return s.getChildAttribute(this._fontNode,"rFont","val")}},{key:"_set_fontFamily",value:function(e){s.setChildAttributes(this._fontNode,"rFont",{val:e}),s.removeChildIfEmpty(this._fontNode,"rFont")}},{key:"_get_fontGenericFamily",value:function(){return s.getChildAttribute(this._fontNode,"family","val")}},{key:"_set_fontGenericFamily",value:function(e){s.setChildAttributes(this._fontNode,"family",{val:e}),s.removeChildIfEmpty(this._fontNode,"family")}},{key:"_get_fontColor",value:function(){return this._getColor(this._fontNode,"color")}},{key:"_set_fontColor",value:function(e){this._setColor(this._fontNode,"color",e)}},{key:"_get_fontScheme",value:function(){return s.getChildAttribute(this._fontNode,"scheme","val")}},{key:"_set_fontScheme",value:function(e){s.setChildAttributes(this._fontNode,"scheme",{val:e}),s.removeChildIfEmpty(this._fontNode,"scheme")}}])&&i(e.prototype,t),r&&i(e,r),n}();n.name||(n.name="RichTextFragment"),t.exports=n},{"./ArgHandler":2,"./colorIndexes":25,"./xmlq":29,lodash:170}],14:[function(e,t,r){"use strict";function i(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)}}var o=e("lodash"),s=e("./Cell"),a=e("./regexify"),f=e("./ArgHandler"),u=e("./addressConverter"),n=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)}var e,t,n;return e=r,(t=[{key:"address",value:function(e){return u.toAddress({type:"row",rowNumber:this.rowNumber(),sheetName:e&&e.includeSheetName&&this.sheet().name(),rowAnchored:e&&e.anchored})}},{key:"cell",value:function(e){var t,r=e;if("string"==typeof e&&(r=u.columnNameToNumber(e)),r<1)throw new RangeError("Invalid column number ".concat(r,". Remember that spreadsheets use 1-based indexing."));if(this._cells[r])return this._cells[r];var n=this._node.attributes.s,i=this.sheet().existingColumnStyleId(r);o.isNil(n)?o.isNil(i)||(t=i):t=n;var a=new s(this,r,t);return this._cells[r]=a}},{key:"height",value:function(){var t=this;return new f("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 f("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 f("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:"addPageBreak",value:function(){return this.sheet().horizontalPageBreaks().add(this.rowNumber()),this}},{key:"clearCellsUsingSharedFormula",value:function(t){this._cells.forEach(function(e){e&&e.sharesFormula(t)&&e.clear()})}},{key:"find",value:function(t,r){t=a(t);var n=[];return this._cells.forEach(function(e){e&&e.find(t,r)&&n.push(e)}),n}},{key:"hasCell",value:function(e){if(e<1)throw new RangeError("Invalid column number ".concat(e,". Remember that spreadsheets use 1-based indexing."));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}}])&&i(e.prototype,t),n&&i(e,n),r}();t.exports=n},{"./ArgHandler":2,"./Cell":3,"./addressConverter":23,"./regexify":28,lodash:170}],15:[function(e,t,r){"use strict";function i(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)}}var a=e("lodash"),n=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()}var e,r,n;return e=t,(r=[{key:"getIndexForString",value:function(e){var t=a.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:a.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}}])&&i(e.prototype,r),n&&i(e,n),t}();t.exports=n},{lodash:170}],16:[function(e,t,r){"use strict";function n(e){return(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})(e)}function a(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)}}var u=e("lodash"),s=e("./Cell"),c=e("./Row"),h=e("./Column"),o=e("./Range"),l=e("./Relationships"),d=e("./xmlq"),f=e("./regexify"),p=e("./addressConverter"),b=e("./ArgHandler"),m=e("./colorIndexes"),v=e("./PageBreaks"),y=["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","legacyDrawing","legacyDrawingHF","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)}var e,t,r;return e=i,(t=[{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=d.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:[]},d.appendChild(t,r)),e instanceof s||(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,n=this._colNodes[t];if(n){if(n.attributes.min<t){var i=u.cloneDeep(n);i.attributes.max=t-1;for(var a=i.attributes.min;a<=i.attributes.max;a++)this._colNodes[a]=i}if((r=u.cloneDeep(n)).attributes.min=t,r.attributes.max=t,this._colNodes[t]=r,n.attributes.max>t){var o=u.cloneDeep(n);o.attributes.min=t+1;for(var s=o.attributes.min;s<=o.attributes.max;s++)this._colNodes[s]=o}}else r={name:"col",attributes:{min:t,max:t},children:[]},this._colNodes[t]=r;var f=new h(this,r);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=f(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"".concat(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 o(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(e<1)throw new RangeError("Invalid row number ".concat(e,". Remember that spreadsheets use 1-based indexing."));if(this._rows[e])return this._rows[e];var t=new c(this,{name:"row",attributes:{r:e},children:[]});return this._rows[e]=t}},{key:"tabColor",val