UNPKG

exceljs

Version:

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

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