UNPKG

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 355 kB
!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(){return function o(a,s,u){function l(t,e){if(!s[t]){if(!a[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:{}};a[t][0].call(i.exports,function(e){return l(a[t][1][e]||e)},i,i.exports,o,a,s,u)}return s[t].exports}for(var c="function"==typeof require&&require,e=0;e<u.length;e++)l(u[e]);return l}({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 o=e("./xmlq"),a=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 a("Range.formula").case(function(){var e=o.findChild(t._node,"DocSecurity");return!!e&&1===e.children[0]}).case("boolean",function(e){return o.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":28,lodash:76}],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 o=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&&o.every(e,function(e,t){var r=n[t];if("*"===r)return!0;if("nil"===r)return o.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&&o.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:76}],3:[function(e,t,r){"use strict";function o(e){return(o="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 f=e("lodash"),a=e("./ArgHandler"),h=e("./addressConverter"),s=e("./dateConverter"),u=e("./regexify"),d=e("./xmlq"),p=e("./FormulaError"),l=e("./Style"),m=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 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,f.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=u(e);var r=this.value();if("string"!=typeof r)return!1;if(f.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("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 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(e){var i=this;return this._style||e instanceof l||(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 instanceof m?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 m?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(),f.isNil(this._formulaType)){if(!f.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 m||"object"===o(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),f.isNil(this._formulaRef)||(i.attributes.ref=this._formulaRef),f.isNil(this._sharedFormulaId)||(i.attributes.si=this._sharedFormulaId),f.isNil(this._formula)||(i.children=[this._formula]),e.children.push(i)}return f.isNil(this._style)?f.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){f.isObject(e)?this._parseNode(e):(this._columnNumber=e,f.isNil(t)||(this._styleId=t))}},{key:"_parseNode",value:function(e){var t=h.fromAddress(e.attributes.r);this._columnNumber=t.columnNumber,f.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,f.isNil(this._sharedFormulaId)||this.sheet().updateMaxSharedFormulaId(this._sharedFormulaId),delete r.attributes.t,delete r.attributes.ref,delete r.attributes.si,f.isEmpty(r.attributes)||(this._remainingFormulaAttributes=r.attributes));var n=e.attributes.t;if("s"===n){var i=d.findChild(e,"v");if(i){var o=i.children[0];this._value=this.workbook().sharedStrings().getStringByIndex(o),f.isArray(this._value)&&(this._value=new m(this._value))}else this._value=""}else if("str"===n){var a=d.findChild(e,"v");this._value=a&&a.children[0]}else if("inlineStr"===n){var s=d.findChild(e,"is");if("t"===s.children[0].name){var u=s.children[0];this._value=u.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 l=d.findChild(e,"v").children[0];this._value=p.getError(l)}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,f.isEmpty(e.attributes)||(this._remainingAttributes=e.attributes),d.removeChild(e,"f"),d.removeChild(e,"v"),d.removeChild(e,"is"),f.isEmpty(e.children)||(this._remainingChildren=e.children)}}])&&i(e.prototype,t),r&&i(e,r),n}();t.exports=n},{"./ArgHandler":2,"./FormulaError":7,"./RichText":11,"./Style":16,"./addressConverter":22,"./dateConverter":25,"./regexify":27,"./xmlq":28,lodash:76}],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 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._sheet=e,this._node=t}var e,t,n;return e=r,(t=[{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 o("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 o("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 o("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":22}],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 o=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 o.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:76}],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 o={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===o[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===o[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:o[e],children:[this._properties[e]]});return this._node}}])&&i(e.prototype,r),n&&i(e,n),t}();t.exports=n},{}],7:[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"),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._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}();o.DIV0=new o("#DIV/0!"),o.NA=new o("#N/A"),o.NAME=new o("#NAME?"),o.NULL=new o("#NULL!"),o.NUM=new o("#NUM!"),o.REF=new o("#REF!"),o.VALUE=new o("#VALUE!"),o.getError=function(t){return n.find(o,function(e){return e instanceof o&&e.error()===t})||new o(t)},t.exports=o},{lodash:76}],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=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},{}],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 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._startCell=e,this._endCell=t,this._findRangeExtent(e,t)}var e,t,n;return e=r,(t=[{key:"address",value:function(e){return o.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 o=this;return new a("Range.formula").case(function(){return o.startCell().getSharedRefFormula()}).case("string",function(n){var i=o.sheet().incrementMaxSharedFormulaId();return o.forEach(function(e,t,r){0===t&&0===r?e.setSharedFormula(i,n,o.address()):e.setSharedFormula(i)}),o}).handle(arguments)}},{key:"map",value:function(n){var i=this,o=[];return this.forEach(function(e,t,r){o[t]||(o[t]=[]),o[t][r]=n(e,t,r,i)}),o}},{key:"merged",value:function(e){var t=this;return new a("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 a("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,o=e;return this.forEach(function(e,t,r){o=n(o,e,t,r,i)}),o}},{key:"sheet",value:function(){return this.startCell().sheet()}},{key:"startCell",value:function(){return this._startCell}},{key:"style",value:function(){var o=this;return new a("Range.style").case("string",function(t){return o.map(function(e){return e.style(t)})}).case("array",function(e){var t={};return e.forEach(function(e){t[e]=o.style(e)}),t}).case(["string","function"],function(n,i){return o.forEach(function(e,t,r){e.style(n,i(e,t,r,o))})}).case(["string","array"],function(n,i){return o.forEach(function(e,t,r){i[t]&&void 0!==i[t][r]&&e.style(n,i[t][r])})}).case(["string","*"],function(t,r){return o.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];o.style(t,r)}return o}).case("Style",function(t){return o._style=t,o.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 a("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":22}],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("lodash"),a="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(a).concat(e),Target:t}};return r&&(n.attributes.TargetMode=r),this._node.children.push(n),n}},{key:"findById",value:function(t){return o.find(this._node.children,function(e){return e.attributes.Id===t})}},{key:"findByType",value:function(t){return o.find(this._node.children,function(e){return e.attributes.Type==="".concat(a).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:76}],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 o=e("lodash"),a=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 a(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(o.cloneDeep(this.toXml()));return e&&o.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 a(e,t,this)):this._node.splice(r,0,new a(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":12,lodash:76}],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 o=e("./ArgHandler"),a=e("lodash"),s=e("./xmlq"),u=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 o("_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 o("_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=u[r.attributes.indexed]),r.attributes.hasOwnProperty("tint")&&(n.tint=r.attributes.tint),!a.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":24,"./xmlq":28,lodash:76}],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("lodash"),s=e("./Cell"),o=e("./regexify"),u=e("./ArgHandler"),l=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 l.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=l.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);a.isNil(n)?a.isNil(i)||(t=i):t=n;var o=new s(this,r,t);return this._cells[r]=o}},{key:"height",value:function(){var t=this;return new u("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 u("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 u("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(),a.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(),a.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=o(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!a.isNil(this._node.attributes.s)}},{key:"minUsedColumnNumber",value:function(){return a.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){a.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":22,"./regexify":27,lodash:76}],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"),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=o.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:o.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:76}],15:[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 o(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 l=e("lodash"),s=e("./Cell"),c=e("./Row"),f=e("./Column"),a=e("./Range"),h=e("./Relationships"),d=e("./xmlq"),u=e("./regexify"),p=e("./addressConverter"),m=e("./ArgHandler"),_=e("./colorIndexes"),g=e("./PageBreaks"),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","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 m("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 m("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 m("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=l.cloneDeep(n);i.attributes.max=t-1;for(var o=i.attributes.min;o<=i.attributes.max;o++)this._colNodes[o]=i}if((r=l.cloneDeep(n)).attributes.min=t,r.attributes.max=t,this._colNodes[t]=r,n.attributes.max>t){var a=l.cloneDeep(n);a.attributes.min=t+1;for(var s=a.attributes.min;s<=a.attributes.max;s++)this._colNodes[s]=a}}else r={name:"col",attributes:{min:t,max:t},children:[]},this._colNodes[t]=r;var u=new f(this,r);return this._columns[t]=u}},{key:"definedName",value:function(){var r=this;return new m("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=u(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 m("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 m("Sheet.hidden").case(function(){return"hidden"===r._idNode.attributes.state||"veryHidden"===r._idNode.attributes.state&&"very"}).case("*",function(e){if(e){var t=l.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 m("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 m("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 a(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",value:function(){var r=this;return new m("Sheet.tabColor").case(function(){var e=d.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=_[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 d.removeChild(r._sheetPrNode,"tabColor"),r}).case("object",function(e){var t=d.appendChildIfNotFound(r._sheetPrNode,"tabColor");return d.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 m("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:"rightToLeft",value:function(){var t=this,r=this._getOrCreateSheetViewNode();return new m("Sheet.rightToLeft").case(function(){return r.attributes.rightToLeft}).case("boolean",function(e){return e?r.attributes.rightToLeft=!0:delete r.attributes.rightToLeft,t}).handle(arguments)}},{key:"usedRange",value:function(){for(var e=l.findIndex(this._rows),t=this._rows.length-1,r=0,n=0,i=0;i<this._rows.length;i++){var o=this._rows[i];if(o){var a=o.minUsedColumnNumber(),s=o.maxUsedColumnNumber();0<a&&(!r||a<r)&&(r=a),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:"pageBreaks",value:function(){return this._pageBreaks}},{key:"verticalPageBreaks",value:function(){return this._pageBreaks.colBreaks}},{key:"horizontalPageBreaks",value:function(){return this._pageBreaks.rowBreaks}},{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){l.forEach(this._colNodes,function(e,t){e&&r(t)})}},{key:"forEachExistingRow",value:function(r){return l.forEach(this._rows,function(e,t){e&&r(e,t)}),this}},{key:"hyperlink",value:function(){var a=this;return new m("Sheet.hyperlink").case("string",function(e){var t=a._hyperlinks[e];if(t){var r=a._relationships.findById(t.attributes["r:id"]);return r&&r.attributes.Target}}).case(["string","nil"],function(e){return delete a._hyperlinks[e],a}).case(["string","string"],function(e,t){return a.hyperlink(e,t,!1)}).case(["string","string","boolean"],function(e,t,r){var n;r||p.fromAddress(t)?n={ref:e,location:t,display:t}:n={ref:e,"r:id":a._relationships.add("hyperlink",t,"External").attributes.Id};return a._hyperlinks[e]={name:"hyperlink",attributes:n,children:[]},a}).case(["string","object"],function(e,t){if(t instanceof s){var r=t.address({includeSheetName:!0});a.hyperlink(e,r,!0)}else if(t.hyperlink)a.hyperlink(e,t.hyperlink);else if(t.email){var n=t.email,i=t.emailSubject||"";a.hyperlink(e,encodeURI("mailto:".concat(n,"?subject=").concat(i)))}var o=a._hyperlinks[e];return o&&t.tooltip&&(o.attributes.tooltip=t.tooltip),a}).handle(arguments)}},{key:"incrementMaxSharedFormulaId",value:function(){return++this._maxSharedFormulaId}},{key:"merged",value:function(){var r=this;return new m("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 m("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"===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 r=this,n=l.clone(this._node);if(n.children=n.children.slice(),this._colsNode.children=l.filter(this._colNodes,function(e,t){return e&&t===e.attributes.min&&2<Object.keys(e.attributes).length}),this._colsNode.children.length&&d.insertInOrder(n,this._colsNode,v),this._hyperlinksNode.children=l.values(this._hyperlinks),this._hyperlinksNode.children.length&&d.insertInOrder(n,this._hyperlinksNode,v),this._printOptionsNode&&Object.keys(this._printOptionsNode.attributes).length&&d.insertInOrder(n,this._printOptionsNode,v),this._pageMarginsNode&&this._pageMarginsPresetName){var e=l.clone(this._pageMarginsNode);Object.keys(this._pageMarginsNode.attributes).length?e.attributes=l.assign(this._pageMarginsPresets[this._pageMarginsPresetName],this._pageMarginsNode.attributes):e.attributes=this._pageMarginsPresets[this._pageMarginsPresetName],d.insertInOrder(n,e,v)}return this._mergeCellsNode.children=l.values(this._mergeCells),this._mergeCellsNode.children.length&&d.insertInOrder(n,this._mergeCellsNode,v),this._dataValidationsNode.children=l.values(this._dataValidations),this._dataValidationsNode.children.length&&d.insertInOrder(n,this._dataValidationsNode,v),this._autoFilter&&d.insertInOrder(n,{name:"autoFilter",children:[],attributes:{ref:this._autoFilter.address()}},v),["colBreaks","rowBreaks"].forEach(function(e){var t=r["_".concat(e,"Node")];t.attributes.count&&d.insertInOrder(n,t,v)}),{id:this._idNode,sheet:n,relationships:this._relationships}}},{key:"updateMaxSharedFormulaId",value:function(e){e>this._maxSharedFormulaId&&(this._maxSharedFormulaId=e)}},{key:"printOptions",value:function(){var r=this,n=this._getCheckAttributeNameHelper("printOptions",["gridLines","gridLinesSet","headings","horizontalCentered","verticalCentered"]);return new m("Sheet.printOptions").case(["string"],function(e){return n(e),1===r._printOptionsNode.attributes[e]}).case(["string","nil"],function(e){return n(e),delete r._printOptionsNode.attributes[e],r}).case(["string","boolean"],function(e,t){return n(e),t?(r._printOptionsNode.attributes[e]=1,r):r.printOptions(e,void 0)}).handle(arguments)}},{key:"printGridLines",value:function(){var t=this;return new m("Sheet.gridLines").case(function(){return t.printOptions("gridLines")&&t.printOptions("gridLinesSet")}).case(["nil"],function(){return t.printOptions("gridLines",void 0),t.printOptions("gridLinesSet",void 0),t}).case(["boolean"],function(e){return t.printOptions("gridLines",e),t.pr