@elbstack/xlsx-populate
Version:
Excel XLSX parser/generator written in JavaScript with Node.js and browser support, jQuery/d3-style method chaining, and a focus on keeping existing workbook features and styles in tact.
1 lines • 334 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(){return function o(a,s,u){function l(r,e){if(!s[r]){if(!a[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(c)return c(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var i=s[r]={exports:{}};a[r][0].call(i.exports,function(e){var t=a[r][1][e];return l(t||e)},i,i.exports,o,a,s,u)}return s[r].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";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();e("lodash");var i=e("./xmlq"),o=e("./ArgHandler"),a=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._node=e}return n(t,[{key:"isSecure",value:function(e){var t=this;return new o("Range.formula").case(function(){var e=i.findChild(t._node,"DocSecurity");return!!e&&1===e.children[0]}).case("boolean",function(e){return i.appendChildIfNotFound(t._node,"DocSecurity").children=[e?1:0],t}).handle(arguments)}},{key:"toXml",value:function(){return this._node}}]),t}();t.exports=a},{"./ArgHandler":2,"./xmlq":25,lodash:95}],2:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=e("lodash"),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._name=e,this._cases=[]}return n(t,[{key:"case",value:function(e,t){return 1===arguments.length&&(t=e,e=[]),Array.isArray(e)||(e=[e]),this._cases.push({types:e,handler:t}),this}},{key:"handle",value:function(e){for(var t=0;t<this._cases.length;t++){var r=this._cases[t];if(this._argsMatchTypes(e,r.types))return r.handler.apply(null,e)}throw new Error(this._name+": Invalid arguments.")}},{key:"_argsMatchTypes",value:function(e,n){return e.length===n.length&&i.every(e,function(e,t){var r=n[t];if("*"===r)return!0;if("nil"===r)return i.isNil(e);if("string"===r)return"string"==typeof e;if("boolean"===r)return"boolean"==typeof e;if("number"===r)return"number"==typeof e;if("integer"===r)return"number"==typeof e&&i.isInteger(e);if("function"===r)return"function"==typeof e;if("array"===r)return Array.isArray(e);if("date"===r)return e&&e.constructor===Date;if("object"===r)return e&&e.constructor===Object;if(e&&e.constructor&&e.constructor.name===r)return!0;throw new Error("Unknown type: "+r)})}}]),t}();t.exports=o},{lodash:95}],3:[function(e,t,r){"use strict";var i=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var c=e("lodash"),o=e("./ArgHandler"),f=e("./addressConverter"),a=e("./dateConverter"),s=e("./regexify"),h=e("./xmlq"),d=e("./FormulaError"),u=e("./Style"),n=function(){function n(e,t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this._row=e,this._init(t,r)}return i(n,[{key:"active",value:function(){var t=this;return new 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 f.toAddress({type:"cell",rowNumber:this.rowNumber(),columnNumber:this.columnNumber(),sheetName:e&&e.includeSheetName&&this.sheet().name(),rowAnchored:e&&(e.rowAnchored||e.anchored),columnAnchored:e&&(e.columnAnchored||e.anchored)})}},{key:"column",value:function(){return this.sheet().column(this.columnNumber())}},{key:"clear",value:function(){var e=this._formulaRef&&this._sharedFormulaId;return delete this._value,delete this._formulaType,delete this._formula,delete this._sharedFormulaId,delete this._formulaRef,c.isNil(e)||this.sheet().clearCellsUsingSharedFormula(e),this}},{key:"columnName",value:function(){return f.columnNumberToName(this.columnNumber())}},{key:"columnNumber",value:function(){return this._columnNumber}},{key:"find",value:function(e,t){e=s(e);var r=this.value();if("string"!=typeof r)return!1;if(c.isNil(t))return e.test(r);var n=r.replace(e,t);return n!==r&&(this.value(n),!0)}},{key:"formula",value:function(){var t=this;return new 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("*",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(){var i=this;return this._style||arguments[0]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}).case("array",function(e){var t=e.length,r=e[0].length;return n.rangeTo(n.relativeCell(t-1,r-1)).value(e)}).case("*",function(e){return n.clear(),n._value=e,n}).handle(arguments)}},{key:"workbook",value:function(){return this.row().workbook()}},{key:"getSharedRefFormula",value:function(){return"shared"===this._formulaType?this._formulaRef&&this._formula:void 0}},{key:"sharesFormula",value:function(e){return"shared"===this._formulaType&&this._sharedFormulaId===e}},{key:"setSharedFormula",value:function(e,t,r){this.clear(),this._formulaType="shared",this._sharedFormulaId=e,this._formula=t,this._formulaRef=r}},{key:"toXml",value:function(){var e={name:"c",attributes:this._remainingAttributes||{},children:[]};if(e.attributes.r=this.address(),c.isNil(this._formulaType)){if(!c.isNil(this._value)){var t=void 0,r=void 0;"string"==typeof this._value||c.isArray(this._value)?(t="s",r=this.workbook().sharedStrings().getIndexForString(this._value)):"boolean"==typeof this._value?(t="b",r=this._value?1:0):"number"==typeof this._value?r=this._value:this._value instanceof Date&&(r=a.dateToNumber(this._value)),t&&(e.attributes.t=t);var n={name:"v",children:[r]};e.children.push(n)}}else{var i={name:"f",attributes:this._remainingFormulaAttributes||{}};"normal"!==this._formulaType&&(i.attributes.t=this._formulaType),c.isNil(this._formulaRef)||(i.attributes.ref=this._formulaRef),c.isNil(this._sharedFormulaId)||(i.attributes.si=this._sharedFormulaId),c.isNil(this._formula)||(i.children=[this._formula]),e.children.push(i)}return c.isNil(this._style)?c.isNil(this._styleId)||(e.attributes.s=this._styleId):e.attributes.s=this._style.id(),this._remainingChildren&&(e.children=e.children.concat(this._remainingChildren)),e}},{key:"_init",value:function(e,t){c.isObject(e)?this._parseNode(e):(this._columnNumber=e,c.isNil(t)||(this._styleId=t))}},{key:"_parseNode",value:function(e){var t=f.fromAddress(e.attributes.r);this._columnNumber=t.columnNumber,c.isNil(e.attributes.s)||(this._styleId=e.attributes.s);var r=h.findChild(e,"f");r&&(this._formulaType=r.attributes.t||"normal",this._formulaRef=r.attributes.ref,this._formula=r.children[0],this._sharedFormulaId=r.attributes.si,c.isNil(this._sharedFormulaId)||this.sheet().updateMaxSharedFormulaId(this._sharedFormulaId),delete r.attributes.t,delete r.attributes.ref,delete r.attributes.si,c.isEmpty(r.attributes)||(this._remainingFormulaAttributes=r.attributes));var n=e.attributes.t;if("s"===n){var i=h.findChild(e,"v").children[0];this._value=this.workbook().sharedStrings().getStringByIndex(i)}else if("str"===n){var o=h.findChild(e,"v");this._value=o&&o.children[0]}else if("inlineStr"===n){var a=h.findChild(e,"is");if("t"===a.children[0].name){var s=a.children[0];this._value=s.children[0]}else this._value=a.children}else if("b"===n)this._value=1===h.findChild(e,"v").children[0];else if("e"===n){var u=h.findChild(e,"v").children[0];this._value=d.getError(u)}else{var l=h.findChild(e,"v");this._value=l&&Number(l.children[0])}delete e.attributes.r,delete e.attributes.s,delete e.attributes.t,c.isEmpty(e.attributes)||(this._remainingAttributes=e.attributes),h.removeChild(e,"f"),h.removeChild(e,"v"),h.removeChild(e,"is"),c.isEmpty(e.children)||(this._remainingChildren=e.children)}}]),n}();t.exports=n},{"./ArgHandler":2,"./FormulaError":7,"./Style":13,"./addressConverter":19,"./dateConverter":22,"./regexify":24,"./xmlq":25,lodash:95}],4:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=e("./ArgHandler"),o=e("./addressConverter"),a=function(){function r(e,t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this._sheet=e,this._node=t}return n(r,[{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 i("Column.hidden").case(function(){return 1===t._node.attributes.hidden}).case("boolean",function(e){return e?t._node.attributes.hidden=1:delete t._node.attributes.hidden,t}).handle(arguments)}},{key:"sheet",value:function(){return this._sheet}},{key:"style",value:function(){var n=this;return new i("Column.style").case("string",function(e){return n._createStyleIfNeeded(),n._style.style(e)}).case("array",function(e){var t={};return e.forEach(function(e){t[e]=n.style(e)}),t}).case(["string","*"],function(t,r){return n.sheet().forEachExistingRow(function(e){(e.hasStyle()||e.hasCell(n.columnNumber()))&&e.cell(n.columnNumber()).style(t,r)}),n._createStyleIfNeeded(),n._style.style(t,r),n}).case("object",function(e){for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];n.style(t,r)}return n}).case("Style",function(t){return n.sheet().forEachExistingRow(function(e){(e.hasStyle()||e.hasCell(n.columnNumber()))&&e.cell(n.columnNumber()).style(t)}),n._style=t,n._node.attributes.style=t.id(),n}).handle(arguments)}},{key:"width",value:function(e){var t=this;return new i("Column.width").case(function(){return t._node.attributes.customWidth?t._node.attributes.width:void 0}).case("number",function(e){return t._node.attributes.width=e,t._node.attributes.customWidth=1,t}).case("nil",function(){return delete t._node.attributes.width,delete t._node.attributes.customWidth,t}).handle(arguments)}},{key:"workbook",value:function(){return this.sheet().workbook()}},{key:"toXml",value:function(){return this._node}},{key:"_createStyleIfNeeded",value:function(){if(!this._style){var e=this._node.attributes.style;this._style=this.workbook().styleSheet().createStyle(e),this._node.attributes.style=this._style.id(),this.width()||this.width(9.140625)}}}]),r}();t.exports=a},{"./ArgHandler":2,"./addressConverter":19}],5:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=e("lodash"),o=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._node=e}return n(t,[{key:"add",value:function(e,t){var r={name:"Override",attributes:{PartName:e,ContentType:t}};return this._node.children.push(r),r}},{key:"findByPartName",value:function(t){return i.find(this._node.children,function(e){return e.attributes.PartName===t})}},{key:"toXml",value:function(){return this._node}}]),t}();t.exports=o},{lodash:95}],6:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i={title:"dc:title",subject:"dc:subject",author:"dc:creator",creator:"dc:creator",description:"dc:description",keywords:"cp:keywords",category:"cp:category"},o=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._node=e,this._properties={}}return n(t,[{key:"set",value:function(e,t){var r=e.toLowerCase();if(void 0===i[r])throw new Error('Unknown property name: "'+e+'"');return this._properties[r]=t,this}},{key:"get",value:function(e){var t=e.toLowerCase();if(void 0===i[t])throw new Error('Unknown property name: "'+e+'"');return this._properties[t]}},{key:"toXml",value:function(){for(var e in this._properties)this._properties.hasOwnProperty(e)&&this._node.children.push({name:i[e],children:[this._properties[e]]});return this._node}}]),t}();t.exports=o},{}],7:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=e("lodash"),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}return n(t,[{key:"error",value:function(){return this._error}}]),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 i.find(o,function(e){return e instanceof o&&e.error()===t})||new o(t)},t.exports=o},{lodash:95}],8:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var a=e("./ArgHandler"),i=e("./addressConverter"),o=function(){function r(e,t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this._startCell=e,this._endCell=t,this._findRangeExtent(e,t)}return n(r,[{key:"address",value:function(e){return i.toAddress({type:"range",startRowNumber:this.startCell().rowNumber(),startRowAnchored:e&&(e.startRowAnchored||e.anchored),startColumnName:this.startCell().columnName(),startColumnAnchored:e&&(e.startColumnAnchored||e.anchored),endRowNumber:this.endCell().rowNumber(),endRowAnchored:e&&(e.endRowAnchored||e.anchored),endColumnName:this.endCell().columnName(),endColumnAnchored:e&&(e.endColumnAnchored||e.anchored),sheetName:e&&e.includeSheetName&&this.sheet().name()})}},{key:"cell",value:function(e,t){return this.sheet().cell(this._minRowNumber+e,this._minColumnNumber+t)}},{key:"autoFilter",value:function(){return this.sheet().autoFilter(this),this}},{key:"cells",value:function(){return this.map(function(e){return e})}},{key:"clear",value:function(){return this.value(void 0)}},{key:"endCell",value:function(){return this._endCell}},{key:"forEach",value:function(e){for(var t=0;t<this._numRows;t++)for(var r=0;r<this._numColumns;r++)e(this.cell(t,r),t,r,this);return this}},{key:"formula",value:function(){var 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}}]),r}();t.exports=o},{"./ArgHandler":2,"./addressConverter":19}],9:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=e("lodash"),o="http://schemas.openxmlformats.org/officeDocument/2006/relationships/",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._init(e),this._getStartingId()}return n(t,[{key:"add",value:function(e,t,r){var n={name:"Relationship",attributes:{Id:"rId"+this._nextId++,Type:""+o+e,Target:t}};return r&&(n.attributes.TargetMode=r),this._node.children.push(n),n}},{key:"findById",value:function(t){return i.find(this._node.children,function(e){return e.attributes.Id===t})}},{key:"findByType",value:function(t){return i.find(this._node.children,function(e){return e.attributes.Type===""+o+t})}},{key:"toXml",value:function(){if(this._node.children.length)return this._node}},{key:"_getStartingId",value:function(){var r=this;this._nextId=1,this._node.children.forEach(function(e){var t=parseInt(e.attributes.Id.substr(3));t>=r._nextId&&(r._nextId=t+1)})}},{key:"_init",value:function(e){e||(e={name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},children:[]}),this._node=e}}]),t}();t.exports=a},{lodash:95}],10:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var a=e("lodash"),s=e("./Cell"),i=e("./regexify"),o=e("./ArgHandler"),u=e("./addressConverter"),l=function(){function r(e,t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this._sheet=e,this._init(t)}return n(r,[{key:"address",value:function(e){return 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=e;if("string"==typeof e&&(t=u.columnNameToNumber(e)),this._cells[t])return this._cells[t];var r=void 0,n=this._node.attributes.s,i=this.sheet().existingColumnStyleId(t);a.isNil(n)?a.isNil(i)||(r=i):r=n;var o=new s(this,t,r);return this._cells[t]=o}},{key:"height",value:function(){var t=this;return new o("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 o("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 o("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:"clearCellsUsingSharedFormula",value:function(t){this._cells.forEach(function(e){e&&e.sharesFormula(t)&&e.clear()})}},{key:"find",value:function(t,r){t=i(t);var n=[];return this._cells.forEach(function(e){e&&e.find(t,r)&&n.push(e)}),n}},{key:"hasCell",value:function(e){return!!this._cells[e]}},{key:"hasStyle",value:function(){return!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}}]),r}();t.exports=l},{"./ArgHandler":2,"./Cell":3,"./addressConverter":19,"./regexify":24,lodash:95}],11:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var i=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._stringArray=[],this._indexMap={},this._init(e),this._cacheExistingSharedStrings()}return n(t,[{key:"getIndexForString",value:function(e){var t=i.isArray(e)?JSON.stringify(e):e,r=this._indexMap[t];return 0<=r||(r=this._stringArray.length,this._stringArray.push(e),this._indexMap[t]=r,this._node.children.push({name:"si",children:i.isArray(e)?e:[{name:"t",attributes:{"xml:space":"preserve"},children:[e]}]})),r}},{key:"getStringByIndex",value:function(e){return this._stringArray[e]}},{key:"toXml",value:function(){return this._node}},{key:"_cacheExistingSharedStrings",value:function(){var i=this;this._node.children.forEach(function(e,t){var r=e.children[0];if("t"===r.name){var n=r.children[0];i._stringArray.push(n),i._indexMap[n]=t}else i._stringArray.push(e.children),i._indexMap[JSON.stringify(e.children)]=t})}},{key:"_init",value:function(e){e||(e={name:"sst",attributes:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main"},children:[]}),this._node=e,delete this._node.attributes.count,delete this._node.attributes.uniqueCount}}]),t}();t.exports=o},{lodash:95}],12:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();var l=e("lodash"),a=e("./Cell"),u=e("./Row"),c=e("./Column"),s=e("./Range"),f=e("./Relationships"),h=e("./xmlq"),d=e("./regexify"),p=e("./addressConverter"),m=e("./ArgHandler"),_=e("./colorIndexes"),v=["sheetPr","dimension","sheetViews","sheetFormatPr","cols","sheetData","sheetCalcPr","sheetProtection","autoFilter","protectedRanges","scenarios","autoFilter","sortState","dataConsolidate","customSheetViews","mergeCells","phoneticPr","conditionalFormatting","dataValidations","hyperlinks","printOptions","pageMargins","pageSetup","headerFooter","rowBreaks","colBreaks","customProperties","cellWatches","ignoredErrors","smartTags","drawing","drawingHF","picture","oleObjects","controls","webPublishItems","tableParts","extLst"],i=function(){function i(e,t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),this._init(e,t,r,n)}return o(i,[{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=h.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:[]},h.appendChild(t,r)),e instanceof a||(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=this._colNodes[t],n=void 0;if(r){if(r.attributes.min<t){var i=l.cloneDeep(r);i.attributes.max=t-1;for(var o=i.attributes.min;o<=i.attributes.max;o++)this._colNodes[o]=i}if((n=l.cloneDeep(r)).attributes.min=t,n.attributes.max=t,this._colNodes[t]=n,r.attributes.max>t){var a=l.cloneDeep(r);a.attributes.min=t+1;for(var s=a.attributes.min;s<=a.attributes.max;s++)this._colNodes[s]=a}}else n={name:"col",attributes:{min:t,max:t},children:[]},this._colNodes[t]=n;var u=new c(this,n);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=d(t);var n=[];return this._rows.forEach(function(e){e&&(n=n.concat(e.find(t,r)))}),n}},{key:"gridLinesVisible",value:function(){var t=this,r=this._getOrCreateSheetViewNode();return new 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 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 s(e,t)}).case(["number","*","number","*"],function(e,t,r,n){return i.range(i.cell(e,t),i.cell(r,n))}).handle(arguments)}},{key:"autoFilter",value:function(e){return this._autoFilter=e,this}},{key:"row",value:function(e){if(this._rows[e])return this._rows[e];var t=new u(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=h.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 h.removeChild(r._sheetPrNode,"tabColor"),r}).case("object",function(e){var t=h.appendChildIfNotFound(r._sheetPrNode,"tabColor");return h.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:"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:"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 n=this;return new m("Sheet.hyperlink").case("string",function(e){var t=n._hyperlinks[e];if(t){var r=n._relationships.findById(t.attributes["r:id"]);return r&&r.attributes.Target}}).case(["string","nil"],function(e){return delete n._hyperlinks[e],n}).case(["string","string"],function(e,t){var r=n._relationships.add("hyperlink",t,"External");return n._hyperlinks[e]={name:"hyperlink",attributes:{ref:e,"r:id":r.attributes.Id},children:[]},n}).handle(arguments)}},{key:"incrementMaxSharedFormulaId",value:function(){return++this._maxSharedFormulaId}},{key:"merged",value:function(){var r=this;return new 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"===(void 0===t?"undefined":n(t))&&(r._dataValidations[e]={name:"dataValidation",attributes:{type:t.type?t.type:"list",allowBlank:t.allowBlank,showInputMessage:t.showInputMessage,prompt:t.prompt,promptTitle:t.promptTitle,showErrorMessage:t.showErrorMessage,error:t.error,errorTitle:t.errorTitle,operator:t.operator,sqref:e},children:[{name:"formula1",atrributes:{},children:[t.formula1]},{name:"formula2",atrributes:{},children:[t.formula2]}]}),r}).handle(arguments)}},{key:"toXmls",value:function(){var e=l.clone(this._node);return e.children=e.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&&h.insertInOrder(e,this._colsNode,v),this._hyperlinksNode.children=l.values(this._hyperlinks),this._hyperlinksNode.children.length&&h.insertInOrder(e,this._hyperlinksNode,v),this._mergeCellsNode.children=l.values(this._mergeCells),this._mergeCellsNode.children.length&&h.insertInOrder(e,this._mergeCellsNode,v),this._dataValidationsNode.children=l.values(this._dataValidations),this._dataValidationsNode.children.length&&h.insertInOrder(e,this._dataValidationsNode,v),this._autoFilter&&h.insertInOrder(e,{name:"autoFilter",children:[],attributes:{ref:this._autoFilter.address()}},v),{id:this._idNode,sheet:e,relationships:this._relationships}}},{key:"updateMaxSharedFormulaId",value:function(e){e>this._maxSharedFormulaId&&(this._maxSharedFormulaId=e)}},{key:"_getOrCreateSheetViewNode",value:function(){var e=h.findChild(this._node,"sheetViews");return e||(e={name:"sheetViews",attributes:{},children:[{name:"sheetView",attributes:{workbookViewId:0},children:[]}]},h.insertInOrder(this._node,e,v)),h.findChild(e,"sheetView")}},{key:"_init",value:function(e,t,r,n){var i=this;r||(r={name:"worksheet",attributes:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"},children:[{name:"sheetData",attributes:{},children:[]}]}),this._workbook=e,this._idNode=t,this._node=r,this._maxSharedFormulaId=-1,this._mergeCells={},this._dataValidations={},this._hyperlinks={},this._autoFilter=null,this._relationships=new f(n),h.removeChild(this._node,"dimension"),this._rows=[],this._sheetDataNode=h.findChild(this._node,"sheetData"),this._sheetDataNode.children.forEach(function(e){var t=new u(i,e);i._rows[t.rowNumber()]=t}),this._sheetDataNode.children=this._rows,this._columns=[],this._colsNode=h.findChild(this._node,"cols"),this._colsNode?h.removeChild(this._node,this._colsNode):this._colsNode={name:"cols",attributes:{},children:[]},this._colNodes=[],l.forEach(this._colsNode.children,function(e){for(var t=e.attributes.min,r=e.attributes.max,n=t;n<=r;n++)i._colNodes[n]=e}),this._sheetPrNode=h.findChild(this._node,"sheetPr"),this._sheetPrNode||(this._sheetPrNode={name:"sheetPr",attributes:{},children:[]},h.insertInOrder(this._node,this._sheetPrNode,v)),this._mergeCellsNode=h.findChild(this._node,"mergeCells"),this._mergeCellsNode?h.removeChild(this._node,this._mergeCellsNode):this._mergeCellsNode={name:"mergeCells",attributes:{},children:[]};var o=this._mergeCellsNode.children;this._mergeCellsNode.children=[],o.forEach(function(e){i._mergeCells[e.attributes.ref]=e}),this._dataValidationsNode=h.findChild(this._node,"dataValidations"),this._dataValidationsNode?h.removeChild(this._node,this._dataValidationsNode):this._dataValidationsNode={name:"dataValidations",attributes:{},children:[]};var a=this._dataValidationsNode.children;this._dataValidationsNode.children=[],a.forEach(function(e){i._dataValidations[e.attributes.sqref]=e}),this._hyperlinksNode=h.findChild(this._node,"hyperlinks"),this._hyperlinksNode?h.removeChild(this._node,this._hyperlinksNode):this._hyperlinksNode={name:"hyperlinks",attributes:{},children:[]};var s=this._hyperlinksNode.children;this._hyperlinksNode.children=[],s.forEach(function(e){i._hyperlinks[e.attributes.ref]=e})}}]),i}();t.exports=i},{"./ArgHandler":2,"./Cell":3,"./Column":4,"./Range":8,"./Relationships":9,"./Row":10,"./addressConverter":19,"./colorIndexes":21,"./regexify":24,"./xmlq":25,lodash:95}],13:[function(e,t,r){"use strict";var n=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}();function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=e("./ArgHandler"),c=e("lodash"),f=e("./xmlq"),s=e("./colorIndexes"),a=function(){function a(e,t,r,n,i,o){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),this._styleSheet=e,this._id=t,this._xfNode=r,this._fontNode=n,this._fillNode=i,this._borderNode=o}return n(a,[{key:"id",value:function(){return this._id}},{key:"style",value:function(){var n=this;return new o("_Style.style").case("string",function(e){var t="_get_"+e;if(!n[t])throw new Error("_Style.style: '"+e+"' is not a valid style");return n[t]()}).case(["string","*"],function(e,t){var r="_set_"+e;if(!n[r])throw new Error("_Style.style: '"+e+"' is not a valid style");return n[r](t),n}).handle(arguments)}},{key:"_getColor",value:function(e,t){var r=f.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=s[r.attributes.indexed]),r.attributes.hasOwnProperty("tint")&&(n.tint=r.attributes.tint),!c.isEmpty(n))return n}}},{key:"_setColor",value:function(e,t,r){"string"==typeof r?r={rgb:r}:"number"==typeof r&&(r={theme:r}),f.setChildAttributes(e,t,{rgb:r&&r.rgb&&r.rgb.toUpperCase(),indexed:null,theme:r&&r.theme,tint:r&&r.tint}),f.removeChildIfEmpty(e,"color")}},{key:"_get_bold",value:function(){return f.hasChild(this._fontNode,"b")}},{key:"_set_bold",value:function(e){e?f.appendChildIfNotFound(this._fontNode,"b"):f.removeChild(this._fontNode,"b")}},{key:"_get_italic",value:function(){return f.hasChild(this._fontNode,"i")}},{key:"_set_italic",value:function(e){e?f.appendChildIfNotFound(this._fontNode,"i"):f.removeChild(this._fontNode,"i")}},{key:"_get_underline",value:function(){var e=f.findChild(this._fontNode,"u");return!!e&&(e.attributes.val||!0)}},{key:"_set_underline",value:function(e){if(e){var t=f.appendChildIfNotFound(this._fontNode,"u"),r="string"==typeof e?e:null;f.setAttributes(t,{val:r})}else f.removeChild(this._fontNode,"u")}},{key:"_get_strikethrough",value:function(){return f.hasChild(this._fontNode,"strike")}},{key:"_set_strikethrough",value:function(e){e?f.appendChildIfNotFound(this._fontNode,"strike"):f.removeChild(this._fontNode,"strike")}},{key:"_getFontVerticalAlignment",value:function(){return f.getChildAttribute(this._fontNode,"vertAlign","val")}},{key:"_setFontVerticalAlignment",value:function(e){f.setChildAttributes(this._fontNode,"vertAlign",{val:e}),f.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 f.getChildAttribute(this._fontNode,"sz","val")}},{key:"_set_fontSize",value:function(e){f.setChildAttributes(this._fontNode,"sz",{val:e}),f.removeChildIfEmpty(this._fontNode,"sz")}},{key:"_get_fontFamily",value:function(){return f.getChildAttribute(this._fontNode,"name","val")}},{key:"_set_fontFamily",value:function(e){f.setChildAttributes(this._fontNode,"name",{val:e}),f.removeChildIfEmpty(this._fontNode,"name")}},{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_horizontalAlignment",value:function(){return f.getChildAttribute(this._xfNode,"alignment","horizontal")}},{key:"_set_horizontalAlignment",value:function(e){f.setChildAttributes(this._xfNode,"alignment",{horizontal:e}),f.removeChildIfEmpty(this._xfNode,"alignment")}},{key:"_get_justifyLastLine",value:function(){return 1===f.getChildAttribute(this._xfNode,"alignment","justifyLastLine")}},{key:"_set_justifyLastLine",value:function(e){f.setChildAttributes(this._xfNode,"alignment",{justifyLastLine:e?1:null}),f.removeChildIfEmpty(this._xfNode,"alignment")}},{key:"_get_indent",value:function(){return f.getChildAttribute(this._xfNode,"alignment","indent")}},{key:"_set_indent",value:function(e){f.setChildAttributes(this._xfNode,"alignment",{indent:e}),f.removeChildIfEmpty(this._xfNode,"alignment")}},{key:"_get_verticalAlignment",value:function(){return f.getChildAttribute(this._xfNode,"alignment","vertical")}},{key:"_set_verticalAlignment",value:function(e){f.setChildAttributes(this._xfNode,"alignment",{vertical:e}),f.removeChildIfEmpty(this._xfNode,"alignment")}},{key:"_get_wrapText",value:function(){return 1===f.getChildAttribute(this._xfNode,"alignment","wrapText")}},{key:"_set_wrapText",value:function(e){f.setChildAttributes(this._xfNode,"alignment",{wrapText:e?1:null}),f.removeChildIfEmpty(this._xfNode,"alignment")}},{key:"_get_shrinkToFit",value:function(){return 1===f.getChildAttribute(this._xfNode,"alignment","shrinkToFit")}},{key:"_set_shrinkToFit",value:function(e){f.setChildAttributes(this._xfNode,"alignment",{shrinkToFit:e?1:null}),f.removeChildIfEmpty(this._xfNode,"alignment")}},{key:"_get_textDirection",value:function(){var e=f.getChildAttribute(this._xfNode,"alignment","readingOrder");return 1===e?"left-to-right":2===e?"right-to-left":e}},{key:"_set_textDirection",value:function(e){var t=void 0;"left-to-right"===e?t=1:"right-to-left"===e&&(t=2),f.setChildAttributes(this._xfNode,"alignment",{readingOrder:t}),f.removeChildIfEmpty(this._xfNode,"alignment")}},{key:"_getTextRotation",value:function(){return f.getChildAttribute(this._xfNode,"alignment","textRotation")}},{key:"_setTextRotation",value:function(e){f.setChildAttributes(this._xfNode,"alignment",{textRotation:e}),f.removeChildIfEmpty(this._xfNode,"alignment")}},{key:"_get_textRotation",value:function(){var e=this._getTextRotation();return 90<e&&(e=90-e),e}},{key:"_set_textRotation",value:function(e){e<0&&(e=90-e),this._setTextRotation(e)}},{key:"_get_angleTextCounterclockwise",value:function(){return 45===this._getTextRotation()}},{key:"_set_angleTextCounterclockwise",value:function(e){this._setTextRotation(e?45:null)}},{key:"_get_angleTextClockwise",value:function(){return 135===this._getTextRotation()}},{key:"_set_angleTextClockwise",value:function(e){this._setTextRotation(e?135:null)}},{key:"_get_rotateTextUp",value:function(){return 90===this._getTextRotation()}},{key:"_set_rotateTextUp",value:function(e){this._setTextRotation(e?90:null)}},{key:"_get_rotateTextDown",value:function(){return 180===this._getTextRotation()}},{key:"_set_rotateTextDown",value:function(e){this._setTextRotation(e?180:null)}},{key:"_get_verticalText",value:function(){return 255===this._getTextRotation()}},{key:"_set_verticalText",value:function(e){this._setTextRotation(e?255:null)}},{key:"_get_fill",value:function(){var t=this,e=f.findChild(this._fillNode,"patternFill"),r=f.findChild(this._fillNode,"gradientFill"),n=e&&e.attributes.patternType;if("solid"===n)return{type:"solid",color:this._getColor(e,"fgColor")};if(n)return{type:"pattern",pattern:n,foreground:this._getColor(e,"fgColor"),background:this._getColor(e,"bgColor")};if(r){var i=r.attributes.type||"linear",o={type:"gradient",gradientType:i,stops:c.map(r.children,function(e){return{position:e.attributes.position,color:t._getColor(e,"color")}})};return"linear"===i?o.angle=r.attributes.degree:(o.left=r.attributes.left,o.right=r.attributes.right,o.top=r.attributes.top,o.bottom=r.attributes.bottom),o}}},{key:"_set_fill",value:function(e){var n=this;if(this._fillNode.children=[],!c.isNil(e)){if("pattern"===e.type){var t={name:"patternFill",attributes:{patternType:e.pattern},children:[]};return this._fillNode.children.push(t),this._setColor(t,"fgColor",e.foreground),void this._setColor(t,"bgColor",e.background)}if("gradient"===e.type){var i={name:"gradientFill",attributes:{},children:[]};return this._fillNode.children.push(i),f.setAttributes(i,{type:"path"===e.gradientType?"path":void 0,left:e.left,right:e.right,top:e.top,bottom:e.bottom,degree:e.angle}),void c.forEach(e.stops,function(e,t){var r={name:"stop",attributes:{position:e.position},children:[]};i.children.push(r),n._setColor(r,"color",e.color)})}c.isObject(e)?(e.hasOwnProperty("rgb")||e.hasOwnProperty("theme"))&&(e={color:e}):e={type:"solid",