UNPKG

@zurmokeeper/exceljs

Version:

Excel Workbook Manager - Read and Write xlsx and csv Files.

3 lines (2 loc) 1.12 MB
/*! ExcelJS 17-01-2025 */ !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ExcelJS=t()}}((function(){var define,module,exports;return function t(e,r,n){function i(o,a){if(!r[o]){if(!e[o]){var l="function"==typeof require&&require;if(!a&&l)return l(o,!0);if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var h=r[o]={exports:{}};e[o][0].call(h.exports,(function(t){return i(e[o][1][t]||t)}),h,h.exports,t,e,r,n)}return r[o].exports}for(var s="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}({1:[function(t,e,r){"use strict";const n=t("fs"),i=t("fast-csv"),s=t("dayjs/plugin/customParseFormat"),o=t("dayjs/plugin/utc"),a=t("dayjs").extend(s).extend(o),l=t("../utils/stream-buf"),{fs:{exists:c}}=t("../utils/utils"),h={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!"}};e.exports=class{constructor(t){this.workbook=t,this.worksheet=null}async readFile(t,e){if(e=e||{},!await c(t))throw new Error("File not found: "+t);const r=n.createReadStream(t),i=await this.read(r,e);return r.close(),i}read(t,e){return e=e||{},new Promise((r,n)=>{const s=this.workbook.addWorksheet(e.sheetName),o=e.dateFormats||["YYYY-MM-DD[T]HH:mm:ssZ","YYYY-MM-DD[T]HH:mm:ss","MM-DD-YYYY","YYYY-MM-DD"],l=e.map||function(t){if(""===t)return null;const e=Number(t);if(!Number.isNaN(e)&&e!==1/0)return e;const r=o.reduce((e,r)=>{if(e)return e;const n=a(t,r,!0);return n.isValid()?n:null},null);if(r)return new Date(r.valueOf());const n=h[t];return void 0!==n?n:t},c=i.parse(e.parserOptions).on("data",t=>{s.addRow(t.map(l))}).on("end",()=>{c.emit("worksheet",s)});c.on("worksheet",r).on("error",n),t.pipe(c)})}createInputStream(){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")}write(t,e){return new Promise((r,n)=>{e=e||{};const s=this.workbook.getWorksheet(e.sheetName||e.sheetId),o=i.format(e.formatterOptions);t.on("finish",()=>{r()}),o.on("error",n),o.pipe(t);const{dateFormat:l,dateUTC:c}=e,h=e.map||(t=>{if(t){if(t.text||t.hyperlink)return t.hyperlink||t.text||"";if(t.formula||t.result)return t.result||"";if(t instanceof Date)return l?c?a.utc(t).format(l):a(t).format(l):c?a.utc(t).format():a(t).format();if(t.error)return t.error;if("object"==typeof t)return JSON.stringify(t)}return t}),u=void 0===e.includeEmptyRows||e.includeEmptyRows;let f=1;s&&s.eachRow((t,e)=>{if(u)for(;f++<e-1;)o.write([]);const{values:r}=t;r.shift(),o.write(r.map(h)),f=e}),o.end()})}writeFile(t,e){const r={encoding:(e=e||{}).encoding||"utf8"},i=n.createWriteStream(t,r);return this.write(i,e)}async writeBuffer(t){const e=new l;return await this.write(e,t),e.read()}}},{"../utils/stream-buf":27,"../utils/utils":30,dayjs:403,"dayjs/plugin/customParseFormat":404,"dayjs/plugin/utc":405,"fast-csv":434,fs:232}],2:[function(t,e,r){"use strict";const n=t("../utils/col-cache");class i{constructor(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(this.worksheet=t,e)if("string"==typeof e){const t=n.decodeAddress(e);this.nativeCol=t.col+r,this.nativeColOff=0,this.nativeRow=t.row+r,this.nativeRowOff=0}else void 0!==e.nativeCol?(this.nativeCol=e.nativeCol||0,this.nativeColOff=e.nativeColOff||0,this.nativeRow=e.nativeRow||0,this.nativeRowOff=e.nativeRowOff||0):void 0!==e.col?(this.col=e.col+r,this.row=e.row+r):(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}static asInstance(t){return t instanceof i||null==t?t:new i(t)}get col(){return this.nativeCol+Math.min(this.colWidth-1,this.nativeColOff)/this.colWidth}set col(t){this.nativeCol=Math.floor(t),this.nativeColOff=Math.floor((t-this.nativeCol)*this.colWidth)}get row(){return this.nativeRow+Math.min(this.rowHeight-1,this.nativeRowOff)/this.rowHeight}set row(t){this.nativeRow=Math.floor(t),this.nativeRowOff=Math.floor((t-this.nativeRow)*this.rowHeight)}get colWidth(){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}get rowHeight(){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}get model(){return{nativeCol:this.nativeCol,nativeColOff:this.nativeColOff,nativeRow:this.nativeRow,nativeRowOff:this.nativeRowOff}}set model(t){this.nativeCol=t.nativeCol,this.nativeColOff=t.nativeColOff,this.nativeRow=t.nativeRow,this.nativeRowOff=t.nativeRowOff}}e.exports=i},{"../utils/col-cache":21}],3:[function(t,e,r){"use strict";const n=t("../utils/col-cache"),i=t("../utils/under-dash"),s=t("./enums"),{slideFormula:o}=t("../utils/shared-formula"),a=t("./note");class l{constructor(t,e,r){if(!t||!e)throw new Error("A Cell needs a Row");this._row=t,this._column=e,n.validateAddress(r),this._address=r,this._value=c.create(l.Types.Null,this),this.style=this._mergeStyle(t.style,e.style,{}),this._mergeCount=0}get worksheet(){return this._row.worksheet}get workbook(){return this._row.worksheet.workbook}destroy(){delete this.style,delete this._value,delete this._row,delete this._column,delete this._address}get numFmt(){return this.style.numFmt}set numFmt(t){this.style.numFmt=t}get font(){return this.style.font}set font(t){this.style.font=t}get alignment(){return this.style.alignment}set alignment(t){this.style.alignment=t}get border(){return this.style.border}set border(t){this.style.border=t}get fill(){return this.style.fill}set fill(t){this.style.fill=t}get protection(){return this.style.protection}set protection(t){this.style.protection=t}_mergeStyle(t,e,r){const n=t&&t.numFmt||e&&e.numFmt;n&&(r.numFmt=n);const i=t&&t.font||e&&e.font;i&&(r.font=i);const s=t&&t.alignment||e&&e.alignment;s&&(r.alignment=s);const o=t&&t.border||e&&e.border;o&&(r.border=o);const a=t&&t.fill||e&&e.fill;a&&(r.fill=a);const l=t&&t.protection||e&&e.protection;return l&&(r.protection=l),r}get address(){return this._address}get row(){return this._row.number}get col(){return this._column.number}get $col$row(){return`$${this._column.letter}$${this.row}`}get type(){return this._value.type}get effectiveType(){return this._value.effectiveType}toCsvString(){return this._value.toCsvString()}addMergeRef(){this._mergeCount++}releaseMergeRef(){this._mergeCount--}get isMerged(){return this._mergeCount>0||this.type===l.Types.Merge}merge(t,e){this._value.release(),this._value=c.create(l.Types.Merge,this,t),e||(this.style=t.style)}unmerge(){this.type===l.Types.Merge&&(this._value.release(),this._value=c.create(l.Types.Null,this),this.style=this._mergeStyle(this._row.style,this._column.style,{}))}isMergedTo(t){return this._value.type===l.Types.Merge&&this._value.isMergedTo(t)}get master(){return this.type===l.Types.Merge?this._value.master:this}get isHyperlink(){return this._value.type===l.Types.Hyperlink}get hyperlink(){return this._value.hyperlink}get value(){return this._value.value}set value(t){this.type!==l.Types.Merge?(this._value.release(),this._value=c.create(c.getType(t),this,t)):this._value.master.value=t}get note(){return this._comment&&this._comment.note}set note(t){this._comment=new a(t)}removeNote(){delete this._comment}get text(){return this._value.toString()}get html(){return i.escapeHtml(this.text)}toString(){return this.text}_upgradeToHyperlink(t){this.type===l.Types.String&&(this._value=c.create(l.Types.Hyperlink,this,{text:this._value.value,hyperlink:t}))}get formula(){return this._value.formula}get result(){return this._value.result}get formulaType(){return this._value.formulaType}get fullAddress(){const{worksheet:t}=this._row;return{sheetName:t.name,address:this.address,row:this.row,col:this.col}}get name(){return this.names[0]}set name(t){this.names=[t]}get names(){return this.workbook.definedNames.getNamesEx(this.fullAddress)}set names(t){const{definedNames:e}=this.workbook;e.removeAllNames(this.fullAddress),t.forEach(t=>{e.addEx(this.fullAddress,t)})}addName(t){this.workbook.definedNames.addEx(this.fullAddress,t)}removeName(t){this.workbook.definedNames.removeEx(this.fullAddress,t)}removeAllNames(){this.workbook.definedNames.removeAllNames(this.fullAddress)}get _dataValidations(){return this.worksheet.dataValidations}get dataValidation(){return this._dataValidations.find(this.address)}set dataValidation(t){this._dataValidations.add(this.address,t)}get model(){const{model:t}=this._value;return t.style=this.style,this._comment?t.comment=this._comment.model:delete t.comment,t}set model(t){if(this._value.release(),this._value=c.create(t.type,this),this._value.model=t,t.comment)switch(t.comment.type){case"note":this._comment=a.fromModel(t.comment)}t.style?this.style=i.cloneDeep(t.style):this.style={}}}l.Types=s.ValueType;const c={getType:t=>null==t?l.Types.Null:t instanceof String||"string"==typeof t?l.Types.String:"number"==typeof t?l.Types.Number:"boolean"==typeof t?l.Types.Boolean:t instanceof Date?l.Types.Date:t.text&&t.hyperlink?l.Types.Hyperlink:t.formula||t.sharedFormula?l.Types.Formula:t.richText?l.Types.RichText:t.sharedString?l.Types.SharedString:t.error?l.Types.Error:l.Types.JSON,types:[{t:l.Types.Null,f:class{constructor(t){this.model={address:t.address,type:l.Types.Null}}get value(){return null}set value(t){}get type(){return l.Types.Null}get effectiveType(){return l.Types.Null}get address(){return this.model.address}set address(t){this.model.address=t}toCsvString(){return""}release(){}toString(){return""}}},{t:l.Types.Number,f:class{constructor(t,e){this.model={address:t.address,type:l.Types.Number,value:e}}get value(){return this.model.value}set value(t){this.model.value=t}get type(){return l.Types.Number}get effectiveType(){return l.Types.Number}get address(){return this.model.address}set address(t){this.model.address=t}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}},{t:l.Types.String,f:class{constructor(t,e){this.model={address:t.address,type:l.Types.String,value:e}}get value(){return this.model.value}set value(t){this.model.value=t}get type(){return l.Types.String}get effectiveType(){return l.Types.String}get address(){return this.model.address}set address(t){this.model.address=t}toCsvString(){return`"${this.model.value.replace(/"/g,'""')}"`}release(){}toString(){return this.model.value}}},{t:l.Types.Date,f:class{constructor(t,e){this.model={address:t.address,type:l.Types.Date,value:e}}get value(){return this.model.value}set value(t){this.model.value=t}get type(){return l.Types.Date}get effectiveType(){return l.Types.Date}get address(){return this.model.address}set address(t){this.model.address=t}toCsvString(){return this.model.value.toISOString()}release(){}toString(){return this.model.value.toString()}}},{t:l.Types.Hyperlink,f:class{constructor(t,e){this.model={address:t.address,type:l.Types.Hyperlink,text:e?e.text:void 0,hyperlink:e?e.hyperlink:void 0},e&&e.tooltip&&(this.model.tooltip=e.tooltip)}get value(){const t={text:this.model.text,hyperlink:this.model.hyperlink};return this.model.tooltip&&(t.tooltip=this.model.tooltip),t}set value(t){this.model={text:t.text,hyperlink:t.hyperlink},t.tooltip&&(this.model.tooltip=t.tooltip)}get text(){return this.model.text}set text(t){this.model.text=t}get hyperlink(){return this.model.hyperlink}set hyperlink(t){this.model.hyperlink=t}get type(){return l.Types.Hyperlink}get effectiveType(){return l.Types.Hyperlink}get address(){return this.model.address}set address(t){this.model.address=t}toCsvString(){return this.model.hyperlink}release(){}toString(){return this.model.text}}},{t:l.Types.Formula,f:class{constructor(t,e){this.cell=t,this.model={address:t.address,type:l.Types.Formula,shareType:e?e.shareType:void 0,ref:e?e.ref:void 0,formula:e?e.formula:void 0,sharedFormula:e?e.sharedFormula:void 0,result:e?e.result:void 0}}_copyModel(t){const e={},r=r=>{const n=t[r];n&&(e[r]=n)};return r("formula"),r("result"),r("ref"),r("shareType"),r("sharedFormula"),e}get value(){return this._copyModel(this.model)}set value(t){this.model=this._copyModel(t)}validate(t){switch(c.getType(t)){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")}}get dependencies(){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)}}get formula(){return this.model.formula||this._getTranslatedFormula()}set formula(t){this.model.formula=t}get formulaType(){return this.model.formula?s.FormulaType.Master:this.model.sharedFormula?s.FormulaType.Shared:s.FormulaType.None}get result(){return this.model.result}set result(t){this.model.result=t}get type(){return l.Types.Formula}get effectiveType(){const t=this.model.result;return null==t?s.ValueType.Null:t instanceof String||"string"==typeof t?s.ValueType.String:"number"==typeof t?s.ValueType.Number:t instanceof Date?s.ValueType.Date:t.text&&t.hyperlink?s.ValueType.Hyperlink:t.formula?s.ValueType.Formula:s.ValueType.Null}get address(){return this.model.address}set address(t){this.model.address=t}_getTranslatedFormula(){if(!this._translatedFormula&&this.model.sharedFormula){const{worksheet:t}=this.cell,e=t.findCell(this.model.sharedFormula);this._translatedFormula=e&&o(e.formula,e.address,this.model.address)}return this._translatedFormula}toCsvString(){return""+(this.model.result||"")}release(){}toString(){return this.model.result?this.model.result.toString():""}}},{t:l.Types.Merge,f:class{constructor(t,e){this.model={address:t.address,type:l.Types.Merge,master:e?e.address:void 0},this._master=e,e&&e.addMergeRef()}get value(){return this._master.value}set value(t){t instanceof l?(this._master&&this._master.releaseMergeRef(),t.addMergeRef(),this._master=t):this._master.value=t}isMergedTo(t){return t===this._master}get master(){return this._master}get type(){return l.Types.Merge}get effectiveType(){return this._master.effectiveType}get address(){return this.model.address}set address(t){this.model.address=t}toCsvString(){return""}release(){this._master.releaseMergeRef()}toString(){return this.value.toString()}}},{t:l.Types.JSON,f:class{constructor(t,e){this.model={address:t.address,type:l.Types.String,value:JSON.stringify(e),rawValue:e}}get value(){return this.model.rawValue}set value(t){this.model.rawValue=t,this.model.value=JSON.stringify(t)}get type(){return l.Types.String}get effectiveType(){return l.Types.String}get address(){return this.model.address}set address(t){this.model.address=t}toCsvString(){return this.model.value}release(){}toString(){return this.model.value}}},{t:l.Types.SharedString,f:class{constructor(t,e){this.model={address:t.address,type:l.Types.SharedString,value:e}}get value(){return this.model.value}set value(t){this.model.value=t}get type(){return l.Types.SharedString}get effectiveType(){return l.Types.SharedString}get address(){return this.model.address}set address(t){this.model.address=t}toCsvString(){return this.model.value.toString()}release(){}toString(){return this.model.value.toString()}}},{t:l.Types.RichText,f:class{constructor(t,e){this.model={address:t.address,type:l.Types.String,value:e}}get value(){return this.model.value}set value(t){this.model.value=t}toString(){return this.model.value.richText.map(t=>t.text).join("")}get type(){return l.Types.RichText}get effectiveType(){return l.Types.RichText}get address(){return this.model.address}set address(t){this.model.address=t}toCsvString(){return`"${this.text.replace(/"/g,'""')}"`}release(){}}},{t:l.Types.Boolean,f:class{constructor(t,e){this.model={address:t.address,type:l.Types.Boolean,value:e}}get value(){return this.model.value}set value(t){this.model.value=t}get type(){return l.Types.Boolean}get effectiveType(){return l.Types.Boolean}get address(){return this.model.address}set address(t){this.model.address=t}toCsvString(){return this.model.value?1:0}release(){}toString(){return this.model.value.toString()}}},{t:l.Types.Error,f:class{constructor(t,e){this.model={address:t.address,type:l.Types.Error,value:e}}get value(){return this.model.value}set value(t){this.model.value=t}get type(){return l.Types.Error}get effectiveType(){return l.Types.Error}get address(){return this.model.address}set address(t){this.model.address=t}toCsvString(){return this.toString()}release(){}toString(){return this.model.value.error.toString()}}}].reduce((t,e)=>(t[e.t]=e.f,t),[]),create(t,e,r){const n=this.types[t];if(!n)throw new Error("Could not create Value of type "+t);return new n(e,r)}};e.exports=l},{"../utils/col-cache":21,"../utils/shared-formula":26,"../utils/under-dash":29,"./enums":8,"./note":10}],4:[function(t,e,r){"use strict";const n=t("../utils/under-dash"),i=t("./enums"),s=t("../utils/col-cache");class o{constructor(t,e,r){this._worksheet=t,this._number=e,!1!==r&&(this.defn=r)}get number(){return this._number}get worksheet(){return this._worksheet}get letter(){return s.n2l(this._number)}get isCustomWidth(){return void 0!==this.width&&9!==this.width}get defn(){return{header:this._header,key:this.key,width:this.width,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel}}set defn(t){t?(this.key=t.key,this.width=void 0!==t.width?t.width:9,this.outlineLevel=t.outlineLevel,t.style?this.style=t.style:this.style={},this.header=t.header,this._hidden=!!t.hidden):(delete this._header,delete this._key,delete this.width,this.style={},this.outlineLevel=0)}get headers(){return this._header&&this._header instanceof Array?this._header:[this._header]}get header(){return this._header}set header(t){void 0!==t?(this._header=t,this.headers.forEach((t,e)=>{this._worksheet.getCell(e+1,this.number).value=t})):this._header=void 0}get key(){return this._key}set key(t){(this._key&&this._worksheet.getColumnKey(this._key))===this&&this._worksheet.deleteColumnKey(this._key),this._key=t,t&&this._worksheet.setColumnKey(this._key,this)}get hidden(){return!!this._hidden}set hidden(t){this._hidden=t}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(t){this._outlineLevel=t}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelCol)}toString(){return JSON.stringify({key:this.key,width:this.width,headers:this.headers.length?this.headers:void 0})}equivalentTo(t){return this.width===t.width&&this.hidden===t.hidden&&this.outlineLevel===t.outlineLevel&&n.isEqual(this.style,t.style)}get isDefault(){if(this.isCustomWidth)return!1;if(this.hidden)return!1;if(this.outlineLevel)return!1;const t=this.style;return!t||!(t.font||t.numFmt||t.alignment||t.border||t.fill||t.protection)}get headerCount(){return this.headers.length}eachCell(t,e){const r=this.number;e||(e=t,t=null),this._worksheet.eachRow(t,(t,n)=>{e(t.getCell(r),n)})}get values(){const t=[];return this.eachCell((e,r)=>{e&&e.type!==i.ValueType.Null&&(t[r]=e.value)}),t}set values(t){if(!t)return;const e=this.number;let r=0;t.hasOwnProperty("0")&&(r=1),t.forEach((t,n)=>{this._worksheet.getCell(n+r,e).value=t})}addPageBreak(t,e){const r=this._worksheet,n=Math.max(0,t-1)||0,i=Math.max(0,e-1)||65535,s={id:this._number,max:i,man:1};n&&(s.min=n),r.colBreaks.push(s)}_applyStyle(t,e){return this.style[t]=e,this.eachCell(r=>{r[t]=e}),e}get numFmt(){return this.style.numFmt}set numFmt(t){this._applyStyle("numFmt",t)}get font(){return this.style.font}set font(t){this._applyStyle("font",t)}get alignment(){return this.style.alignment}set alignment(t){this._applyStyle("alignment",t)}get protection(){return this.style.protection}set protection(t){this._applyStyle("protection",t)}get border(){return this.style.border}set border(t){this._applyStyle("border",t)}get fill(){return this.style.fill}set fill(t){this._applyStyle("fill",t)}static toModel(t){const e=[];let r=null;return t&&t.forEach((t,n)=>{t.isDefault?r&&(r=null):r&&t.equivalentTo(r)?r.max=n+1:(r={min:n+1,max:n+1,width:void 0!==t.width?t.width:9,style:t.style,isCustomWidth:t.isCustomWidth,hidden:t.hidden,outlineLevel:t.outlineLevel,collapsed:t.collapsed},e.push(r))}),e.length?e:void 0}static fromModel(t,e){const r=[];let n=1,i=0;for(e=(e=e||[]).sort((function(t,e){return t.min-e.min}));i<e.length;){const s=e[i++];for(;n<s.min;)r.push(new o(t,n++));for(;n<=s.max;)r.push(new o(t,n++,s))}return r.length?r:null}}e.exports=o},{"../utils/col-cache":21,"../utils/under-dash":29,"./enums":8}],5:[function(t,e,r){"use strict";e.exports=class{constructor(t){this.model=t||{}}add(t,e){return this.model[t]=e}find(t){return this.model[t]}remove(t){this.model[t]=void 0}}},{}],6:[function(t,e,r){"use strict";const n=t("../utils/under-dash"),i=t("../utils/col-cache"),s=t("../utils/cell-matrix"),o=t("./range"),a=/[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;e.exports=class{constructor(){this.matrixMap={}}getMatrix(t){return this.matrixMap[t]||(this.matrixMap[t]=new s)}add(t,e){const r=i.decodeEx(t);this.addEx(r,e)}addEx(t,e){const r=this.getMatrix(e);if(t.top)for(let e=t.left;e<=t.right;e++)for(let n=t.top;n<=t.bottom;n++){const s={sheetName:t.sheetName,address:i.n2l(e)+n,row:n,col:e};r.addCellEx(s)}else r.addCellEx(t)}remove(t,e){const r=i.decodeEx(t);this.removeEx(r,e)}removeEx(t,e){this.getMatrix(e).removeCellEx(t)}removeAllNames(t){n.each(this.matrixMap,e=>{e.removeCellEx(t)})}forEach(t){n.each(this.matrixMap,(e,r)=>{e.forEach(e=>{t(r,e)})})}getNames(t){return this.getNamesEx(i.decodeEx(t))}getNamesEx(t){return n.map(this.matrixMap,(e,r)=>e.findCellEx(t)&&r).filter(Boolean)}_explore(t,e){e.mark=!1;const{sheetName:r}=e,n=new o(e.row,e.col,e.row,e.col,r);let i,s;function a(i,s){const o=t.findCellAt(r,i,e.col);return!(!o||!o.mark)&&(n[s]=i,o.mark=!1,!0)}for(s=e.row-1;a(s,"top");s--);for(s=e.row+1;a(s,"bottom");s++);function l(e,i){const o=[];for(s=n.top;s<=n.bottom;s++){const n=t.findCellAt(r,s,e);if(!n||!n.mark)return!1;o.push(n)}n[i]=e;for(let t=0;t<o.length;t++)o[t].mark=!1;return!0}for(i=e.col-1;l(i,"left");i--);for(i=e.col+1;l(i,"right");i++);return n}getRanges(t,e){if(!(e=e||this.matrixMap[t]))return{name:t,ranges:[]};e.forEach(t=>{t.mark=!0});return{name:t,ranges:e.map(t=>t.mark&&this._explore(e,t)).filter(Boolean).map(t=>t.$shortRange)}}normaliseMatrix(t,e){t.forEachInSheet(e,(t,e,r)=>{t&&(t.row===e&&t.col===r||(t.row=e,t.col=r,t.address=i.n2l(r)+e))})}spliceRows(t,e,r,i){n.each(this.matrixMap,n=>{n.spliceRows(t,e,r,i),this.normaliseMatrix(n,t)})}spliceColumns(t,e,r,i){n.each(this.matrixMap,n=>{n.spliceColumns(t,e,r,i),this.normaliseMatrix(n,t)})}get model(){return n.map(this.matrixMap,(t,e)=>this.getRanges(e,t)).filter(t=>t.ranges.length)}set model(t){const e=this.matrixMap={};t.forEach(t=>{const r=e[t.name]=new s;t.ranges.forEach(t=>{a.test(t.split("!").pop()||"")&&r.addCell(t)})})}}},{"../utils/cell-matrix":20,"../utils/col-cache":21,"../utils/under-dash":29,"./range":11}],7:[function(t,e,r){"use strict";const n=t("../utils/col-cache"),i=t("./anchor");e.exports={parseRange:(t,e,r)=>{if("string"==typeof t){const e=n.decode(t);return{tl:new i(r,{col:e.left,row:e.top},-1),br:new i(r,{col:e.right,row:e.bottom},0),editAs:"oneCell"}}return{tl:new i(r,t.tl,0),br:t.br&&new i(r,t.br,0),ext:t.ext,editAs:t.editAs,hyperlinks:e||t.hyperlinks}}}},{"../utils/col-cache":21,"./anchor":2}],8:[function(t,e,r){"use strict";e.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!"}}},{}],9:[function(t,e,r){"use strict";const{parseRange:n}=t("./drawing-range");e.exports=class{constructor(t,e){this.worksheet=t,this.model=e}get model(){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 model(t){let{type:e,imageId:r,range:i,hyperlinks:s}=t;this.type=e,this.imageId=r,"image"===e&&(this.range=n(i,s,this.worksheet))}}},{"./drawing-range":7}],10:[function(t,e,r){"use strict";const n=t("../utils/under-dash");class i{constructor(t){this.note=t}get model(){let t=null;switch(typeof this.note){case"string":t={type:"note",note:{texts:[{text:this.note}]}};break;default:t={type:"note",note:this.note}}return n.deepMerge({},i.DEFAULT_CONFIGS,t)}set model(t){const{note:e}=t,{texts:r}=e;1===r.length&&1===Object.keys(r[0]).length?this.note=r[0].text:this.note=e}static fromModel(t){const e=new i;return e.model=t,e}}i.DEFAULT_CONFIGS={note:{margins:{insetmode:"auto",inset:[.13,.13,.25,.25]},protection:{locked:"True",lockText:"True"},editAs:"absolute"}},e.exports=i},{"../utils/under-dash":29}],11:[function(t,e,r){"use strict";const n=t("../utils/col-cache");class i{constructor(){this.decode(arguments)}setTLBR(t,e,r,i,s){if(arguments.length<4){const i=n.decodeAddress(t),o=n.decodeAddress(e);this.model={top:Math.min(i.row,o.row),left:Math.min(i.col,o.col),bottom:Math.max(i.row,o.row),right:Math.max(i.col,o.col),sheetName:r},this.setTLBR(i.row,i.col,o.row,o.col,s)}else this.model={top:Math.min(t,r),left:Math.min(e,i),bottom:Math.max(t,r),right:Math.max(e,i),sheetName:s}}decode(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:{const e=t[0];if(e instanceof i)this.model={top:e.model.top,left:e.model.left,bottom:e.model.bottom,right:e.model.right,sheetName:e.sheetName};else if(e instanceof Array)this.decode(e);else if(e.top&&e.left&&e.bottom&&e.right)this.model={top:e.top,left:e.left,bottom:e.bottom,right:e.right,sheetName:e.sheetName};else{const t=n.decodeEx(e);t.top?this.model={top:t.top,left:t.left,bottom:t.bottom,right:t.right,sheetName:t.sheetName}:this.model={top:t.row,left:t.col,bottom:t.row,right:t.col,sheetName:t.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() - "+t.length)}}get top(){return this.model.top||1}set top(t){this.model.top=t}get left(){return this.model.left||1}set left(t){this.model.left=t}get bottom(){return this.model.bottom||1}set bottom(t){this.model.bottom=t}get right(){return this.model.right||1}set right(t){this.model.right=t}get sheetName(){return this.model.sheetName}set sheetName(t){this.model.sheetName=t}get _serialisedSheetName(){const{sheetName:t}=this.model;return t?/^[a-zA-Z0-9]*$/.test(t)?t+"!":`'${t}'!`:""}expand(t,e,r,n){(!this.model.top||t<this.top)&&(this.top=t),(!this.model.left||e<this.left)&&(this.left=e),(!this.model.bottom||r>this.bottom)&&(this.bottom=r),(!this.model.right||n>this.right)&&(this.right=n)}expandRow(t){if(t){const{dimensions:e,number:r}=t;e&&this.expand(r,e.min,r,e.max)}}expandToAddress(t){const e=n.decodeEx(t);this.expand(e.row,e.col,e.row,e.col)}get tl(){return n.n2l(this.left)+this.top}get $t$l(){return`$${n.n2l(this.left)}$${this.top}`}get br(){return n.n2l(this.right)+this.bottom}get $b$r(){return`$${n.n2l(this.right)}$${this.bottom}`}get range(){return`${this._serialisedSheetName+this.tl}:${this.br}`}get $range(){return`${this._serialisedSheetName+this.$t$l}:${this.$b$r}`}get shortRange(){return this.count>1?this.range:this._serialisedSheetName+this.tl}get $shortRange(){return this.count>1?this.$range:this._serialisedSheetName+this.$t$l}get count(){return(1+this.bottom-this.top)*(1+this.right-this.left)}toString(){return this.range}intersects(t){return(!t.sheetName||!this.sheetName||t.sheetName===this.sheetName)&&(!(t.bottom<this.top)&&(!(t.top>this.bottom)&&(!(t.right<this.left)&&!(t.left>this.right))))}contains(t){const e=n.decodeEx(t);return this.containsEx(e)}containsEx(t){return(!t.sheetName||!this.sheetName||t.sheetName===this.sheetName)&&(t.row>=this.top&&t.row<=this.bottom&&t.col>=this.left&&t.col<=this.right)}forEachAddress(t){for(let e=this.left;e<=this.right;e++)for(let r=this.top;r<=this.bottom;r++)t(n.encodeAddress(r,e),r,e)}}e.exports=i},{"../utils/col-cache":21}],12:[function(t,e,r){"use strict";const n=t("../utils/under-dash"),i=t("./enums"),s=t("../utils/col-cache"),o=t("./cell");e.exports=class{constructor(t,e){this._worksheet=t,this._number=e,this._cells=[],this.style={},this.outlineLevel=0}get number(){return this._number}get worksheet(){return this._worksheet}commit(){this._worksheet._commitRow(this)}destroy(){delete this._worksheet,delete this._cells,delete this.style}findCell(t){return this._cells[t-1]}getCellEx(t){let e=this._cells[t.col-1];if(!e){const r=this._worksheet.getColumn(t.col);e=new o(this,r,t.address),this._cells[t.col-1]=e}return e}getCell(t){if("string"==typeof t){const e=this._worksheet.getColumnKey(t);t=e?e.number:s.l2n(t)}return this._cells[t-1]||this.getCellEx({address:s.encodeAddress(this._number,t),row:this._number,col:t})}splice(t,e){const r=t+e;for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];const o=i.length-e,a=this._cells.length;let l,c,h;if(o<0)for(l=t+i.length;l<=a;l++)h=this._cells[l-1],c=this._cells[l-o-1],c?(h=this.getCell(l),h.value=c.value,h.style=c.style,h._comment=c._comment):h&&(h.value=null,h.style={},h._comment=void 0);else if(o>0)for(l=a;l>=r;l--)c=this._cells[l-1],c?(h=this.getCell(l+o),h.value=c.value,h.style=c.style,h._comment=c._comment):this._cells[l+o-1]=void 0;for(l=0;l<i.length;l++)h=this.getCell(t+l),h.value=i[l],h.style={},h._comment=void 0}eachCell(t,e){if(e||(e=t,t=null),t&&t.includeEmpty){const t=this._cells.length;for(let r=1;r<=t;r++)e(this.getCell(r),r)}else this._cells.forEach((t,r)=>{t&&t.type!==i.ValueType.Null&&e(t,r+1)})}addPageBreak(t,e){const r=this._worksheet,n=Math.max(0,t-1)||0,i=Math.max(0,e-1)||16838,s={id:this._number,max:i,man:1};n&&(s.min=n),r.rowBreaks.push(s)}get values(){const t=[];return this._cells.forEach(e=>{e&&e.type!==i.ValueType.Null&&(t[e.col]=e.value)}),t}set values(t){if(this._cells=[],t)if(t instanceof Array){let e=0;t.hasOwnProperty("0")&&(e=1),t.forEach((t,r)=>{void 0!==t&&(this.getCellEx({address:s.encodeAddress(this._number,r+e),row:this._number,col:r+e}).value=t)})}else this._worksheet.eachColumnKey((e,r)=>{void 0!==t[r]&&(this.getCellEx({address:s.encodeAddress(this._number,e.number),row:this._number,col:e.number}).value=t[r])});else;}get hasValues(){return n.some(this._cells,t=>t&&t.type!==i.ValueType.Null)}get cellCount(){return this._cells.length}get actualCellCount(){let t=0;return this.eachCell(()=>{t++}),t}get dimensions(){let t=0,e=0;return this._cells.forEach(r=>{r&&r.type!==i.ValueType.Null&&((!t||t>r.col)&&(t=r.col),e<r.col&&(e=r.col))}),t>0?{min:t,max:e}:null}_applyStyle(t,e){return this.style[t]=e,this._cells.forEach(r=>{r&&(r[t]=e)}),e}get numFmt(){return this.style.numFmt}set numFmt(t){this._applyStyle("numFmt",t)}get font(){return this.style.font}set font(t){this._applyStyle("font",t)}get alignment(){return this.style.alignment}set alignment(t){this._applyStyle("alignment",t)}get protection(){return this.style.protection}set protection(t){this._applyStyle("protection",t)}get border(){return this.style.border}set border(t){this._applyStyle("border",t)}get fill(){return this.style.fill}set fill(t){this._applyStyle("fill",t)}get hidden(){return!!this._hidden}set hidden(t){this._hidden=t}get outlineLevel(){return this._outlineLevel||0}set outlineLevel(t){this._outlineLevel=t}get collapsed(){return!!(this._outlineLevel&&this._outlineLevel>=this._worksheet.properties.outlineLevelRow)}get model(){const t=[];let e=0,r=0;return this._cells.forEach(n=>{if(n){const i=n.model;i&&((!e||e>n.col)&&(e=n.col),r<n.col&&(r=n.col),t.push(i))}}),this.height||t.length?{cells:t,number:this.number,min:e,max:r,height:this.height,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,collapsed:this.collapsed}:null}set model(t){if(t.number!==this._number)throw new Error("Invalid row number in model");let e;this._cells=[],t.cells.forEach(t=>{switch(t.type){case o.Types.Merge:break;default:{let r;if(t.address)r=s.decodeAddress(t.address);else if(e){const{row:t}=e,n=e.col+1;r={row:t,col:n,address:s.encodeAddress(t,n),$col$row:`$${s.n2l(n)}$${t}`}}e=r;this.getCellEx(r).model=t;break}}}),t.height?this.height=t.height:delete this.height,this.hidden=t.hidden,this.outlineLevel=t.outlineLevel||0,this.style=t.style&&JSON.parse(JSON.stringify(t.style))||{}}}},{"../utils/col-cache":21,"../utils/under-dash":29,"./cell":3,"./enums":8}],13:[function(t,e,r){"use strict";const{parseRange:n}=t("./drawing-range");function i(t){if("string"==typeof t)return{runs:[s(t)]};if(Array.isArray(t))return{runs:t.map(s)};const e={runs:t.runs.map(s)};return t.alignment&&(e.alignment=t.alignment),e}function s(t){if("string"==typeof t)return{text:t};const e={text:t.text};return t.font&&(e.font=t.font),e}e.exports=class{constructor(t,e){this.worksheet=t,this.model=e}get model(){return{props:{type:this.props.type,rotation:this.props.rotation,horizontalFlip:this.props.horizontalFlip,verticalFlip:this.props.verticalFlip,fill:this.props.fill,outline:this.props.outline,textBody:this.props.textBody},range:{tl:this.range.tl.model,br:this.range.br&&this.range.br.model,ext:this.range.ext,editAs:this.range.editAs},hyperlinks:this.hyperlinks}}set model(t){let{props:e,range:r,hyperlinks:s}=t;this.props={type:e.type},e.rotation&&(this.props.rotation=e.rotation),e.horizontalFlip&&(this.props.horizontalFlip=e.horizontalFlip),e.verticalFlip&&(this.props.verticalFlip=e.verticalFlip),e.fill&&(this.props.fill=e.fill),e.outline&&(this.props.outline=e.outline),e.textBody&&(this.props.textBody=function(t){if("string"==typeof t)return{paragraphs:[i(t)]};if(Array.isArray(t))return{paragraphs:t.map(i)};const e={paragraphs:t.paragraphs.map(i)};t.vertAlign&&(e.vertAlign=t.vertAlign);return e}(e.textBody)),this.range=n(r,void 0,this.worksheet),this.hyperlinks=s}}},{"./drawing-range":7}],14:[function(t,e,r){"use strict";const n=t("../utils/col-cache");class i{constructor(t,e,r){this.table=t,this.column=e,this.index=r}_set(t,e){this.table.cacheState(),this.column[t]=e}get name(){return this.column.name}set name(t){this._set("name",t)}get filterButton(){return this.column.filterButton}set filterButton(t){this.column.filterButton=t}get style(){return this.column.style}set style(t){this.column.style=t}get totalsRowLabel(){return this.column.totalsRowLabel}set totalsRowLabel(t){this._set("totalsRowLabel",t)}get totalsRowFunction(){return this.column.totalsRowFunction}set totalsRowFunction(t){this._set("totalsRowFunction",t)}get totalsRowResult(){return this.column.totalsRowResult}set totalsRowResult(t){this._set("totalsRowResult",t)}get totalsRowFormula(){return this.column.totalsRowFormula}set totalsRowFormula(t){this._set("totalsRowFormula",t)}}e.exports=class{constructor(t,e){this.worksheet=t,e&&(this.table=e,this.validate(),this.store())}getFormula(t){switch(t.totalsRowFunction){case"none":return null;case"average":return`SUBTOTAL(101,${this.table.name}[${t.name}])`;case"countNums":return`SUBTOTAL(102,${this.table.name}[${t.name}])`;case"count":return`SUBTOTAL(103,${this.table.name}[${t.name}])`;case"max":return`SUBTOTAL(104,${this.table.name}[${t.name}])`;case"min":return`SUBTOTAL(105,${this.table.name}[${t.name}])`;case"stdDev":return`SUBTOTAL(106,${this.table.name}[${t.name}])`;case"var":return`SUBTOTAL(107,${this.table.name}[${t.name}])`;case"sum":return`SUBTOTAL(109,${this.table.name}[${t.name}])`;case"custom":return t.totalsRowFormula;default:throw new Error("Invalid Totals Row Function: "+t.totalsRowFunction)}}get width(){return this.table.columns.length}get height(){return this.table.rows.length}get filterHeight(){return this.height+(this.table.headerRow?1:0)}get tableHeight(){return this.filterHeight+(this.table.totalsRow?1:0)}validate(){const{table:t}=this,e=(t,e,r)=>{void 0===t[e]&&(t[e]=r)};e(t,"headerRow",!0),e(t,"totalsRow",!1),e(t,"style",{}),e(t.style,"theme","TableStyleMedium2"),e(t.style,"showFirstColumn",!1),e(t.style,"showLastColumn",!1),e(t.style,"showRowStripes",!1),e(t.style,"showColumnStripes",!1);const r=(t,e)=>{if(!t)throw new Error(e)};r(t.ref,"Table must have ref"),r(t.columns,"Table must have column definitions"),r(t.rows,"Table must have row definitions"),t.tl=n.decodeAddress(t.ref);const{row:i,col:s}=t.tl;r(i>0,"Table must be on valid row"),r(s>0,"Table must be on valid col");const{width:o,filterHeight:a,tableHeight:l}=this;t.autoFilterRef=n.encode(i,s,i+a-1,s+o-1),t.tableRef=n.encode(i,s,i+l-1,s+o-1),t.columns.forEach((t,n)=>{r(t.name,`Column ${n} must have a name`),0===n?e(t,"totalsRowLabel","Total"):(e(t,"totalsRowFunction","none"),t.totalsRowFormula=this.getFormula(t))})}store(){const t=(t,e)=>{e&&Object.keys(e).forEach(r=>{t[r]=e[r]})},{worksheet:e,table:r}=this,{row:n,col:i}=r.tl;let s=0;if(r.headerRow){const o=e.getRow(n+s++);r.columns.forEach((e,r)=>{const{style:n,name:s}=e,a=o.getCell(i+r);a.value=s,t(a,n)})}if(r.rows.forEach(o=>{const a=e.getRow(n+s++);o.forEach((e,n)=>{const s=a.getCell(i+n);s.value=e,t(s,r.columns[n].style)})}),r.totalsRow){const o=e.getRow(n+s++);r.columns.forEach((e,r)=>{const n=o.getCell(i+r);if(0===r)n.value=e.totalsRowLabel;else{const t=this.getFormula(e);n.value=t?{formula:e.totalsRowFormula,result:e.totalsRowResult}:null}t(n,e.style)})}}load(t){const{table:e}=this,{row:r,col:n}=e.tl;let i=0;if(e.headerRow){const s=t.getRow(r+i++);e.columns.forEach((t,e)=>{s.getCell(n+e).value=t.name})}if(e.rows.forEach(e=>{const s=t.getRow(r+i++);e.forEach((t,e)=>{s.getCell(n+e).value=t})}),e.totalsRow){const s=t.getRow(r+i++);e.columns.forEach((t,e)=>{const r=s.getCell(n+e);if(0===e)r.value=t.totalsRowLabel;else{this.getFormula(t)&&(r.value={formula:t.totalsRowFormula,result:t.totalsRowResult})}})}}get model(){return this.table}set model(t){this.table=t}cacheState(){this._cache||(this._cache={ref:this.ref,width:this.width,tableHeight:this.tableHeight})}commit(){if(!this._cache)return;this.validate();const t=n.decodeAddress(this._cache.ref);if(this.ref!==this._cache.ref)for(let e=0;e<this._cache.tableHeight;e++){const r=this.worksheet.getRow(t.row+e);for(let e=0;e<this._cache.width;e++){r.getCell(t.col+e).value=null}}else{for(let e=this.tableHeight;e<this._cache.tableHeight;e++){const r=this.worksheet.getRow(t.row+e);for(let e=0;e<this._cache.width;e++){r.getCell(t.col+e).value=null}}for(let e=0;e<this.tableHeight;e++){const r=this.worksheet.getRow(t.row+e);for(let e=this.width;e<this._cache.width;e++){r.getCell(t.col+e).value=null}}}this.store()}addRow(t,e){this.cacheState(),void 0===e?this.table.rows.push(t):this.table.rows.splice(e,0,t)}removeRows(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.cacheState(),this.table.rows.splice(t,e)}getColumn(t){const e=this.table.columns[t];return new i(this,e,t)}addColumn(t,e,r){this.cacheState(),void 0===r?(this.table.columns.push(t),this.table.rows.forEach((t,r)=>{t.push(e[r])})):(this.table.columns.splice(r,0,t),this.table.rows.forEach((t,n)=>{t.splice(r,0,e[n])}))}removeColumns(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.cacheState(),this.table.columns.splice(t,e),this.table.rows.forEach(r=>{r.splice(t,e)})}_assign(t,e,r){this.cacheState(),t[e]=r}get ref(){return this.table.ref}set ref(t){this._assign(this.table,"ref",t)}get name(){return this.table.name}set name(t){this.table.name=t}get displayName(){return this.table.displyName||this.table.name}set displayNamename(t){this.table.displayName=t}get headerRow(){return this.table.headerRow}set headerRow(t){this._assign(this.table,"headerRow",t)}get totalsRow(){return this.table.totalsRow}set totalsRow(t){this._assign(this.table,"totalsRow",t)}get theme(){return this.table.style.name}set theme(t){this.table.style.name=t}get showFirstColumn(){return this.table.style.showFirstColumn}set showFirstColumn(t){this.table.style.showFirstColumn=t}get showLastColumn(){return this.table.style.showLastColumn}set showLastColumn(t){this.table.style.showLastColumn=t}get showRowStripes(){return this.table.style.showRowStripes}set showRowStripes(t){this.table.style.showRowStripes=t}get showColumnStripes(){return this.table.style.showColumnStripes}set showColumnStripes(t){this.table.style.showColumnStripes=t}}},{"../utils/col-cache":21}],15:[function(t,e,r){"use strict";const n=t("./worksheet"),i=t("./defined-names"),s=t("../xlsx/xlsx"),o=t("../csv/csv");e.exports=class{constructor(){this.category="",this.company="",this.created=new Date,this.description="",this.keywords="",this.manager="",this.modified=this.created,this.properties={},this.calcProperties={},this._worksheets=[],this.subject="",this.title="",this.views=[],this.media=[],this._definedNames=new i}get xlsx(){return this._xlsx||(this._xlsx=new s(this)),this._xlsx}get csv(){return this._csv||(this._csv=new o(this)),this._csv}get nextId(){for(let t=1;t<this._worksheets.length;t++)if(!this._worksheets[t])return t;return this._worksheets.length||1}addWorksheet(t,e){const r=this.nextId;e&&("string"==typeof e?(console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }'),e={properties:{tabColor:{argb:e}}}):(e.argb||e.theme||e.indexed)&&(console.trace("tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }"),e={properties:{tabColor:e}}));const i=this._worksheets.reduce((t,e)=>(e&&e.orderNo)>t?e.orderNo:t,0),s=Object.assign({},e,{id:r,name:t,orderNo:i+1,workbook:this}),o=new n(s);return this._worksheets[r]=o,o}removeWorksheetEx(t){delete this._worksheets[t.id]}removeWorksheet(t){const e=this.getWorksheet(t);e&&e.destroy()}getWorksheet(t){return void 0===t?this._worksheets.find(Boolean):"number"==typeof t?this._worksheets[t]:"string"==typeof t?this._worksheets.find(e=>e&&e.name===t):void 0}get worksheets(){return this._worksheets.slice(1).sort((t,e)=>t.orderNo-e.orderNo).filter(Boolean)}eachSheet(t){this.worksheets.forEach(e=>{t(e,e.id)})}get definedNames(){return this._definedNames}clearThemes(){this._themes=void 0}addImage(t){const e=this.media.length;return this.media.push(Object.assign({},t,{type:"image"})),e}getImage(t){return this.media[t]}get model(){return{creator:this.creator||"Unknown",lastModifiedBy:this.lastModifiedBy||"Unknown",lastPrinted:this.lastPrinted,created:this.created,modified:this.modified,properties:this.properties,worksheets:this.worksheets.map(t=>t.model),sheets:this.worksheets.map(t=>t.model).filter(Boolean),definedNames:this._definedNames.model,views:this.views,company:this.company,manager:this.manager,title:this.title,subject:this.subject,keywords:this.keywords,category:this.category,description:this.description,language:this.language,revision:this.revision,contentStatus:this.contentStatus,themes:this._themes,media:this.media,calcProperties:this.calcProperties}}set model(t){this.creator=t.creator,this.lastModifiedBy=t.lastModifiedBy,this.lastPrinted=t.lastPrinted,this.created=t.created,this.modified=t.modified,this.company=t.company,this.manager=t.manager,this.title=t.title,this.subject=t.subject,this.keywords=t.keywords,this.category=t.category,this.description=t.description,this.language=t.language,this.revision=t.revision,this.contentStatus=t.contentStatus,this.properties=t.properties,this.calcProperties=t.calcProperties,this._worksheets=[],t.worksheets.forEach(e=>{const{id:r,name:i,state:s}=e,o=t.sheets&&t.sheets.findIndex(t=>t.id===r);(this._worksheets[r]=new n({id:r,name:i,orderNo:o,state:s,workbook:this})).model=e}),this._definedNames.model=t.definedNames,this.views=t.views,this._themes=t.themes,this.media=t.media||[]}}},{"../csv/csv":1,"../xlsx/xlsx":160,"./defined-names":6,"./worksheet":16}],16:[function(t,e,r){"use strict";const n=t("../utils/under-dash"),i=t("../utils/col-cache"),s=t("./range"),o=t("./row"),a=t("./column"),l=t("./enums"),c=t("./image"),h=t("./shape"),u=t("./table"),f=t("./data-validations"),d=t("../utils/encryptor"),{copyStyle:p}=t("../utils/copy-style"),m=t("../utils/column-flatter");e.exports=class{constructor(t){t=t||{},this._workbook=t.workbook,this.id=t.id,this.orderNo=t.orderNo,this.name=t.name,this.state=t.state||"visible",this._rows=[],this._columns=null,this._keys={},this._merges={},this.rowBreaks=[],this.colBreaks=[],this.properties=Object.assign({},{defaultRowHeight:15,dyDescent:55,outlineLevelCol:0,outlineLevelRow:0},t.properties),this.pageSetup=Object.assign({},{margins:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3},orientation:"portrait",horizontalDpi:4294967295,verticalDpi:4294967295,fitToPage:!(!t.pageSetup||!t.pageSetup.fitToWidth&&!t.pageSetup.fitToHeight||t.pageSetup.scale),pageOrder:"downThenOver",blackAndWhite:!1,draft:!1,cellComments:"None",errors:"displayed",scale:100,fitToWidth:1,fitToHeight:1,paperSize:void 0,showRowColHeaders:!1,showGridLines:!1,firstPageNumber:void 0,horizontalCentered:!1,verticalCentered:!1,rowBreaks:null,colBreaks:null},t.pageSetup),this.headerFooter=Object.assign({},{differentFirst:!1,differentOddEven:!1,oddHeader:null,oddFooter:null,evenHeader:null,evenFooter:null,firstHeader:null,firstFooter:null},t.headerFooter),this.dataValidations=new f,this.views=t.views||[],this.autoFilter=t.autoFilter||null,this._media=[],this.shapes=[],this.sheetProtection=null,this.tables={},this.conditionalFormattings=[]}get name(){return this._name}set name(t){if(void 0===t&&(t="sheet"+this.id),this._name!==t){if("string"!=typeof t)throw new Error("The name has to be a string.");if(""===t)throw new Error("The name can't be empty.");if("History"===t)throw new Error('The name "History" is protected. Please use a different name.');if(/[*?:/\\[\]]/.test(t))throw new Error(`Worksheet name ${t} cannot include any of the following characters: * ? : \\ / [ ]`);if(/(^')|('$)/.test(t))throw new Error("The first or last character of worksheet name cannot be a single quotation mark: "+t);if(t&&t.length>31&&(console.warn(`Worksheet name ${t} exceeds 31 chars. This will be truncated`),t=t.substring(0,31)),this._workbook._worksheets.find(e=>e&&e.name.toLowerCase()===t.toLowerCase()))throw new Error("Worksheet name already exists: "+t);this._name=t}}get workbook(){return this._workbook}destroy(){this._workbook.removeWorksheetEx(this)}get dimensions(){const t=new s;return this._rows.forEach(e=>{if(e){const r=e.dimensions;r&&t.expand(e.number,r.min,e.number,r.max)}}),t}get columns(){return this._columns}set columns(t){this._headerRowCount=t.reduce((t,e)=>{const r=(e.header?1:e.headers&&e.headers.length)||0;return Math.max(t,r)},0);let e=1;const r=this._columns=[];t.forEach(t=>{const n=new a(this,e++,!1);r.push(n),n.defn=t})}getColumnKey(t){return this._keys[t]}setColumnKey(t,e){this._keys[t]=e}deleteColumnKey(t){delete this._keys[t]}eachColumnKey(t){n.each(this._keys,t)}getColumn(t){if("string"==typeof t){const e=this._keys[t];if(e)return e;t=i.l2n(t)}if(this._columns||(this._columns=[]),t>this._columns.length){let e=this._columns.length+1;for(;e<=t;)this._columns.push(new a(this,e++))}return this._columns[t-1]}spliceColumns(t,e){const r=this._rows.length;for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];if(i.length>0)for(let n=0;n<r;n++){const r=[t,e];i.forEach(t=>{r.push(t[n]||null)});const s=this.getRow(n+1);s.splice.apply(s,r)}else this._rows.forEach(r=>{r&&r.splice(t,e)});const o=i.length-e,a=t+e,l=this._columns.length;if(o<0)for(let e=t+i.length;e<=l;e++)this.getColumn(e).defn=this.getColumn(e-o).defn;else if(o>0)for(let t=l;t>=a;t--)this.getColumn(t+o).defn=this.getColumn(t).defn;for(let e=t;e<t+i.length;e++)this.getColumn(e).defn=null;this.workbook.definedNames.spliceColumns(this.name,t,e,i.length)}get lastColumn(){return this.getColumn(this.columnCount)}get columnCount(){let t=0;return this.eachRow(e=>{t=Math.max(t,e.cellCount)}),t}get actualColumnCount(){const t=[];let e=0;return this.eachRow(r=>{r.eachCell(r=>{let{col:n}=r;t[n]||(t[n]=!0,e++)})}),e}_commitRow(){}get _lastRowNumber(){const t=this._rows;let e=t.length;for(;e>0&&void 0===t[e-1];)e--;return e}get _nextRow(){return this._lastRowNumber+1}get lastRow(){if(this._rows.length)return this._rows[this._rows.length-1]}findRow(t){return this._rows[t-1]}findRows(t,e){return this._rows.slice(t-1,t-1+e)}get rowCount(){return this._lastRowNumber}get actualRowCount(){let t=0;return this.eachRow(()=>{t++}),t}getRow(t){let e=this._rows[t-1];return e||(e=this._rows[t-1]=new o(this,t)),e}getRows(t,e){if(e<1)return;const r=[];for(let n=t;n<t+e;n++)r.push(this.getRow(n));return r}addRow(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"n";const r=this._nextRow,n=this.getRow(r);return n.values=t,this._setStyleOption(r,"i"===e[0]?e:"n"),n}addRows(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"n";const r=[];return t.forEach(t=>{r.push(this.addRow(t,e))}),r}insertRow(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"n";return this.spliceRows(t,0,e),this._setStyleOption(t,r),this.getRow(t)}insertRows(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"n";if(this.spliceRows(t,0,...e),"n"!==r)for(let n=0;n<e.length;n++)"o"===r[0]&&