UNPKG

@papb/json-excel

Version:

Create a pretty Excel table from JSON data with a very simple API

1 lines 1.16 MB
var jsonToExcel=function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function n(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function a(e){var t={exports:{}};return e(t,t.exports),t.exports}function s(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.')}var u=o(a(function(e,t){e.exports=function e(t,r,n){function i(a,u){if(!r[a]){if(!t[a]){if(!u&&s)return s(a);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[a]={exports:{}};t[a][0].call(f.exports,function(e){return i(t[a][1][e]||e)},f,f.exports,e,t,r,n)}return r[a].exports}for(var o=s,a=0;a<n.length;a++)i(n[a]);return i}({1:[function(e,t,r){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 i(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function o(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function s(e){i(a,n,o,s,u,"next",e)}function u(e){i(a,n,o,s,u,"throw",e)}s(void 0)})}}var a=e("fs"),s=e("fast-csv"),u=e("dayjs/plugin/customParseFormat"),c=e("dayjs/plugin/utc"),f=e("dayjs").extend(u).extend(c),l=e("../utils/stream-buf"),h=e("../utils/utils").fs.exists,d={true:!0,false:!1,"#N/A":{error:"#N/A"},"#REF!":{error:"#REF!"},"#NAME?":{error:"#NAME?"},"#DIV/0!":{error:"#DIV/0!"},"#NULL!":{error:"#NULL!"},"#VALUE!":{error:"#VALUE!"},"#NUM!":{error:"#NUM!"}},p=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.workbook=t,this.worksheet=null}var t,r,i,u;return t=e,(r=[{key:"readFile",value:(u=o(regeneratorRuntime.mark(function e(t,r){var n,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=r||{},e.next=3,h(t);case 3:if(e.sent){e.next=5;break}throw new Error("File not found: ".concat(t));case 5:return n=a.createReadStream(t),e.next=8,this.read(n,r);case 8:return i=e.sent,n.close(),e.abrupt("return",i);case 11:case"end":return e.stop()}},e,this)})),function(e,t){return u.apply(this,arguments)})},{key:"read",value:function(e,t){var r=this;return t=t||{},new Promise(function(n,i){var o=r.workbook.addWorksheet(t.sheetName),a=t.dateFormats||["YYYY-MM-DD[T]HH:mm:ssZ","YYYY-MM-DD[T]HH:mm:ss","MM-DD-YYYY","YYYY-MM-DD"],u=t.map||function(e){if(""===e)return null;var t=Number(e);if(!Number.isNaN(t)&&t!==1/0)return t;var r=a.reduce(function(t,r){if(t)return t;var n=f(e,r,!0);return n.isValid()?n:null},null);if(r)return new Date(r.valueOf());var n=d[e];return void 0!==n?n:e},c=s.parse(t.parserOptions).on("data",function(e){o.addRow(e.map(u))}).on("end",function(){c.emit("worksheet",o)});c.on("worksheet",n).on("error",i),e.pipe(c)})}},{key:"createInputStream",value:function(){throw new Error("`CSV#createInputStream` is deprecated. You should use `CSV#read` instead. This method will be removed in version 5.0. Please follow upgrade instruction: https://github.com/exceljs/exceljs/blob/master/UPGRADE-4.0.md")}},{key:"write",value:function(e,t){var r=this;return new Promise(function(i,o){var a=r.workbook.getWorksheet((t=t||{}).sheetName||t.sheetId),u=s.format(t.formatterOptions);e.on("finish",function(){i()}),u.on("error",o),u.pipe(e);var c=t.dateFormat,l=t.dateUTC,h=t.map||function(e){if(e){if(e.text||e.hyperlink)return e.hyperlink||e.text||"";if(e.formula||e.result)return e.result||"";if(e instanceof Date)return c?l?f.utc(e).format(c):f(e).format(c):l?f.utc(e).format():f(e).format();if(e.error)return e.error;if("object"===n(e))return JSON.stringify(e)}return e},d=void 0===t.includeEmptyRows||t.includeEmptyRows,p=1;a&&a.eachRow(function(e,t){if(d)for(;p++<t-1;)u.write([]);var r=e.values;r.shift(),u.write(r.map(h)),p=t}),u.end()})}},{key:"writeFile",value:function(e,t){var r={encoding:(t=t||{}).encoding||"utf8"},n=a.createWriteStream(e,r);return this.write(n,t)}},{key:"writeBuffer",value:(i=o(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=new l,e.next=3,this.write(r,t);case 3:return e.abrupt("return",r.read());case 4:case"end":return e.stop()}},e,this)})),function(e){return i.apply(this,arguments)})}])&&function(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)}}(t.prototype,r),e}();t.exports=p},{"../utils/stream-buf":23,"../utils/utils":26,dayjs:336,"dayjs/plugin/customParseFormat":337,"dayjs/plugin/utc":338,"fast-csv":369,fs:215}],2:[function(e,t,r){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}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("../utils/col-cache"),a=function(){function e(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(n(this,e),r)if("string"==typeof r){var a=o.decodeAddress(r);this.nativeCol=a.col+i,this.nativeColOff=0,this.nativeRow=a.row+i,this.nativeRowOff=0}else void 0!==r.nativeCol?(this.nativeCol=r.nativeCol||0,this.nativeColOff=r.nativeColOff||0,this.nativeRow=r.nativeRow||0,this.nativeRowOff=r.nativeRowOff||0):void 0!==r.col?(this.col=r.col+i,this.row=r.row+i):(this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0);else this.nativeCol=0,this.nativeColOff=0,this.nativeRow=0,this.nativeRowOff=0;this.worksheet=t}var t,r,a;return t=e,a=[{key:"asInstance",value:function(t){return t instanceof e||null==t?t:new e(t)}}],(r=[{key:"col",get:function(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth},set:function(e){this.nativeCol=Math.floor(e),this.nativeColOff=Math.floor((e-this.nativeCol)*this.colWidth)}},{key:"row",get:function(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight},set:function(e){this.nativeRow=Math.floor(e),this.nativeRowOff=Math.floor((e-this.nativeRow)*this.rowHeight)}},{key:"colWidth",get:function(){return this.worksheet&&this.worksheet.getColumn(this.nativeCol+1)&&this.worksheet.getColumn(this.nativeCol+1).isCustomWidth?Math.floor(1e4*this.worksheet.getColumn(this.nativeCol+1).width):64e4}},{key:"rowHeight",get:function(){return this.worksheet&&this.worksheet.getRow(this.nativeRow+1)&&this.worksheet.getRow(this.nativeRow+1).height?Math.floor(1e4*this.worksheet.getRow(this.nativeRow+1).height):18e4}},{key:"model",get:function(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}},set:function(e){this.nativeCol=e.nativeCol,this.nativeColOff=e.nativeColOff,this.nativeRow=e.nativeRow,this.nativeRowOff=e.nativeRowOff}}])&&i(t.prototype,r),a&&i(t,a),e}();t.exports=a},{"../utils/col-cache":19}],3:[function(e,t,r){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}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)}}function o(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),e}var a=e("../utils/col-cache"),s=e("../utils/under-dash"),u=e("./enums"),c=e("../utils/shared-formula").slideFormula,f=e("./note"),l=function(){function e(t,r,i){if(n(this,e),!t||!r)throw new Error("A Cell needs a Row");this._row=t,this._column=r,a.validateAddress(i),this._address=i,this._value=S.create(e.Types.Null,this),this.style=this._mergeStyle(t.style,r.style,{}),this._mergeCount=0}return o(e,[{key:"destroy",value:function(){delete this.style,delete this._value,delete this._row,delete this._column,delete this._address}},{key:"_mergeStyle",value:function(e,t,r){var n=e&&e.numFmt||t&&t.numFmt;n&&(r.numFmt=n);var i=e&&e.font||t&&t.font;i&&(r.font=i);var o=e&&e.alignment||t&&t.alignment;o&&(r.alignment=o);var a=e&&e.border||t&&t.border;a&&(r.border=a);var s=e&&e.fill||t&&t.fill;s&&(r.fill=s);var u=e&&e.protection||t&&t.protection;return u&&(r.protection=u),r}},{key:"toCsvString",value:function(){return this._value.toCsvString()}},{key:"addMergeRef",value:function(){this._mergeCount++}},{key:"releaseMergeRef",value:function(){this._mergeCount--}},{key:"merge",value:function(t,r){this._value.release(),this._value=S.create(e.Types.Merge,this,t),r||(this.style=t.style)}},{key:"unmerge",value:function(){this.type===e.Types.Merge&&(this._value.release(),this._value=S.create(e.Types.Null,this),this.style=this._mergeStyle(this._row.style,this._column.style,{}))}},{key:"isMergedTo",value:function(t){return this._value.type===e.Types.Merge&&this._value.isMergedTo(t)}},{key:"toString",value:function(){return this.text}},{key:"_upgradeToHyperlink",value:function(t){this.type===e.Types.String&&(this._value=S.create(e.Types.Hyperlink,this,{text:this._value.value,hyperlink:t}))}},{key:"addName",value:function(e){this.workbook.definedNames.addEx(this.fullAddress,e)}},{key:"removeName",value:function(e){this.workbook.definedNames.removeEx(this.fullAddress,e)}},{key:"removeAllNames",value:function(){this.workbook.definedNames.removeAllNames(this.fullAddress)}},{key:"worksheet",get:function(){return this._row.worksheet}},{key:"workbook",get:function(){return this._row.worksheet.workbook}},{key:"numFmt",get:function(){return this.style.numFmt},set:function(e){this.style.numFmt=e}},{key:"font",get:function(){return this.style.font},set:function(e){this.style.font=e}},{key:"alignment",get:function(){return this.style.alignment},set:function(e){this.style.alignment=e}},{key:"border",get:function(){return this.style.border},set:function(e){this.style.border=e}},{key:"fill",get:function(){return this.style.fill},set:function(e){this.style.fill=e}},{key:"protection",get:function(){return this.style.protection},set:function(e){this.style.protection=e}},{key:"address",get:function(){return this._address}},{key:"row",get:function(){return this._row.number}},{key:"col",get:function(){return this._column.number}},{key:"$col$row",get:function(){return"$".concat(this._column.letter,"$").concat(this.row)}},{key:"type",get:function(){return this._value.type}},{key:"effectiveType",get:function(){return this._value.effectiveType}},{key:"isMerged",get:function(){return this._mergeCount>0||this.type===e.Types.Merge}},{key:"master",get:function(){return this.type===e.Types.Merge?this._value.master:this}},{key:"isHyperlink",get:function(){return this._value.type===e.Types.Hyperlink}},{key:"hyperlink",get:function(){return this._value.hyperlink}},{key:"value",get:function(){return this._value.value},set:function(t){this.type!==e.Types.Merge?(this._value.release(),this._value=S.create(S.getType(t),this,t)):this._value.master.value=t}},{key:"note",get:function(){return this._comment&&this._comment.note},set:function(e){this._comment=new f(e)}},{key:"text",get:function(){return this._value.toString()}},{key:"html",get:function(){return s.escapeHtml(this.text)}},{key:"formula",get:function(){return this._value.formula}},{key:"result",get:function(){return this._value.result}},{key:"formulaType",get:function(){return this._value.formulaType}},{key:"fullAddress",get:function(){return{sheetName:this._row.worksheet.name,address:this.address,row:this.row,col:this.col}}},{key:"name",get:function(){return this.names[0]},set:function(e){this.names=[e]}},{key:"names",get:function(){return this.workbook.definedNames.getNamesEx(this.fullAddress)},set:function(e){var t=this,r=this.workbook.definedNames;r.removeAllNames(this.fullAddress),e.forEach(function(e){r.addEx(t.fullAddress,e)})}},{key:"_dataValidations",get:function(){return this.worksheet.dataValidations}},{key:"dataValidation",get:function(){return this._dataValidations.find(this.address)},set:function(e){this._dataValidations.add(this.address,e)}},{key:"model",get:function(){var e=this._value.model;return e.style=this.style,this._comment&&(e.comment=this._comment.model),e},set:function(e){if(this._value.release(),this._value=S.create(e.type,this),this._value.model=e,e.comment)switch(e.comment.type){case"note":this._comment=f.fromModel(e.comment)}this.style=e.style?e.style:{}}}]),e}();l.Types=u.ValueType;var h=function(){function e(t){n(this,e),this.model={address:t.address,type:l.Types.Null}}return o(e,[{key:"toCsvString",value:function(){return""}},{key:"release",value:function(){}},{key:"toString",value:function(){return""}},{key:"value",get:function(){return null},set:function(e){}},{key:"type",get:function(){return l.Types.Null}},{key:"effectiveType",get:function(){return l.Types.Null}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),d=function(){function e(t,r){n(this,e),this.model={address:t.address,type:l.Types.Number,value:r}}return o(e,[{key:"toCsvString",value:function(){return this.model.value.toString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(e){this.model.value=e}},{key:"type",get:function(){return l.Types.Number}},{key:"effectiveType",get:function(){return l.Types.Number}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),p=function(){function e(t,r){n(this,e),this.model={address:t.address,type:l.Types.String,value:r}}return o(e,[{key:"toCsvString",value:function(){return'"'.concat(this.model.value.replace(/"/g,'""'),'"')}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value}},{key:"value",get:function(){return this.model.value},set:function(e){this.model.value=e}},{key:"type",get:function(){return l.Types.String}},{key:"effectiveType",get:function(){return l.Types.String}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),m=function(){function e(t,r){n(this,e),this.model={address:t.address,type:l.Types.String,value:r}}return o(e,[{key:"toString",value:function(){return this.model.value.richText.map(function(e){return e.text}).join("")}},{key:"toCsvString",value:function(){return'"'.concat(this.text.replace(/"/g,'""'),'"')}},{key:"release",value:function(){}},{key:"value",get:function(){return this.model.value},set:function(e){this.model.value=e}},{key:"type",get:function(){return l.Types.RichText}},{key:"effectiveType",get:function(){return l.Types.RichText}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),y=function(){function e(t,r){n(this,e),this.model={address:t.address,type:l.Types.Date,value:r}}return o(e,[{key:"toCsvString",value:function(){return this.model.value.toISOString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(e){this.model.value=e}},{key:"type",get:function(){return l.Types.Date}},{key:"effectiveType",get:function(){return l.Types.Date}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),b=function(){function e(t,r){n(this,e),this.model={address:t.address,type:l.Types.Hyperlink,text:r?r.text:void 0,hyperlink:r?r.hyperlink:void 0},r&&r.tooltip&&(this.model.tooltip=r.tooltip)}return o(e,[{key:"toCsvString",value:function(){return this.model.hyperlink}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.text}},{key:"value",get:function(){var e={text:this.model.text,hyperlink:this.model.hyperlink};return this.model.tooltip&&(e.tooltip=this.model.tooltip),e},set:function(e){this.model={text:e.text,hyperlink:e.hyperlink},e.tooltip&&(this.model.tooltip=e.tooltip)}},{key:"text",get:function(){return this.model.text},set:function(e){this.model.text=e}},{key:"hyperlink",get:function(){return this.model.hyperlink},set:function(e){this.model.hyperlink=e}},{key:"type",get:function(){return l.Types.Hyperlink}},{key:"effectiveType",get:function(){return l.Types.Hyperlink}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),v=function(){function e(t,r){n(this,e),this.model={address:t.address,type:l.Types.Merge,master:r?r.address:void 0},this._master=r,r&&r.addMergeRef()}return o(e,[{key:"isMergedTo",value:function(e){return e===this._master}},{key:"toCsvString",value:function(){return""}},{key:"release",value:function(){this._master.releaseMergeRef()}},{key:"toString",value:function(){return this.value.toString()}},{key:"value",get:function(){return this._master.value},set:function(e){e instanceof l?(this._master&&this._master.releaseMergeRef(),e.addMergeRef(),this._master=e):this._master.value=e}},{key:"master",get:function(){return this._master}},{key:"type",get:function(){return l.Types.Merge}},{key:"effectiveType",get:function(){return this._master.effectiveType}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),g=function(){function e(t,r){n(this,e),this.cell=t,this.model={address:t.address,type:l.Types.Formula,shareType:r?r.shareType:void 0,ref:r?r.ref:void 0,formula:r?r.formula:void 0,sharedFormula:r?r.sharedFormula:void 0,result:r?r.result:void 0}}return o(e,[{key:"_copyModel",value:function(e){var t={},r=function(r){var n=e[r];n&&(t[r]=n)};return r("formula"),r("result"),r("ref"),r("shareType"),r("sharedFormula"),t}},{key:"validate",value:function(e){switch(S.getType(e)){case l.Types.Null:case l.Types.String:case l.Types.Number:case l.Types.Date:break;case l.Types.Hyperlink:case l.Types.Formula:default:throw new Error("Cannot process that type of result value")}}},{key:"_getTranslatedFormula",value:function(){if(!this._translatedFormula&&this.model.sharedFormula){var e=this.cell.worksheet.findCell(this.model.sharedFormula);this._translatedFormula=e&&c(e.formula,e.address,this.model.address)}return this._translatedFormula}},{key:"toCsvString",value:function(){return"".concat(this.model.result||"")}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.result?this.model.result.toString():""}},{key:"value",get:function(){return this._copyModel(this.model)},set:function(e){this.model=this._copyModel(e)}},{key:"dependencies",get:function(){return{ranges:this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g),cells:this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g,"").match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g)}}},{key:"formula",get:function(){return this.model.formula||this._getTranslatedFormula()},set:function(e){this.model.formula=e}},{key:"formulaType",get:function(){return this.model.formula?u.FormulaType.Master:this.model.sharedFormula?u.FormulaType.Shared:u.FormulaType.None}},{key:"result",get:function(){return this.model.result},set:function(e){this.model.result=e}},{key:"type",get:function(){return l.Types.Formula}},{key:"effectiveType",get:function(){var e=this.model.result;return null==e?u.ValueType.Null:e instanceof String||"string"==typeof e?u.ValueType.String:"number"==typeof e?u.ValueType.Number:e instanceof Date?u.ValueType.Date:e.text&&e.hyperlink?u.ValueType.Hyperlink:e.formula?u.ValueType.Formula:u.ValueType.Null}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),w=function(){function e(t,r){n(this,e),this.model={address:t.address,type:l.Types.SharedString,value:r}}return o(e,[{key:"toCsvString",value:function(){return this.model.value.toString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(e){this.model.value=e}},{key:"type",get:function(){return l.Types.SharedString}},{key:"effectiveType",get:function(){return l.Types.SharedString}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),_=function(){function e(t,r){n(this,e),this.model={address:t.address,type:l.Types.Boolean,value:r}}return o(e,[{key:"toCsvString",value:function(){return this.model.value?1:0}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.toString()}},{key:"value",get:function(){return this.model.value},set:function(e){this.model.value=e}},{key:"type",get:function(){return l.Types.Boolean}},{key:"effectiveType",get:function(){return l.Types.Boolean}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),k=function(){function e(t,r){n(this,e),this.model={address:t.address,type:l.Types.Error,value:r}}return o(e,[{key:"toCsvString",value:function(){return this.toString()}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value.error.toString()}},{key:"value",get:function(){return this.model.value},set:function(e){this.model.value=e}},{key:"type",get:function(){return l.Types.Error}},{key:"effectiveType",get:function(){return l.Types.Error}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),x=function(){function e(t,r){n(this,e),this.model={address:t.address,type:l.Types.String,value:JSON.stringify(r),rawValue:r}}return o(e,[{key:"toCsvString",value:function(){return this.model.value}},{key:"release",value:function(){}},{key:"toString",value:function(){return this.model.value}},{key:"value",get:function(){return this.model.rawValue},set:function(e){this.model.rawValue=e,this.model.value=JSON.stringify(e)}},{key:"type",get:function(){return l.Types.String}},{key:"effectiveType",get:function(){return l.Types.String}},{key:"address",get:function(){return this.model.address},set:function(e){this.model.address=e}}]),e}(),S={getType:function(e){return null==e?l.Types.Null:e instanceof String||"string"==typeof e?l.Types.String:"number"==typeof e?l.Types.Number:"boolean"==typeof e?l.Types.Boolean:e instanceof Date?l.Types.Date:e.text&&e.hyperlink?l.Types.Hyperlink:e.formula||e.sharedFormula?l.Types.Formula:e.richText?l.Types.RichText:e.sharedString?l.Types.SharedString:e.error?l.Types.Error:l.Types.JSON},types:[{t:l.Types.Null,f:h},{t:l.Types.Number,f:d},{t:l.Types.String,f:p},{t:l.Types.Date,f:y},{t:l.Types.Hyperlink,f:b},{t:l.Types.Formula,f:g},{t:l.Types.Merge,f:v},{t:l.Types.JSON,f:x},{t:l.Types.SharedString,f:w},{t:l.Types.RichText,f:m},{t:l.Types.Boolean,f:_},{t:l.Types.Error,f:k}].reduce(function(e,t){return e[t.t]=t.f,e},[]),create:function(e,t,r){var n=this.types[e];if(!n)throw new Error("Could not create Value of type ".concat(e));return new n(t,r)}};t.exports=l},{"../utils/col-cache":19,"../utils/shared-formula":22,"../utils/under-dash":25,"./enums":7,"./note":9}],4:[function(e,t,r){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)}}var i=e("../utils/under-dash"),o=e("./enums"),a=e("../utils/col-cache"),s=function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._worksheet=t,this._number=r,!1!==n&&(this.defn=n)}var t,r,s;return t=e,s=[{key:"toModel",value:function(e){var t=[],r=null;return e&&e.forEach(function(e,n){e.isDefault?r&&(r=null):r&&e.equivalentTo(r)?r.max=n+1:t.push(r={min:n+1,max:n+1,width:void 0!==e.width?e.width:9,style:e.style,isCustomWidth:e.isCustomWidth,hidden:e.hidden,outlineLevel:e.outlineLevel,collapsed:e.collapsed})}),t.length?t:void 0}},{key:"fromModel",value:function(t,r){r=r||[];for(var n=[],i=1,o=0;o<r.length;){for(var a=r[o++];i<a.min;)n.push(new e(t,i++));for(;i<=a.max;)n.push(new e(t,i++,a))}return n.length?n:null}}],(r=[{key:"toString",value:function(){return JSON.stringify({key:this.key,width:this.width,headers:this.headers.length?this.headers:void 0})}},{key:"equivalentTo",value:function(e){return this.width===e.width&&this.hidden===e.hidden&&this.outlineLevel===e.outlineLevel&&i.isEqual(this.style,e.style)}},{key:"eachCell",value:function(e,t){var r=this.number;t||(t=e,e=null),this._worksheet.eachRow(e,function(e,n){t(e.getCell(r),n)})}},{key:"_applyStyle",value:function(e,t){return this.style[e]=t,this.eachCell(function(r){r[e]=t}),t}},{key:"number",get:function(){return this._number}},{key:"worksheet",get:function(){return this._worksheet}},{key:"letter",get:function(){return a.n2l(this._number)}},{key:"isCustomWidth",get:function(){return void 0!==this.width&&9!==this.width}},{key:"defn",get:function(){return{header:this._header,key:this.key,width:this.width,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel}},set:function(e){e?(this.key=e.key,this.width=void 0!==e.width?e.width:9,this.outlineLevel=e.outlineLevel,this.style=e.style?e.style:{},this.header=e.header,this._hidden=!!e.hidden):(delete this._header,delete this._key,delete this.width,this.style={},this.outlineLevel=0)}},{key:"headers",get:function(){return this._header&&this._header instanceof Array?this._header:[this._header]}},{key:"header",get:function(){return this._header},set:function(e){var t=this;void 0!==e?(this._header=e,this.headers.forEach(function(e,r){t._worksheet.getCell(r+1,t.number).value=e})):this._header=void 0}},{key:"key",get:function(){return this._key},set:function(e){(this._key&&this._worksheet.getColumnKey(this._key))===this&&this._worksheet.deleteColumnKey(this._key),this._key=e,e&&this._worksheet.setColumnKey(this._key,this)}},{key:"hidden",get:function(){return!!this._hidden},set:function(e){this._hidden=e}},{key:"outlineLevel",get:function(){return this._outlineLevel||0},set:function(e){this._outlineLevel=e}},{key:"collapsed",get:function(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelCol)}},{key:"isDefault",get:function(){if(this.isCustomWidth)return!1;if(this.hidden)return!1;if(this.outlineLevel)return!1;var e=this.style;return!e||!(e.font||e.numFmt||e.alignment||e.border||e.fill||e.protection)}},{key:"headerCount",get:function(){return this.headers.length}},{key:"values",get:function(){var e=[];return this.eachCell(function(t,r){t&&t.type!==o.ValueType.Null&&(e[r]=t.value)}),e},set:function(e){var t=this;if(e){var r=this.number,n=0;e.hasOwnProperty("0")&&(n=1),e.forEach(function(e,i){t._worksheet.getCell(i+n,r).value=e})}}},{key:"numFmt",get:function(){return this.style.numFmt},set:function(e){this._applyStyle("numFmt",e)}},{key:"font",get:function(){return this.style.font},set:function(e){this._applyStyle("font",e)}},{key:"alignment",get:function(){return this.style.alignment},set:function(e){this._applyStyle("alignment",e)}},{key:"protection",get:function(){return this.style.protection},set:function(e){this._applyStyle("protection",e)}},{key:"border",get:function(){return this.style.border},set:function(e){this._applyStyle("border",e)}},{key:"fill",get:function(){return this.style.fill},set:function(e){this._applyStyle("fill",e)}}])&&n(t.prototype,r),s&&n(t,s),e}();t.exports=s},{"../utils/col-cache":19,"../utils/under-dash":25,"./enums":7}],5:[function(e,t,r){var n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.model=t||{}}var t;return(t=[{key:"add",value:function(e,t){return this.model[e]=t}},{key:"find",value:function(e){return this.model[e]}},{key:"remove",value:function(e){this.model[e]=void 0}}])&&function(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.prototype,t),e}();t.exports=n},{}],6:[function(e,t,r){var n=e("../utils/under-dash"),i=e("../utils/col-cache"),o=e("../utils/cell-matrix"),a=e("./range"),s=/[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/,u=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.matrixMap={}}var t;return(t=[{key:"getMatrix",value:function(e){return this.matrixMap[e]||(this.matrixMap[e]=new o)}},{key:"add",value:function(e,t){var r=i.decodeEx(e);this.addEx(r,t)}},{key:"addEx",value:function(e,t){var r=this.getMatrix(t);if(e.top)for(var n=e.left;n<=e.right;n++)for(var o=e.top;o<=e.bottom;o++){var a={sheetName:e.sheetName,address:i.n2l(n)+o,row:o,col:n};r.addCellEx(a)}else r.addCellEx(e)}},{key:"remove",value:function(e,t){var r=i.decodeEx(e);this.removeEx(r,t)}},{key:"removeEx",value:function(e,t){this.getMatrix(t).removeCellEx(e)}},{key:"removeAllNames",value:function(e){n.each(this.matrixMap,function(t){t.removeCellEx(e)})}},{key:"forEach",value:function(e){n.each(this.matrixMap,function(t,r){t.forEach(function(t){e(r,t)})})}},{key:"getNames",value:function(e){return this.getNamesEx(i.decodeEx(e))}},{key:"getNamesEx",value:function(e){return n.map(this.matrixMap,function(t,r){return t.findCellEx(e)&&r}).filter(Boolean)}},{key:"_explore",value:function(e,t){t.mark=!1;var r,n,i=t.sheetName,o=new a(t.row,t.col,t.row,t.col,i);function s(r,n){var a=e.findCellAt(i,r,t.col);return!(!a||!a.mark||(o[n]=r,a.mark=!1,0))}for(n=t.row-1;s(n,"top");n--);for(n=t.row+1;s(n,"bottom");n++);function u(t,r){var a=[];for(n=o.top;n<=o.bottom;n++){var s=e.findCellAt(i,n,t);if(!s||!s.mark)return!1;a.push(s)}o[r]=t;for(var u=0;u<a.length;u++)a[u].mark=!1;return!0}for(r=t.col-1;u(r,"left");r--);for(r=t.col+1;u(r,"right");r++);return o}},{key:"getRanges",value:function(e,t){var r=this;return(t=t||this.matrixMap[e])?(t.forEach(function(e){e.mark=!0}),{name:e,ranges:t.map(function(e){return e.mark&&r._explore(t,e)}).filter(Boolean).map(function(e){return e.$shortRange})}):{name:e,ranges:[]}}},{key:"normaliseMatrix",value:function(e,t){e.forEachInSheet(t,function(e,t,r){e&&(e.row===t&&e.col===r||(e.row=t,e.col=r,e.address=i.n2l(r)+t))})}},{key:"spliceRows",value:function(e,t,r,i){var o=this;n.each(this.matrixMap,function(n){n.spliceRows(e,t,r,i),o.normaliseMatrix(n,e)})}},{key:"spliceColumns",value:function(e,t,r,i){var o=this;n.each(this.matrixMap,function(n){n.spliceColumns(e,t,r,i),o.normaliseMatrix(n,e)})}},{key:"model",get:function(){var e=this;return n.map(this.matrixMap,function(t,r){return e.getRanges(r,t)}).filter(function(e){return e.ranges.length})},set:function(e){var t=this.matrixMap={};e.forEach(function(e){var r=t[e.name]=new o;e.ranges.forEach(function(e){s.test(e.split("!").pop()||"")&&r.addCell(e)})})}}])&&function(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.prototype,t),e}();t.exports=u},{"../utils/cell-matrix":18,"../utils/col-cache":19,"../utils/under-dash":25,"./range":10}],7:[function(e,t,r){t.exports={ValueType:{Null:0,Merge:1,Number:2,String:3,Date:4,Hyperlink:5,Formula:6,SharedString:7,RichText:8,Boolean:9,Error:10},FormulaType:{None:0,Master:1,Shared:2},RelationshipType:{None:0,OfficeDocument:1,Worksheet:2,CalcChain:3,SharedStrings:4,Styles:5,Theme:6,Hyperlink:7},DocumentType:{Xlsx:1},ReadingOrder:{LeftToRight:1,RightToLeft:2},ErrorValue:{NotApplicable:"#N/A",Ref:"#REF!",Name:"#NAME?",DivZero:"#DIV/0!",Null:"#NULL!",Value:"#VALUE!",Num:"#NUM!"}}},{}],8:[function(e,t,r){var n=e("../utils/col-cache"),i=e("./anchor"),o=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.worksheet=t,this.model=r}var t;return(t=[{key:"model",get:function(){switch(this.type){case"background":return{type:this.type,imageId:this.imageId};case"image":return{type:this.type,imageId:this.imageId,hyperlinks:this.range.hyperlinks,range:{tl:this.range.tl.model,br:this.range.br&&this.range.br.model,ext:this.range.ext,editAs:this.range.editAs}};default:throw new Error("Invalid Image Type")}},set:function(e){var t=e.type,r=e.imageId,o=e.range,a=e.hyperlinks;if(this.type=t,this.imageId=r,"image"===t)if("string"==typeof o){var s=n.decode(o);this.range={tl:new i(this.worksheet,{col:s.left,row:s.top},-1),br:new i(this.worksheet,{col:s.right,row:s.bottom},0),editAs:"oneCell"}}else this.range={tl:new i(this.worksheet,o.tl,0),br:o.br&&new i(this.worksheet,o.br,0),ext:o.ext,editAs:o.editAs,hyperlinks:a||o.hyperlinks}}}])&&function(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.prototype,t),e}();t.exports=o},{"../utils/col-cache":19,"./anchor":2}],9:[function(e,t,r){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 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("../utils/under-dash"),a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.note=t}var t,r,a;return t=e,a=[{key:"fromModel",value:function(t){var r=new e;return r.model=t,r}}],(r=[{key:"model",get:function(){var t=null;switch(n(this.note)){case"string":t={type:"note",note:{texts:[{text:this.note}]}};break;default:t={type:"note",note:this.note}}return o.deepMerge({},e.DEFAULT_CONFIGS,t)},set:function(e){var t=e.note,r=t.texts;this.note=1===r.length&&1===Object.keys(r[0]).length?r[0].text:t}}])&&i(t.prototype,r),a&&i(t,a),e}();a.DEFAULT_CONFIGS={note:{margins:{insetmode:"auto",inset:[.13,.13,.25,.25]},protection:{locked:"True",lockText:"True"},editAs:"absolute"}},t.exports=a},{"../utils/under-dash":25}],10:[function(e,t,r){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=e("../utils/col-cache"),o=function(){function e(){n(this,e),this.decode(arguments)}var t;return(t=[{key:"setTLBR",value:function(e,t,r,n,o){if(arguments.length<4){var a=i.decodeAddress(e),s=i.decodeAddress(t);this.model={top:Math.min(a.row,s.row),left:Math.min(a.col,s.col),bottom:Math.max(a.row,s.row),right:Math.max(a.col,s.col),sheetName:r},this.setTLBR(a.row,a.col,s.row,s.col,o)}else this.model={top:Math.min(e,r),left:Math.min(t,n),bottom:Math.max(e,r),right:Math.max(t,n),sheetName:o}}},{key:"decode",value:function(t){switch(t.length){case 5:this.setTLBR(t[0],t[1],t[2],t[3],t[4]);break;case 4:this.setTLBR(t[0],t[1],t[2],t[3]);break;case 3:this.setTLBR(t[0],t[1],t[2]);break;case 2:this.setTLBR(t[0],t[1]);break;case 1:var r=t[0];if(r instanceof e)this.model={top:r.model.top,left:r.model.left,bottom:r.model.bottom,right:r.model.right,sheetName:r.sheetName};else if(r instanceof Array)this.decode(r);else if(r.top&&r.left&&r.bottom&&r.right)this.model={top:r.top,left:r.left,bottom:r.bottom,right:r.right,sheetName:r.sheetName};else{var n=i.decodeEx(r);this.model=n.top?{top:n.top,left:n.left,bottom:n.bottom,right:n.right,sheetName:n.sheetName}:{top:n.row,left:n.col,bottom:n.row,right:n.col,sheetName:n.sheetName}}break;case 0:this.model={top:0,left:0,bottom:0,right:0};break;default:throw new Error("Invalid number of arguments to _getDimensions() - ".concat(t.length))}}},{key:"expand",value:function(e,t,r,n){(!this.model.top||e<this.top)&&(this.top=e),(!this.model.left||t<this.left)&&(this.left=t),(!this.model.bottom||r>this.bottom)&&(this.bottom=r),(!this.model.right||n>this.right)&&(this.right=n)}},{key:"expandRow",value:function(e){if(e){var t=e.dimensions,r=e.number;t&&this.expand(r,t.min,r,t.max)}}},{key:"expandToAddress",value:function(e){var t=i.decodeEx(e);this.expand(t.row,t.col,t.row,t.col)}},{key:"toString",value:function(){return this.range}},{key:"intersects",value:function(e){return!(e.sheetName&&this.sheetName&&e.sheetName!==this.sheetName||e.bottom<this.top||e.top>this.bottom||e.right<this.left||e.left>this.right)}},{key:"contains",value:function(e){var t=i.decodeEx(e);return this.containsEx(t)}},{key:"containsEx",value:function(e){return(!e.sheetName||!this.sheetName||e.sheetName===this.sheetName)&&e.row>=this.top&&e.row<=this.bottom&&e.col>=this.left&&e.col<=this.right}},{key:"forEachAddress",value:function(e){for(var t=this.left;t<=this.right;t++)for(var r=this.top;r<=this.bottom;r++)e(i.encodeAddress(r,t),r,t)}},{key:"top",get:function(){return this.model.top||1},set:function(e){this.model.top=e}},{key:"left",get:function(){return this.model.left||1},set:function(e){this.model.left=e}},{key:"bottom",get:function(){return this.model.bottom||1},set:function(e){this.model.bottom=e}},{key:"right",get:function(){return this.model.right||1},set:function(e){this.model.right=e}},{key:"sheetName",get:function(){return this.model.sheetName},set:function(e){this.model.sheetName=e}},{key:"_serialisedSheetName",get:function(){var e=this.model.sheetName;return e?/^[a-zA-Z0-9]*$/.test(e)?"".concat(e,"!"):"'".concat(e,"'!"):""}},{key:"tl",get:function(){return i.n2l(this.left)+this.top}},{key:"$t$l",get:function(){return"$".concat(i.n2l(this.left),"$").concat(this.top)}},{key:"br",get:function(){return i.n2l(this.right)+this.bottom}},{key:"$b$r",get:function(){return"$".concat(i.n2l(this.right),"$").concat(this.bottom)}},{key:"range",get:function(){return"".concat(this._serialisedSheetName+this.tl,":").concat(this.br)}},{key:"$range",get:function(){return"".concat(this._serialisedSheetName+this.$t$l,":").concat(this.$b$r)}},{key:"shortRange",get:function(){return this.count>1?this.range:this._serialisedSheetName+this.tl}},{key:"$shortRange",get:function(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}},{key:"count",get:function(){return(1+this.bottom-this.top)*(1+this.right-this.left)}}])&&function(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.prototype,t),e}();t.exports=o},{"../utils/col-cache":19}],11:[function(e,t,r){var n=e("../utils/under-dash"),i=e("./enums"),o=e("../utils/col-cache"),a=e("./cell"),s=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._worksheet=t,this._number=r,this._cells=[],this.style={},this.outlineLevel=0}var t;return(t=[{key:"commit",value:function(){this._worksheet._commitRow(this)}},{key:"destroy",value:function(){delete this._worksheet,delete this._cells,delete this.style}},{key:"findCell",value:function(e){return this._cells[e-1]}},{key:"getCellEx",value:function(e){var t=this._cells[e.col-1];if(!t){var r=this._worksheet.getColumn(e.col);t=new a(this,r,e.address),this._cells[e.col-1]=t}return t}},{key:"getCell",value:function(e){if("string"==typeof e){var t=this._worksheet.getColumnKey(e);e=t?t.number:o.l2n(e)}return this._cells[e-1]||this.getCellEx({address:o.encodeAddress(this._number,e),row:this._number,col:e})}},{key:"splice",value:function(e,t){for(var r=e+t,n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];var a,s,u,c=i.length-t,f=this._cells.length;if(c<0)for(a=e+i.length;a<=f;a++)u=this._cells[a-1],(s=this._cells[a-c-1])?((u=this.getCell(a)).value=s.value,u.style=s.style,u._comment=s._comment):u&&(u.value=null,u.style={},u._comment=void 0);else if(c>0)for(a=f;a>=r;a--)(s=this._cells[a-1])?((u=this.getCell(a+c)).value=s.value,u.style=s.style,u._comment=s._comment):this._cells[a+c-1]=void 0;for(a=0;a<i.length;a++)(u=this.getCell(e+a)).value=i[a],u.style={},u._comment=void 0}},{key:"eachCell",value:function(e,t){if(t||(t=e,e=null),e&&e.includeEmpty)for(var r=this._cells.length,n=1;n<=r;n++)t(this.getCell(n),n);else this._cells.forEach(function(e,r){e&&e.type!==i.ValueType.Null&&t(e,r+1)})}},{key:"addPageBreak",value:function(e,t){var r=this._worksheet,n=Math.max(0,e-1)||0,i=Math.max(0,t-1)||16838,o={id:this._number,max:i,man:1};n&&(o.min=n),r.rowBreaks.push(o)}},{key:"_applyStyle",value:function(e,t){return this.style[e]=t,this._cells.forEach(function(r){r&&(r[e]=t)}),t}},{key:"number",get:function(){return this._number}},{key:"worksheet",get:function(){return this._worksheet}},{key:"values",get:function(){var e=[];return this._cells.forEach(function(t){t&&t.type!==i.ValueType.Null&&(e[t.col]=t.value)}),e},set:function(e){var t=this;if(this._cells=[],e)if(e instanceof Array){var r=0;e.hasOwnProperty("0")&&(r=1),e.forEach(function(e,n){void 0!==e&&(t.getCellEx({address:o.encodeAddress(t._number,n+r),row:t._number,col:n+r}).value=e)})}else this._worksheet.eachColumnKey(function(r,n){void 0!==e[n]&&(t.getCellEx({address:o.encodeAddress(t._number,r.number),row:t._number,col:r.number}).value=e[n])})}},{key:"hasValues",get:function(){return n.some(this._cells,function(e){return e&&e.type!==i.ValueType.Null})}},{key:"cellCount",get:function(){return this._cells.length}},{key:"actualCellCount",get:function(){var e=0;return this.eachCell(function(){e++}),e}},{key:"dimensions",get:function(){var e=0,t=0;return this._cells.forEach(function(r){r&&r.type!==i.ValueType.Null&&((!e||e>r.col)&&(e=r.col),t<r.col&&(t=r.col))}),e>0?{min:e,max:t}:null}},{key:"numFmt",get:function(){return this.style.numFmt},set:function(e){this._applyStyle("numFmt",e)}},{key:"font",get:function(){return this.style.font},set:function(e){this._applyStyle("font",e)}},{key:"alignment",get:function(){return this.style.alignment},set:function(e){this._applyStyle("alignment",e)}},{key:"protection",get:function(){return this.style.protection},set:function(e){this._applyStyle("protection",e)}},{key:"border",get:function(){return this.style.border},set:function(e){this._applyStyle("border",e)}},{key:"fill",get:function(){return this.style.fill},set:function(e){this._applyStyle("fill",e)}},{key:"hidden",get:function(){return!!this._hidden},set:function(e){this._hidden=e}},{key:"outlineLevel",get:function(){return this._outlineLevel||0},set:function(e){this._outlineLevel=e}},{key:"collapsed",get:function(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelRow)}},{key:"model",get:function(){var e=[],t=0,r=0;return this._cells.forEach(function(n){if(n){var i=n.model;i&&((!t||t>n.col)&&(t=n.col),r<n.col&&(r=n.col),e.push(i))}}),this.height||e.length?{cells:e,number:this.number,min:t,max:r,height:this.height,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,collapsed:this.collapsed}:null},set:function(e){var t,r=this;if(e.number!==this._number)throw new Error("Invalid row number in model");this._cells=[],e.cells.forEach(function(e){switch(e.type){case a.Types.Merge:break;default:var n;if(e.address)n=o.decodeAddress(e.address);else if(t){var i=t.row,s=t.col+1;n={row:i,col:s,address:o.encodeAddress(i,s),$col$row:"$".concat(o.n2l(s),"$").concat(i)}}t=n,r.getCellEx(n).model=e}}),e.height?this.height=e.height:delete this.height,this.hidden=e.hidden,this.outlineLevel=e.outlineLevel||0,this.style=e.style&&JSON.parse(JSON.stringify(e.style))||{}}}])&&function(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.prototype,t),e}();t.exports=s},{"../utils/col-cache":19,"../utils/under-dash":25,"./cell":3,"./enums":7}],12:[function(e,t,r){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}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)}}function o(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),e}var a=e("../utils/col-cache"),s=function(){function e(t,r,i){n(this,e),this.table=t,this.column=r,this.index=i}return o(e,[{key:"_set",value:function(e,t){this.table.cacheState(),this.column[e]=t}},{key:"name",get:function(){return this.column.name},set:function(e){this._set("name",e)}},{key:"filterButton",get:function(){return this.column.filterButton},set:function(e){this.column.filterButton=e}},{key:"style",get:function(){return this.column.style},set:function(e){this.column.style=e}},{key:"totalsRowLabel",get:function(){return this.column.totalsRowLabel},set:function(e){this._set("totalsRowLabel",e)}},{key:"totalsRowFunction",get:function(){return this.column.totalsRowFunction},set:function(e){this._set("totalsRowFunction",e)}},{key:"totalsRowResult",get:function(){return this.column.totalsRowResult},set:function(e){this._set("totalsRowResult",e)}},{key:"totalsRowFormula",get:function(){return this.column.totalsRowFormula},set:function(e){this._set("totalsRowFormula",e)}}]),e}(),u=function(){function e(t,r){n(this,e),this.worksheet=t,r&&(this.table=r,this.validate(),this.store())}return o(e,[{key:"getFormula",value:function(e){switch(e.totalsRowFunction){case"none":return null;case"average":return"SUBTOTAL(101,".concat(this.table.name,"[").concat(e.name,"])");case"countNums":return"SUBTOTAL(102,".concat(this.table.name,"[").concat(e.name,"])");case"count":return"SUBTOTAL(103,".concat(this.table.name,"[").concat(e.name,"])");case"max":return"SUBTOTAL(104,".concat(this.table.name,"[").concat(e.name,"])");case"min":return"SUBTOTAL(105,".concat(this.table.name,"[").concat(e.name,"])");case"stdDev":return"SUBTOTAL(106,".concat(this.table.name,"[").concat(e.name,"])");case"var":return"SUBTOTAL(107,".concat(this.table.name,"[").concat(e.name,"])");case"sum":return"SUBTOTAL(109,".concat(this.table.name,"[").concat(e.name,"])");case"custom":return e.totalsRowFormula;default:throw new Error("Invalid Totals Row Function: ".concat(e.totalsRowFunction))}}},{key:"validate",value:function(){var e=this,t=this.table,r=function(e,t,r){void 0===e[t]&&(e[t]=r)};r(t,"headerRow",!0),r(t,"totalsRow",!1),r(t,"style",{}),r(t.style,"theme","TableStyleMedium2"),r(t.style,"showFirstColumn",!1),r(t.style,"showLastColumn",!1),r(t.style,"showRowStripes",!1),r(t.style,"showColumnStripes",!1);var n=function(e,t){if(!e)throw new Error(t)};n(t.ref,"Table must have ref"),n(t.columns,"Table must have column definitions"),n(t.rows,"Table must have row definitions"),t.tl=a.decodeAddress(t.ref);var i=t.tl,o=i.row,s=i.col;n(o>0,"Table must be on valid row"),n(s>0,"Table must be on valid col");var u=this.width,c=this.tableHeight;t.autoFilterRef=a.encode(o,s,o+this.filterHeight-1,s+u-1),t.tableRef=a.encode(o,s,o+c-1,s+u-1),t.columns.forEach(function(t,i){n(t.name,"Column ".concat(i," must have a name")),0===i?r(t,"totalsRowLabel","Total"):(r(t,"totalsRowFunction","none"),t.totalsRowFormula=e.getFormula(t))})}},{key:"store",value:function(){var e=this,t=function(e,t){t&&Object.keys(t).forEach(function(r){e[r]=t[r]})},r=this.worksheet,n=this.table,i=n.tl,o=i.row,a=i.col,s=0;if(n.headerRow){var u=r.getRow(o+s++);n.columns.forEach(function(e,r){var n=e.style,i=e.name,o=u.getCell(a+r);o.value=i,t(o,n)})}if(n.rows.forEach(function(e){var i=r.getRow(o+s++);e.forEach(function(e,r){var o=i.getCell(a+r);o.value=e,t(o,n.columns[r].style)})}),n.totalsRow){var c=r.getRow(o+s++);n.columns.forEach(function(r,n){var i=c.getCell(a+n);if(0===n)i.value=r.totalsRowLabel;else{var o=e.getFormula(r);i.value=o?{formula:r.totalsRowFormula,result:r.totalsRowResult}:null}t(i,r.style)})}}},{key:"load",value:function(e){var t=this,r=this.table,n=r.tl,i=n.row,o=n.col,a=0;if(r.headerRow){var s=e.getRow(i+a++);r.columns.forEach(function(e,t){s.getCell(o+t).value=e.name})}if(r.rows.forEach(function(t){var r=e.getRow(i+a++);t.forEach(function(e,t){r.getCell(o+t).value=e})}),r.totalsRow){var u=e.getRow(i+a++);r.columns.forEach(function(e,r){var n=u.getCell(o+r);0===r?n.value=e.totalsRowLabel:t.getFormula(e)&&(n.value={formula:e.totalsRowFormula,result:e.totalsRowResult})})}}},{key:"cacheState",value:function(){this._cache||(this._cache={ref:this.ref,width:this.width,tableHeight:this.tableHeight})}},{key:"commit",value:function(){if(this._cache){this.validate();var e=a.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(var t=0;t<this._cache.tableHeight;t++)for(var r=this.worksheet.getRow(e.row+t),n=0;n<this._cache.width;n++)r.getCell(e.col+n).value=null;else{for(var i=this.tableHeight;i<this._cache.tableHeight;i++)for(var o=this.worksheet.getRow(e.row+i),s=0;s<this._cache.width;s++)o.getCell(e.col+s).value=null;for(var u=0;u<this.tableHeight;u++)for(var c=this.worksheet.getRow(e.row+u),f=this.width;f<this._cache.width;f++)c.getCell(e.col+f).value=null}this.store()}}},{key:"addRow",value:function(e,t){this.cacheState(),void 0===t?this.table.rows.push(e):this.table.rows.splice(t,0,e)}},{key:"removeRows",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.cacheState(),this.table.rows.splice(e,t)}},{key