exceljs
Version:
Excel Workbook Manager - Read and Write xlsx and csv Files.
3 lines (2 loc) • 948 kB
JavaScript
/*! 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,n){function i(o,a){if(!r[o]){if(!t[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 u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,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(e,t,r){"use strict";const n=e("fs"),i=e("fast-csv"),s=e("dayjs/plugin/customParseFormat"),o=e("dayjs/plugin/utc"),a=e("dayjs").extend(s).extend(o),l=e("../utils/stream-buf"),{fs:{exists:c}}=e("../utils/utils"),u={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 c(e))throw new Error("File not found: "+e);const r=n.createReadStream(e),i=await this.read(r,t);return r.close(),i}read(e,t){return t=t||{},new Promise((r,n)=>{const s=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"],l=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 n=a(e,r,!0);return n.isValid()?n:null},null);if(r)return new Date(r.valueOf());const n=u[e];return void 0!==n?n:e},c=i.parse(t.parserOptions).on("data",e=>{s.addRow(e.map(l))}).on("end",()=>{c.emit("worksheet",s)});c.on("worksheet",r).on("error",n),e.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(e,t){return new Promise((r,n)=>{t=t||{};const s=this.workbook.getWorksheet(t.sheetName||t.sheetId),o=i.format(t.formatterOptions);e.on("finish",()=>{r()}),o.on("error",n),o.pipe(e);const{dateFormat:l,dateUTC:c}=t,u=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 l?c?a.utc(e).format(l):a(e).format(l):c?a.utc(e).format():a(e).format();if(e.error)return e.error;if("object"==typeof e)return JSON.stringify(e)}return e}),h=void 0===t.includeEmptyRows||t.includeEmptyRows;let f=1;s&&s.eachRow((e,t)=>{if(h)for(;f++<t-1;)o.write([]);const{values:r}=e;r.shift(),o.write(r.map(u)),f=t}),o.end()})}writeFile(e,t){const r={encoding:(t=t||{}).encoding||"utf8"},i=n.createWriteStream(e,r);return this.write(i,t)}async writeBuffer(e){const t=new l;return await this.write(t,e),t.read()}}},{"../utils/stream-buf":24,"../utils/utils":27,dayjs:391,"dayjs/plugin/customParseFormat":392,"dayjs/plugin/utc":393,"fast-csv":424,fs:216}],2:[function(e,t,r){"use strict";const n=e("../utils/col-cache");class i{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=n.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 i||null==e?e:new i(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=i},{"../utils/col-cache":19}],3:[function(e,t,r){"use strict";const n=e("../utils/col-cache"),i=e("../utils/under-dash"),s=e("./enums"),{slideFormula:o}=e("../utils/shared-formula"),a=e("./note");class l{constructor(e,t,r){if(!e||!t)throw new Error("A Cell needs a Row");this._row=e,this._column=t,n.validateAddress(r),this._address=r,this._value=c.create(l.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 n=e&&e.numFmt||t&&t.numFmt;n&&(r.numFmt=n);const i=e&&e.font||t&&t.font;i&&(r.font=i);const s=e&&e.alignment||t&&t.alignment;s&&(r.alignment=s);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 l=e&&e.protection||t&&t.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(e,t){this._value.release(),this._value=c.create(l.Types.Merge,this,e),t||(this.style=e.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(e){return this._value.type===l.Types.Merge&&this._value.isMergedTo(e)}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(e){this.type!==l.Types.Merge?(this._value.release(),this._value=c.create(c.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 i.escapeHtml(this.text)}toString(){return this.text}_upgradeToHyperlink(e){this.type===l.Types.String&&(this._value=c.create(l.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=c.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={}}}l.Types=s.ValueType;const c={getType:e=>null==e?l.Types.Null:e instanceof String||"string"==typeof e?l.Types.String:"number"==typeof e?l.Types.Number:"boolean"==typeof e?l.Types.Boolean:e instanceof Date?l.Types.Date:e.text&&e.hyperlink?l.Types.Hyperlink:e.formula||e.sharedFormula?l.Types.Formula:e.richText?l.Types.RichText:e.sharedString?l.Types.SharedString:e.error?l.Types.Error:l.Types.JSON,types:[{t:l.Types.Null,f:class{constructor(e){this.model={address:e.address,type:l.Types.Null}}get value(){return null}set value(e){}get type(){return l.Types.Null}get effectiveType(){return l.Types.Null}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return""}release(){}toString(){return""}}},{t:l.Types.Number,f:class{constructor(e,t){this.model={address:e.address,type:l.Types.Number,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return l.Types.Number}get effectiveType(){return l.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:l.Types.String,f:class{constructor(e,t){this.model={address:e.address,type:l.Types.String,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return l.Types.String}get effectiveType(){return l.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:l.Types.Date,f:class{constructor(e,t){this.model={address:e.address,type:l.Types.Date,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return l.Types.Date}get effectiveType(){return l.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:l.Types.Hyperlink,f:class{constructor(e,t){this.model={address:e.address,type:l.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 l.Types.Hyperlink}get effectiveType(){return l.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:l.Types.Formula,f:class{constructor(e,t){this.cell=e,this.model={address:e.address,type:l.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 n=e[r];n&&(t[r]=n)};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(c.getType(e)){case l.Types.Null:case l.Types.String:case l.Types.Number:case l.Types.Date:break;case l.Types.Hyperlink:case l.Types.Formula:default:throw new Error("Cannot process that type of result value")}}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?s.FormulaType.Master:this.model.sharedFormula?s.FormulaType.Shared:s.FormulaType.None}get result(){return this.model.result}set result(e){this.model.result=e}get type(){return l.Types.Formula}get effectiveType(){const e=this.model.result;return null==e?s.ValueType.Null:e instanceof String||"string"==typeof e?s.ValueType.String:"number"==typeof e?s.ValueType.Number:e instanceof Date?s.ValueType.Date:e.text&&e.hyperlink?s.ValueType.Hyperlink:e.formula?s.ValueType.Formula:s.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:l.Types.Merge,f:class{constructor(e,t){this.model={address:e.address,type:l.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 l?(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 l.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:l.Types.JSON,f:class{constructor(e,t){this.model={address:e.address,type:l.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 l.Types.String}get effectiveType(){return l.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:l.Types.SharedString,f:class{constructor(e,t){this.model={address:e.address,type:l.Types.SharedString,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return l.Types.SharedString}get effectiveType(){return l.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:l.Types.RichText,f:class{constructor(e,t){this.model={address:e.address,type:l.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 l.Types.RichText}get effectiveType(){return l.Types.RichText}get address(){return this.model.address}set address(e){this.model.address=e}toCsvString(){return`"${this.text.replace(/"/g,'""')}"`}release(){}}},{t:l.Types.Boolean,f:class{constructor(e,t){this.model={address:e.address,type:l.Types.Boolean,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return l.Types.Boolean}get effectiveType(){return l.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:l.Types.Error,f:class{constructor(e,t){this.model={address:e.address,type:l.Types.Error,value:t}}get value(){return this.model.value}set value(e){this.model.value=e}get type(){return l.Types.Error}get effectiveType(){return l.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 n=this.types[e];if(!n)throw new Error("Could not create Value of type "+e);return new n(t,r)}};t.exports=l},{"../utils/col-cache":19,"../utils/shared-formula":23,"../utils/under-dash":26,"./enums":7,"./note":9}],4:[function(e,t,r){"use strict";const n=e("../utils/under-dash"),i=e("./enums"),s=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 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(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&&n.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,n)=>{t(e.getCell(r),n)})}get values(){const e=[];return this.eachCell((t,r)=>{t&&t.type!==i.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,n)=>{this._worksheet.getCell(n+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,n)=>{e.isDefault?r&&(r=null):r&&e.equivalentTo(r)?r.max=n+1:(r={min:n+1,max:n+1,width:void 0!==e.width?e.width:9,style:e.style,isCustomWidth:e.isCustomWidth,hidden:e.hidden,outlineLevel:e.outlineLevel,collapsed:e.collapsed},t.push(r))}),t.length?t:void 0}static fromModel(e,t){const r=[];let n=1,i=0;for(t=(t=t||[]).sort((function(e,t){return e.min-t.min}));i<t.length;){const s=t[i++];for(;n<s.min;)r.push(new o(e,n++));for(;n<=s.max;)r.push(new o(e,n++,s))}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 n=e("../utils/under-dash"),i=e("../utils/col-cache"),s=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 s)}add(e,t){const r=i.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 n=e.top;n<=e.bottom;n++){const s={sheetName:e.sheetName,address:i.n2l(t)+n,row:n,col:t};r.addCellEx(s)}else r.addCellEx(e)}remove(e,t){const r=i.decodeEx(e);this.removeEx(r,t)}removeEx(e,t){this.getMatrix(t).removeCellEx(e)}removeAllNames(e){n.each(this.matrixMap,t=>{t.removeCellEx(e)})}forEach(e){n.each(this.matrixMap,(t,r)=>{t.forEach(t=>{e(r,t)})})}getNames(e){return this.getNamesEx(i.decodeEx(e))}getNamesEx(e){return n.map(this.matrixMap,(t,r)=>t.findCellEx(e)&&r).filter(Boolean)}_explore(e,t){t.mark=!1;const{sheetName:r}=t,n=new o(t.row,t.col,t.row,t.col,r);let i,s;function a(i,s){const o=e.findCellAt(r,i,t.col);return!(!o||!o.mark)&&(n[s]=i,o.mark=!1,!0)}for(s=t.row-1;a(s,"top");s--);for(s=t.row+1;a(s,"bottom");s++);function l(t,i){const o=[];for(s=n.top;s<=n.bottom;s++){const n=e.findCellAt(r,s,t);if(!n||!n.mark)return!1;o.push(n)}n[i]=t;for(let e=0;e<o.length;e++)o[e].mark=!1;return!0}for(i=t.col-1;l(i,"left");i--);for(i=t.col+1;l(i,"right");i++);return n}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=i.n2l(r)+t))})}spliceRows(e,t,r,i){n.each(this.matrixMap,n=>{n.spliceRows(e,t,r,i),this.normaliseMatrix(n,e)})}spliceColumns(e,t,r,i){n.each(this.matrixMap,n=>{n.spliceColumns(e,t,r,i),this.normaliseMatrix(n,e)})}get model(){return n.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 s;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 n=e("../utils/col-cache"),i=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:s,hyperlinks:o}=e;if(this.type=t,this.imageId=r,"image"===t)if("string"==typeof s){const e=n.decode(s);this.range={tl:new i(this.worksheet,{col:e.left,row:e.top},-1),br:new i(this.worksheet,{col:e.right,row:e.bottom},0),editAs:"oneCell"}}else this.range={tl:new i(this.worksheet,s.tl,0),br:s.br&&new i(this.worksheet,s.br,0),ext:s.ext,editAs:s.editAs,hyperlinks:o||s.hyperlinks}}}},{"../utils/col-cache":19,"./anchor":2}],9:[function(e,t,r){"use strict";const n=e("../utils/under-dash");class i{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 n.deepMerge({},i.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 i;return t.model=e,t}}i.DEFAULT_CONFIGS={note:{margins:{insetmode:"auto",inset:[.13,.13,.25,.25]},protection:{locked:"True",lockText:"True"},editAs:"absolute"}},t.exports=i},{"../utils/under-dash":26}],10:[function(e,t,r){"use strict";const n=e("../utils/col-cache");class i{constructor(){this.decode(arguments)}setTLBR(e,t,r,i,s){if(arguments.length<4){const i=n.decodeAddress(e),o=n.decodeAddress(t);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(e,r),left:Math.min(t,i),bottom:Math.max(e,r),right:Math.max(t,i),sheetName:s}}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 i)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=n.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,n){(!this.model.top||e<this.top)&&(this.top=e),(!this.model.left||t<this.left)&&(this.left=t),(!this.model.bottom||r>this.bottom)&&(this.bottom=r),(!this.model.right||n>this.right)&&(this.right=n)}expandRow(e){if(e){const{dimensions:t,number:r}=e;t&&this.expand(r,t.min,r,t.max)}}expandToAddress(e){const t=n.decodeEx(e);this.expand(t.row,t.col,t.row,t.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(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=n.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(n.encodeAddress(r,t),r,t)}}t.exports=i},{"../utils/col-cache":19}],11:[function(e,t,r){"use strict";const n=e("../utils/under-dash"),i=e("./enums"),s=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:s.l2n(e)}return this._cells[e-1]||this.getCellEx({address:s.encodeAddress(this._number,e),row:this._number,col:e})}splice(e,t){const r=e+t;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-t,a=this._cells.length;let l,c,u;if(o<0)for(l=e+i.length;l<=a;l++)u=this._cells[l-1],c=this._cells[l-o-1],c?(u=this.getCell(l),u.value=c.value,u.style=c.style,u._comment=c._comment):u&&(u.value=null,u.style={},u._comment=void 0);else if(o>0)for(l=a;l>=r;l--)c=this._cells[l-1],c?(u=this.getCell(l+o),u.value=c.value,u.style=c.style,u._comment=c._comment):this._cells[l+o-1]=void 0;for(l=0;l<i.length;l++)u=this.getCell(e+l),u.value=i[l],u.style={},u._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!==i.ValueType.Null&&t(e,r+1)})}addPageBreak(e,t){const r=this._worksheet,n=Math.max(0,e-1)||0,i=Math.max(0,t-1)||16838,s={id:this._number,max:i,man:1};n&&(s.min=n),r.rowBreaks.push(s)}get values(){const e=[];return this._cells.forEach(t=>{t&&t.type!==i.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:s.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:s.encodeAddress(this._number,t.number),row:this._number,col:t.number}).value=e[r])});else;}get hasValues(){return n.some(this._cells,e=>e&&e.type!==i.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!==i.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(n=>{if(n){const i=n.model;i&&((!t||t>n.col)&&(t=n.col),r<n.col&&(r=n.col),e.push(i))}}),this.height||e.length?{cells:e,number:this.number,min:t,max:r,height:this.height,style:this.style,hidden:this.hidden,outlineLevel:this.outlineLevel,collapsed:this.collapsed}:null}set 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=s.decodeAddress(e.address);else if(t){const{row:e}=t,n=t.col+1;r={row:e,col:n,address:s.encodeAddress(e,n),$col$row:`$${s.n2l(n)}$${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 n=e("../utils/col-cache");class i{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=n.decodeAddress(e.ref);const{row:i,col:s}=e.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;e.autoFilterRef=n.encode(i,s,i+a-1,s+o-1),e.tableRef=n.encode(i,s,i+l-1,s+o-1),e.columns.forEach((e,n)=>{r(e.name,`Column ${n} must have a name`),0===n?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:n,col:i}=r.tl;let s=0;if(r.headerRow){const o=t.getRow(n+s++);r.columns.forEach((t,r)=>{const{style:n,name:s}=t,a=o.getCell(i+r);a.value=s,e(a,n)})}if(r.rows.forEach(o=>{const a=t.getRow(n+s++);o.forEach((t,n)=>{const s=a.getCell(i+n);s.value=t,e(s,r.columns[n].style)})}),r.totalsRow){const o=t.getRow(n+s++);r.columns.forEach((t,r)=>{const n=o.getCell(i+r);if(0===r)n.value=t.totalsRowLabel;else{const e=this.getFormula(t);n.value=e?{formula:t.totalsRowFormula,result:t.totalsRowResult}:null}e(n,t.style)})}}load(e){const{table:t}=this,{row:r,col:n}=t.tl;let i=0;if(t.headerRow){const s=e.getRow(r+i++);t.columns.forEach((e,t)=>{s.getCell(n+t).value=e.name})}if(t.rows.forEach(t=>{const s=e.getRow(r+i++);t.forEach((e,t)=>{s.getCell(n+t).value=e})}),t.totalsRow){const s=e.getRow(r+i++);t.columns.forEach((e,t)=>{const r=s.getCell(n+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=n.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 i(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,n)=>{e.splice(r,0,t[n])}))}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 n=e("./worksheet"),i=e("./defined-names"),s=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 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 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 i=this._worksheets.reduce((e,t)=>(t&&t.orderNo)>e?t.orderNo:e,0),s=Object.assign({},t,{id:r,name:e,orderNo:i+1,workbook:this}),o=new n(s);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:i,state:s}=t,o=e.sheets&&e.sheets.findIndex(e=>e.id===r);(this._worksheets[r]=new n({id:r,name:i,orderNo:o,state:s,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 n=e("../utils/under-dash"),i=e("../utils/col-cache"),s=e("./range"),o=e("./row"),a=e("./column"),l=e("./enums"),c=e("./image"),u=e("./table"),h=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 h,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 s;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 n=new a(this,t++,!1);r.push(n),n.defn=e})}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){n.each(this._keys,e)}getColumn(e){if("string"==typeof e){const t=this._keys[e];if(t)return t;e=i.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 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=[e,t];i.forEach(e=>{r.push(e[n]||null)});const s=this.getRow(n+1);s.splice.apply(s,r)}else this._rows.forEach(r=>{r&&r.splice(e,t)});const o=i.length-t,a=e+t,l=this._columns.length;if(o<0)for(let t=e+i.length;t<=l;t++)this.getColumn(t).defn=this.getColumn(t-o).defn;else if(o>0)for(let e=l;e>=a;e--)this.getColumn(e+o).defn=this.getColumn(e).defn;for(let t=e;t<e+i.length;t++)this.getColumn(t).defn=null;this.workbook.definedNames.spliceColumns(this.name,e,t,i.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:n}=r;e[n]||(e[n]=!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 n=e;n<e+t;n++)r.push(this.getRow(n));return r}addRow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"n";const r=this._nextRow,n=this.getRow(r);return n.values=e,this._setStyleOption(r,"i"===t[0]?t:"n"),n}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 n=0;n<t.length;n++)"o"===r[0]&&void 0!==this.findRow(t.length+e+n)?this._copyStyle(t.length+e+n,e+n,"+"===r[1]):"i"===r[0]&&void 0!==this.findRow(e-1)&&this._copyStyle(e-1,e+n,"+"===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 n=this.getRow(e),i=this.getRow(t);i.style=d(n.style),n.eachCell({includeEmpty:r},(e,t)=>{i.getCell(t).style=d(e.style)}),i.height=n.height}duplicateRow(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const n=this._rows[e-1],i=new Array(t).fill(n.values);this.spliceRows(e+1,r?0:t,...i);for(let r=0;r<t;r++){const t=this._rows[e+r];t.style=n.style,t.height=n.height,n.eachCell({includeEmpty:!0},(e,r)=>{t.getCell(r).style=e.style})}}spliceRows(e,t){const r=e+t;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,a=o-t,l=this._rows.length;let c,u;if(a<0)for(e===l&&(this._rows[l-1]=void 0),c=r;c<=l;c++)if(u=this._rows[c-1],u){const e=this.getRow(c+a);e.values=u.values,e.style=u.style,e.height=u.height,u.eachCell({includeEmpty:!0},(t,r)=>{e.getCell(r).style=t.style}),this._rows[c-1]=void 0}else this._rows[c+a-1]=void 0;else if(a>0)for(c=l;c>=r;c--)if(u=this._rows[c-1],u){const e=this.getRow(c+a);e.values=u.values,e.style=u.style,e.height=u.height,u.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),n=t._value._master,i=this.getRow(n._row._number+o).getCell(n._column._number);e.merge(i)}})}else this._rows[c+a-1]=void 0;for(c=0;c<o;c++){const t=this.getRow(e+c);t.sty