@visactor/vtable-export 1.13.3-alpha.4 → 1.13.3-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,13 +10,17 @@ function getCellFont(cellStyle, cellType) {
10
10
  return {
11
11
  name: getFirstFontFromFontFamily(cellStyle.fontFamily) || "Arial",
12
12
  size: cellStyle.fontSize || 10,
13
- bold: "bold" === cellStyle.fontWeight,
13
+ bold: isFontBold(cellStyle.fontWeight),
14
14
  italic: "italic" === cellStyle.fontStyle,
15
15
  color: getColor("link" === cellType ? cellStyle._linkColor : cellStyle.color),
16
16
  underline: cellStyle.underline
17
17
  };
18
18
  }
19
19
 
20
+ function isFontBold(fontWeight) {
21
+ return "number" == typeof fontWeight ? fontWeight >= 600 : Number(fontWeight) >= 600 || "bold" === fontWeight;
22
+ }
23
+
20
24
  function getFirstFontFromFontFamily(fontFamily) {
21
25
  return fontFamily.split(",").map((font => font.trim()))[0];
22
26
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["excel/style.ts"],"names":[],"mappings":";;;AACA,yCAA4D;AAG5D,SAAgB,WAAW,CAAC,SAAoB,EAAE,QAAkB;IAClE,OAAO;QACL,IAAI,EAAE,0BAA0B,CAAC,SAAS,CAAC,UAAoB,CAAC,IAAI,OAAO;QAC3E,IAAI,EAAE,SAAS,CAAC,QAAQ,IAAI,EAAE;QAC9B,IAAI,EAAE,SAAS,CAAC,UAAU,KAAK,MAAM;QACrC,MAAM,EAAE,SAAS,CAAC,SAAS,KAAK,QAAQ;QACxC,KAAK,EAAE,QAAQ,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAE,SAAS,CAAC,UAAqB,CAAC,CAAC,CAAE,SAAS,CAAC,KAAgB,CAAC;QACrG,SAAS,EAAE,SAAS,CAAC,SAAS;KAC/B,CAAC;AACJ,CAAC;AATD,kCASC;AAED,SAAS,0BAA0B,CAAC,UAAkB;IACpD,MAAM,KAAK,GAAG,UAAU,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;IACD,MAAM,MAAM,GAAG;QACb,KAAK,EAAE,cAAc,CAAC,eAAyB,EAAE,cAAc,CAAC;QAChE,KAAK,EAAE,QAAQ,CAAC,WAAqB,CAAC;KACvC,CAAC;IACF,OAAO;QACL,GAAG,EAAE,MAAM;QACX,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,MAAM;KACd,CAAC;AACJ,CAAC;AA5CD,sCA4CC;AAED,SAAS,cAAc,CAAC,SAAiB,EAAE,cAA4B;IAKrE,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,EAAE;QAC3C,IAAI,SAAS,IAAI,CAAC,EAAE;YAClB,OAAO,QAAQ,CAAC;SACjB;QACD,OAAO,cAAc,CAAC;KACvB;IACD,IAAI,SAAS,IAAI,GAAG,EAAE;QACpB,OAAO,MAAM,CAAC;KACf;SAAM,IAAI,SAAS,IAAI,CAAC,EAAE;QACzB,OAAO,MAAM,CAAC;KACf;SAAM,IAAI,SAAS,IAAI,CAAC,EAAE;QACzB,OAAO,QAAQ,CAAC;KACjB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAgB,gBAAgB,CAAC,SAAoB,EAAE,MAAc;IACnE,OAAO;QACL,UAAU,EAAE,SAAS,CAAC,SAAS,IAAI,MAAM;QACzC,QAAQ,EAAE,SAAS,CAAC,YAAY,IAAI,QAAQ;QAC5C,QAAQ,EAAE,SAAS,CAAC,YAAY,IAAI,KAAK;QACzC,MAAM,EAAE,MAAM,IAAI,CAAC;KACb,CAAC;AACX,CAAC;AAPD,4CAOC;AAED,SAAS,QAAQ,CAAC,KAAa;IAE7B,OAAO;QACL,IAAI,EAAE,IAAA,iBAAS,EAAC,IAAA,wBAAgB,EAAC,KAAK,CAAC,CAAC;KACzC,CAAC;AACJ,CAAC","file":"style.js","sourcesContent":["import type ExcelJS from 'exceljs';\nimport { colorStringToRGB, rgbaToHex } from '../util/color';\nimport type { CellStyle, CellType, LineDashsDef } from '../util/type';\n\nexport function getCellFont(cellStyle: CellStyle, cellType: CellType): Partial<ExcelJS.Font> {\n return {\n name: getFirstFontFromFontFamily(cellStyle.fontFamily as string) || 'Arial', // only one font family name\n size: cellStyle.fontSize || 10,\n bold: cellStyle.fontWeight === 'bold', // only bold or not\n italic: cellStyle.fontStyle === 'italic', // only italic or not\n color: getColor(cellType === 'link' ? (cellStyle._linkColor as string) : (cellStyle.color as string)),\n underline: cellStyle.underline\n };\n}\n\nfunction getFirstFontFromFontFamily(fontFamily: string) {\n const fonts = fontFamily.split(',').map(font => font.trim());\n return fonts[0];\n}\n\nexport function getCellFill(cellStyle: CellStyle): ExcelJS.Fill {\n return {\n type: 'pattern',\n pattern: 'solid',\n fgColor: getColor(cellStyle.bgColor as string)\n };\n}\n\nexport function getCellBorder(cellStyle: CellStyle): Partial<ExcelJS.Borders> {\n const { borderColor, borderLineWidth, borderLineDash, _strokeArrayWidth, _strokeArrayColor } = cellStyle;\n if (_strokeArrayColor || _strokeArrayWidth) {\n const border: Partial<ExcelJS.Borders> = {};\n if (!((_strokeArrayColor && !_strokeArrayColor[0]) || (_strokeArrayWidth && !_strokeArrayWidth[0]))) {\n border.top = {\n style: getBorderStyle((_strokeArrayWidth?.[0] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[0] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[1]) || (_strokeArrayWidth && !_strokeArrayWidth[1]))) {\n border.right = {\n style: getBorderStyle((_strokeArrayWidth?.[1] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[1] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[2]) || (_strokeArrayWidth && !_strokeArrayWidth[2]))) {\n border.bottom = {\n style: getBorderStyle((_strokeArrayWidth?.[2] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[2] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[3]) || (_strokeArrayWidth && !_strokeArrayWidth[3]))) {\n border.left = {\n style: getBorderStyle((_strokeArrayWidth?.[3] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[3] as string) ?? (borderColor as string))\n };\n }\n return border;\n }\n\n if (borderLineWidth === 0) {\n return {};\n }\n const border = {\n style: getBorderStyle(borderLineWidth as number, borderLineDash),\n color: getColor(borderColor as string)\n };\n return {\n top: border,\n left: border,\n bottom: border,\n right: border\n };\n}\n\nfunction getBorderStyle(lineWidth: number, borderLineDash: LineDashsDef): ExcelJS.BorderStyle {\n // hair:0.5\n // thin:1\n // medium:2.0\n // thick:3.0\n if (borderLineDash && borderLineDash.length) {\n if (lineWidth <= 2) {\n return 'dashed';\n }\n return 'mediumDashed';\n }\n if (lineWidth <= 0.5) {\n return 'hair';\n } else if (lineWidth <= 1) {\n return 'thin';\n } else if (lineWidth <= 2) {\n return 'medium';\n }\n return 'thick';\n}\n\nexport function getCellAlignment(cellStyle: CellStyle, indent: number): Partial<ExcelJS.Alignment> {\n return {\n horizontal: cellStyle.textAlign || 'left',\n vertical: cellStyle.textBaseline || 'middle',\n wrapText: cellStyle.autoWrapText || false,\n indent: indent || 0\n } as any;\n}\n\nfunction getColor(color: string) {\n // to do: support gradient color\n return {\n argb: rgbaToHex(colorStringToRGB(color))\n };\n}\n"]}
1
+ {"version":3,"sources":["excel/style.ts"],"names":[],"mappings":";;;AACA,yCAA4D;AAG5D,SAAgB,WAAW,CAAC,SAAoB,EAAE,QAAkB;IAClE,OAAO;QACL,IAAI,EAAE,0BAA0B,CAAC,SAAS,CAAC,UAAoB,CAAC,IAAI,OAAO;QAC3E,IAAI,EAAE,SAAS,CAAC,QAAQ,IAAI,EAAE;QAE9B,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC;QACtC,MAAM,EAAE,SAAS,CAAC,SAAS,KAAK,QAAQ;QACxC,KAAK,EAAE,QAAQ,CAAC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ACnE,OAAO;QACL,UAAU,EAAE,SAAS,CAAC,SAAS,IAAI,MAAM;QACzC,QAAQ,EAAE,SAAS,CAAC,YAAY,IAAI,QAAQ;QAC5C,QAAQ,EAAE,SAAS,CAAC,YAAY,IAAI,KAAK;QACzC,MAAM,EAAE,MAAM,IAAI,CAAC;KACb,CAAC;AACX,CAAC;AAPD,4CAOC;AAED,SAAS,QAAQ,CAAC,KAAa;IAE7B,OAAO;QACL,IAAI,EAAE,IAAA,iBAAS,EAAC,IAAA,wBAAgB,EAAC,KAAK,CAAC,CAAC;KACzC,CAAC;AACJ,CAAC","file":"style.js","sourcesContent":["import type ExcelJS from 'exceljs';\nimport { colorStringToRGB, rgbaToHex } from '../util/color';\nimport type { CellStyle, CellType, LineDashsDef } from '../util/type';\n\nexport function getCellFont(cellStyle: CellStyle, cellType: CellType): Partial<ExcelJS.Font> {\n return {\n name: getFirstFontFromFontFamily(cellStyle.fontFamily as string) || 'Arial', // only one font family name\n size: cellStyle.fontSize || 10,\n // bold: cellStyle.fontWeight === 'bold', // only bold or not\n bold: isFontBold(cellStyle.fontWeight), // only bold or not\n italic: cellStyle.fontStyle === 'italic', // only italic or not\n color: getColor(cellType === 'link' ? (cellStyle._linkColor as string) : (cellStyle.color as string)),\n underline: cellStyle.underline\n };\n}\n\nfunction isFontBold(fontWeight: string | number) {\n if (typeof fontWeight === 'number') {\n return fontWeight >= 600;\n }\n if (Number(fontWeight) >= 600) {\n return true;\n }\n return fontWeight === 'bold';\n}\n\nfunction getFirstFontFromFontFamily(fontFamily: string) {\n const fonts = fontFamily.split(',').map(font => font.trim());\n return fonts[0];\n}\n\nexport function getCellFill(cellStyle: CellStyle): ExcelJS.Fill {\n return {\n type: 'pattern',\n pattern: 'solid',\n fgColor: getColor(cellStyle.bgColor as string)\n };\n}\n\nexport function getCellBorder(cellStyle: CellStyle): Partial<ExcelJS.Borders> {\n const { borderColor, borderLineWidth, borderLineDash, _strokeArrayWidth, _strokeArrayColor } = cellStyle;\n if (_strokeArrayColor || _strokeArrayWidth) {\n const border: Partial<ExcelJS.Borders> = {};\n if (!((_strokeArrayColor && !_strokeArrayColor[0]) || (_strokeArrayWidth && !_strokeArrayWidth[0]))) {\n border.top = {\n style: getBorderStyle((_strokeArrayWidth?.[0] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[0] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[1]) || (_strokeArrayWidth && !_strokeArrayWidth[1]))) {\n border.right = {\n style: getBorderStyle((_strokeArrayWidth?.[1] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[1] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[2]) || (_strokeArrayWidth && !_strokeArrayWidth[2]))) {\n border.bottom = {\n style: getBorderStyle((_strokeArrayWidth?.[2] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[2] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[3]) || (_strokeArrayWidth && !_strokeArrayWidth[3]))) {\n border.left = {\n style: getBorderStyle((_strokeArrayWidth?.[3] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[3] as string) ?? (borderColor as string))\n };\n }\n return border;\n }\n\n if (borderLineWidth === 0) {\n return {};\n }\n const border = {\n style: getBorderStyle(borderLineWidth as number, borderLineDash),\n color: getColor(borderColor as string)\n };\n return {\n top: border,\n left: border,\n bottom: border,\n right: border\n };\n}\n\nfunction getBorderStyle(lineWidth: number, borderLineDash: LineDashsDef): ExcelJS.BorderStyle {\n // hair:0.5\n // thin:1\n // medium:2.0\n // thick:3.0\n if (borderLineDash && borderLineDash.length) {\n if (lineWidth <= 2) {\n return 'dashed';\n }\n return 'mediumDashed';\n }\n if (lineWidth <= 0.5) {\n return 'hair';\n } else if (lineWidth <= 1) {\n return 'thin';\n } else if (lineWidth <= 2) {\n return 'medium';\n }\n return 'thick';\n}\n\nexport function getCellAlignment(cellStyle: CellStyle, indent: number): Partial<ExcelJS.Alignment> {\n return {\n horizontal: cellStyle.textAlign || 'left',\n vertical: cellStyle.textBaseline || 'middle',\n wrapText: cellStyle.autoWrapText || false,\n indent: indent || 0\n } as any;\n}\n\nfunction getColor(color: string) {\n // to do: support gradient color\n return {\n argb: rgbaToHex(colorStringToRGB(color))\n };\n}\n"]}
@@ -75829,12 +75829,21 @@ ${XMLNS_NAMESPACE}.`);
75829
75829
  return {
75830
75830
  name: getFirstFontFromFontFamily(cellStyle.fontFamily) || 'Arial',
75831
75831
  size: cellStyle.fontSize || 10,
75832
- bold: cellStyle.fontWeight === 'bold',
75832
+ bold: isFontBold(cellStyle.fontWeight),
75833
75833
  italic: cellStyle.fontStyle === 'italic',
75834
75834
  color: getColor(cellType === 'link' ? cellStyle._linkColor : cellStyle.color),
75835
75835
  underline: cellStyle.underline
75836
75836
  };
75837
75837
  }
75838
+ function isFontBold(fontWeight) {
75839
+ if (typeof fontWeight === 'number') {
75840
+ return fontWeight >= 600;
75841
+ }
75842
+ if (Number(fontWeight) >= 600) {
75843
+ return true;
75844
+ }
75845
+ return fontWeight === 'bold';
75846
+ }
75838
75847
  function getFirstFontFromFontFamily(fontFamily) {
75839
75848
  const fonts = fontFamily.split(',').map(font => font.trim());
75840
75849
  return fonts[0];
@@ -88,4 +88,4 @@ var VP=c,WP=zI,qP=qA,XP=function(e){if(!(this instanceof XP))return new XP(e);"o
88
88
  * Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
89
89
  *
90
90
  * MIT Licensed
91
- */!function(e){const n=r,i=d,s=l,o=t,a={fs:n.constants,os:i.constants},h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",u=/XXXXXX/,c=3,f=(a.O_CREAT||a.fs.O_CREAT)|(a.O_EXCL||a.fs.O_EXCL)|(a.O_RDWR||a.fs.O_RDWR),p="win32"===i.platform(),m=a.EBADF||a.os.errno.EBADF,g=a.ENOENT||a.os.errno.ENOENT,y=[],v=n.rmdirSync.bind(n);let _=!1;function b(e,t){return n.rm(e,{recursive:!0},t)}function w(e){return n.rmSync(e,{recursive:!0})}function x(e,t){const r=N(e,t),i=r[0],s=r[1];try{P(i)}catch(e){return s(e)}let o=i.tries;!function e(){try{const t=I(i);n.stat(t,(function(r){if(!r)return o-- >0?e():s(new Error("Could not get a unique tmp filename, max tries reached "+t));s(null,t)}))}catch(e){s(e)}}()}function k(e){const t=N(e)[0];P(t);let r=t.tries;do{const e=I(t);try{n.statSync(e)}catch(t){return e}}while(r-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function S(e,t){const r=function(e){if(e&&!j(e))return t(e);t()};0<=e[0]?n.close(e[0],(function(){n.unlink(e[1],r)})):n.unlink(e[1],r)}function E(e){let t=null;try{0<=e[0]&&n.closeSync(e[0])}catch(e){if(!function(e){return M(e,-m,"EBADF")}(e)&&!j(e))throw e}finally{try{n.unlinkSync(e[1])}catch(e){j(e)||(t=e)}}if(null!==t)throw t}function C(e,t,r,n){const i=O(E,[t,e],n),s=O(S,[t,e],n,i);return r.keep||y.unshift(i),n?i:s}function T(e,t,r){const i=t.unsafeCleanup?b:n.rmdir.bind(n),s=O(t.unsafeCleanup?w:v,e,r),o=O(i,e,r,s);return t.keep||y.unshift(s),r?s:o}function O(e,t,r,n){let i=!1;return function s(o){if(!i){const a=n||s,l=y.indexOf(a);return l>=0&&y.splice(l,1),i=!0,r||e===v||e===w?e(t):e(t,o||function(){})}}}function R(e){let t=[],r=null;try{r=o.randomBytes(e)}catch(t){r=o.pseudoRandomBytes(e)}for(var n=0;n<e;n++)t.push(h[r[n]%h.length]);return t.join("")}function A(e){return void 0===e}function N(e,t){if("function"==typeof e)return[{},e];if(A(e))return[{},t];const r={};for(const t of Object.getOwnPropertyNames(e))r[t]=e[t];return[r,t]}function I(e){const t=e.tmpdir;if(!A(e.name))return s.join(t,e.dir,e.name);if(!A(e.template))return s.join(t,e.dir,e.template).replace(u,R(6));const r=[e.prefix?e.prefix:"tmp","-",process.pid,"-",R(12),e.postfix?"-"+e.postfix:""].join("");return s.join(t,e.dir,r)}function P(e){e.tmpdir=L(e);const t=e.tmpdir;if(A(e.name)||D(e.name,"name",t),A(e.dir)||D(e.dir,"dir",t),!A(e.template)&&(D(e.template,"template",t),!e.template.match(u)))throw new Error(`Invalid template, found "${e.template}".`);if(!A(e.tries)&&isNaN(e.tries)||e.tries<0)throw new Error(`Invalid tries, found "${e.tries}".`);e.tries=A(e.name)?e.tries||c:1,e.keep=!!e.keep,e.detachDescriptor=!!e.detachDescriptor,e.discardDescriptor=!!e.discardDescriptor,e.unsafeCleanup=!!e.unsafeCleanup,e.dir=A(e.dir)?"":s.relative(t,F(e.dir,t)),e.template=A(e.template)?void 0:s.relative(t,F(e.template,t)),e.template=function(e){return null===e||A(e)||!e.trim()}(e.template)?void 0:s.relative(e.dir,e.template),e.name=A(e.name)?void 0:e.name,e.prefix=A(e.prefix)?"":e.prefix,e.postfix=A(e.postfix)?"":e.postfix}function F(e,t){return e.startsWith(t)?s.resolve(e):s.resolve(s.join(t,e))}function D(e,t,r){if("name"===t){if(s.isAbsolute(e))throw new Error(`${t} option must not contain an absolute path, found "${e}".`);let r=s.basename(e);if(".."===r||"."===r||r!==e)throw new Error(`${t} option must not contain a path, found "${e}".`)}else{if(s.isAbsolute(e)&&!e.startsWith(r))throw new Error(`${t} option must be relative to "${r}", found "${e}".`);let n=F(e,r);if(!n.startsWith(r))throw new Error(`${t} option must be relative to "${r}", found "${n}".`)}}function j(e){return M(e,-g,"ENOENT")}function M(e,t,r){return p?e.code===r:e.code===r&&e.errno===t}function L(e){return s.resolve(e&&e.tmpdir||i.tmpdir())}process.addListener("exit",(function(){if(_)for(;y.length;)try{y[0]()}catch(e){}})),Object.defineProperty(e.exports,"tmpdir",{enumerable:!0,configurable:!1,get:function(){return L()}}),e.exports.dir=function(e,t){const r=N(e,t),i=r[0],s=r[1];x(i,(function(e,t){if(e)return s(e);n.mkdir(t,i.mode||448,(function(e){if(e)return s(e);s(null,t,T(t,i,!1))}))}))},e.exports.dirSync=function(e){const t=N(e)[0],r=k(t);return n.mkdirSync(r,t.mode||448),{name:r,removeCallback:T(r,t,!0)}},e.exports.file=function(e,t){const r=N(e,t),i=r[0],s=r[1];x(i,(function(e,t){if(e)return s(e);n.open(t,f,i.mode||384,(function(e,r){if(e)return s(e);if(i.discardDescriptor)return n.close(r,(function(e){return s(e,t,void 0,C(t,-1,i,!1))}));{const e=i.discardDescriptor||i.detachDescriptor;s(null,t,r,C(t,e?-1:r,i,!1))}}))}))},e.exports.fileSync=function(e){const t=N(e)[0],r=t.discardDescriptor||t.detachDescriptor,i=k(t);var s=n.openSync(i,f,t.mode||384);return t.discardDescriptor&&(n.closeSync(s),s=void 0),{name:i,fd:s,removeCallback:C(i,r?-1:s,t,!0)}},e.exports.tmpName=x,e.exports.tmpNameSync=k,e.exports.setGracefulCleanup=function(){_=!0}}(FB);var DB=FB.exports;function jB(e,t){return new Promise((r=>{let n=!1;const i=()=>{n||(n=!0,e.removeListener(t,i),r())};e.addListener(t,i)}))}const{EventEmitter:MB}=i,LB=Vh,BB=S,zB=Ol,$B=T,HB=R,UB=G,VB=J;let WB=class extends MB{constructor(e){let{workbook:t,id:r,iterator:n,options:i}=e;super(),this.workbook=t,this.id=r,this.iterator=n,this.options=i||{},this.name=`Sheet${this.id}`,this._columns=null,this._keys={},this._dimensions=new HB}destroy(){throw new Error("Invalid Operation: destroy")}get dimensions(){return this._dimensions}get columns(){return this._columns}getColumn(e){if("string"==typeof e){const t=this._keys[e];if(t)return t;e=$B.l2n(e)}if(this._columns||(this._columns=[]),e>this._columns.length){let t=this._columns.length+1;for(;t<=e;)this._columns.push(new VB(this,t++))}return this._columns[e-1]}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){BB.each(this._keys,e)}async read(){try{for await(const e of this.parse())for(const{eventType:t,value:r}of e)this.emit(t,r);this.emit("finished")}catch(e){this.emit("error",e)}}async*[Symbol.asyncIterator](){for await(const e of this.parse())for(const{eventType:t,value:r}of e)"row"===t&&(yield r)}async*parse(){const{iterator:e,options:t}=this;let r=!1,n=!1,i=null;if("emit"===t.worksheets)r=!0;switch(t.hyperlinks){case"emit":n=!0;break;case"cache":this.hyperlinks=i={}}if(!r&&!n&&!i)return;const{sharedStrings:s,styles:o,properties:a}=this.workbook;let l=!1,h=!1,u=!1,c=null,d=null,f=null,p=null;for await(const t of LB(e)){const e=[];for(const{eventType:m,value:g}of t)if("opentag"===m){const t=g;if(r)switch(t.name){case"cols":l=!0,c=[];break;case"sheetData":h=!0;break;case"col":l&&c.push({min:parseInt(t.attributes.min,10),max:parseInt(t.attributes.max,10),width:parseFloat(t.attributes.width),styleId:parseInt(t.attributes.style||"0",10)});break;case"row":if(h){const e=parseInt(t.attributes.r,10);if(d=new UB(this,e),t.attributes.ht&&(d.height=parseFloat(t.attributes.ht)),t.attributes.s){const e=parseInt(t.attributes.s,10),r=o.getStyleModel(e);r&&(d.style=r)}}break;case"c":d&&(f={ref:t.attributes.r,s:parseInt(t.attributes.s,10),t:t.attributes.t});break;case"f":f&&(p=f.f={text:""});break;case"v":case"is":case"t":f&&(p=f.v={text:""})}if(n||i)switch(t.name){case"hyperlinks":u=!0;break;case"hyperlink":if(u){const r={ref:t.attributes.ref,rId:t.attributes["r:id"]};n?e.push({eventType:"hyperlink",value:r}):i[r.ref]=r}}}else if("text"===m)r&&p&&(p.text+=g);else if("closetag"===m){const t=g;if(r)switch(t.name){case"cols":l=!1,this._columns=VB.fromModel(c);break;case"sheetData":h=!1;break;case"row":this._dimensions.expandRow(d),e.push({eventType:"row",value:d}),d=null;break;case"c":if(d&&f){const e=$B.decodeAddress(f.ref),t=d.getCell(e.col);if(f.s){const e=o.getStyleModel(f.s);e&&(t.style=e)}if(f.f){const e={formula:f.f.text};f.v&&("str"===f.t?e.result=zB.xmlDecode(f.v.text):e.result=parseFloat(f.v.text)),t.value=e}else if(f.v)switch(f.t){case"s":{const e=parseInt(f.v.text,10);t.value=s?s[e]:{sharedString:e};break}case"inlineStr":case"str":t.value=zB.xmlDecode(f.v.text);break;case"e":t.value={error:f.v.text};break;case"b":t.value=0!==parseInt(f.v.text,10);break;default:zB.isDateFmt(t.numFmt)?t.value=zB.excelToDate(parseFloat(f.v.text),a.model&&a.model.date1904):t.value=parseFloat(f.v.text)}if(i){const e=i[f.ref];e&&(t.text=t.value,t.value=void 0,t.hyperlink=e)}f=null}}if((n||i)&&"hyperlinks"===t.name)u=!1}e.length>0&&(yield e)}}};var qB=WB;const{EventEmitter:XB}=i,ZB=Vh,GB=A,YB=$d;var QB=class extends XB{constructor(e){let{workbook:t,id:r,iterator:n,options:i}=e;super(),this.workbook=t,this.id=r,this.iterator=n,this.options=i}get count(){return this.hyperlinks&&this.hyperlinks.length||0}each(e){return this.hyperlinks.forEach(e)}async read(){const{iterator:e,options:t}=this;let r=!1,n=null;switch(t.hyperlinks){case"emit":r=!0;break;case"cache":this.hyperlinks=n={}}if(r||n)try{for await(const t of ZB(e))for(const{eventType:e,value:i}of t)if("opentag"===e){const e=i;if("Relationship"===e.name){const t=e.attributes.Id;if(e.attributes.Type===YB.Hyperlink){const i={type:GB.RelationshipType.Styles,rId:t,target:e.attributes.Target,targetMode:e.attributes.TargetMode};r?this.emit("hyperlink",i):n[i.rId]=i}}}this.emit("finished")}catch(e){this.emit("error",e)}else this.emit("finished")}};const KB=r,{EventEmitter:JB}=i,{PassThrough:ez,Readable:tz}=Sl,rz=n,nz=oD,iz=DB,sz=async function*(e){const t=[];let r;e.on("data",(e=>t.push(e)));const n=new Promise((e=>r=e));let i=!1;e.on("end",(()=>{i=!0,r()}));let s=!1;for(e.on("error",(e=>{s=e,r()}));!i||t.length>0;){if(0===t.length)e.resume(),await Promise.race([jB(e,"data"),n]);else{e.pause();const r=t.shift();yield r}if(s)throw s}r()},oz=Vh,az=gc,lz=zd,hz=Kc,uz=qB,cz=QB;iz.setGracefulCleanup();class dz extends JB{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this.input=e,this.options={worksheets:"emit",sharedStrings:"cache",hyperlinks:"ignore",styles:"ignore",entries:"ignore",...t},this.styles=new az,this.styles.init()}_getStream(e){if(e instanceof rz.Readable||e instanceof tz)return e;if("string"==typeof e)return KB.createReadStream(e);throw new Error(`Could not recognise input: ${e}`)}async read(e,t){try{for await(const{eventType:r,value:n}of this.parse(e,t))switch(r){case"shared-strings":case"hyperlinks":this.emit(r,n);break;case"worksheet":this.emit(r,n),await n.read()}this.emit("end"),this.emit("finished")}catch(e){this.emit("error",e)}}async*[Symbol.asyncIterator](){for await(const{eventType:e,value:t}of this.parse())"worksheet"===e&&(yield t)}async*parse(e,t){t&&(this.options=t);const r=this.stream=this._getStream(e||this.input),n=nz.Parse({forceStream:!0});r.pipe(n);const i=[];for await(const e of sz(n)){let t,r;switch(e.path){case"_rels/.rels":break;case"xl/_rels/workbook.xml.rels":await this._parseRels(e);break;case"xl/workbook.xml":await this._parseWorkbook(e);break;case"xl/sharedStrings.xml":yield*this._parseSharedStrings(e);break;case"xl/styles.xml":await this._parseStyles(e);break;default:e.path.match(/xl\/worksheets\/sheet\d+[.]xml/)?(t=e.path.match(/xl\/worksheets\/sheet(\d+)[.]xml/),r=t[1],this.sharedStrings&&this.workbookRels?yield*this._parseWorksheet(sz(e),r):await new Promise(((t,n)=>{iz.file(((s,o,a,l)=>{if(s)return n(s);i.push({sheetNo:r,path:o,tempFileCleanupCallback:l});const h=KB.createWriteStream(o);return h.on("error",n),e.pipe(h),h.on("finish",(()=>t()))}))}))):e.path.match(/xl\/worksheets\/_rels\/sheet\d+[.]xml.rels/)&&(t=e.path.match(/xl\/worksheets\/_rels\/sheet(\d+)[.]xml.rels/),r=t[1],yield*this._parseHyperlinks(sz(e),r))}e.autodrain()}for(const{sheetNo:e,path:t,tempFileCleanupCallback:r}of i){let n=KB.createReadStream(t);n[Symbol.asyncIterator]||(n=n.pipe(new ez)),yield*this._parseWorksheet(n,e),r()}}_emitEntry(e){"emit"===this.options.entries&&this.emit("entry",e)}async _parseRels(e){const t=new hz;this.workbookRels=await t.parseStream(sz(e))}async _parseWorkbook(e){this._emitEntry({type:"workbook"});const t=new lz;await t.parseStream(sz(e)),this.properties=t.map.workbookPr,this.model=t.model}async*_parseSharedStrings(e){switch(this._emitEntry({type:"shared-strings"}),this.options.sharedStrings){case"cache":this.sharedStrings=[];break;case"emit":break;default:return}let t=null,r=[],n=0,i=null;for await(const s of oz(sz(e)))for(const{eventType:e,value:o}of s)if("opentag"===e){const e=o;switch(e.name){case"b":i=i||{},i.bold=!0;break;case"charset":i=i||{},i.charset=parseInt(e.attributes.charset,10);break;case"color":i=i||{},i.color={},e.attributes.rgb&&(i.color.argb=e.attributes.argb),e.attributes.val&&(i.color.argb=e.attributes.val),e.attributes.theme&&(i.color.theme=e.attributes.theme);break;case"family":i=i||{},i.family=parseInt(e.attributes.val,10);break;case"i":i=i||{},i.italic=!0;break;case"outline":i=i||{},i.outline=!0;break;case"rFont":i=i||{},i.name=e.value;break;case"si":i=null,r=[],t=null;break;case"sz":i=i||{},i.size=parseInt(e.attributes.val,10);break;case"strike":break;case"t":t=null;break;case"u":i=i||{},i.underline=!0;break;case"vertAlign":i=i||{},i.vertAlign=e.attributes.val}}else if("text"===e)t=t?t+o:o;else if("closetag"===e){switch(o.name){case"r":r.push({font:i,text:t}),i=null,t=null;break;case"si":"cache"===this.options.sharedStrings?this.sharedStrings.push(r.length?{richText:r}:t):"emit"===this.options.sharedStrings&&(yield{index:n++,text:r.length?{richText:r}:t}),r=[],i=null,t=null}}}async _parseStyles(e){this._emitEntry({type:"styles"}),"cache"===this.options.styles&&(this.styles=new az,await this.styles.parseStream(sz(e)))}*_parseWorksheet(e,t){this._emitEntry({type:"worksheet",id:t});const r=new uz({workbook:this,id:t,iterator:e,options:this.options}),n=(this.workbookRels||[]).find((e=>e.Target===`worksheets/sheet${t}.xml`)),i=n&&(this.model.sheets||[]).find((e=>e.rId===n.Id));i&&(r.id=i.id,r.name=i.name,r.state=i.state),"emit"===this.options.worksheets&&(yield{eventType:"worksheet",value:r})}*_parseHyperlinks(e,t){this._emitEntry({type:"hyperlinks",id:t});const r=new cz({workbook:this,id:t,iterator:e,options:this.options});"emit"===this.options.hyperlinks&&(yield{eventType:"hyperlinks",value:r})}}dz.Options={worksheets:["emit","ignore"],sharedStrings:["cache","emit","ignore"],hyperlinks:["cache","emit","ignore"],styles:["cache","ignore"],entries:["emit","ignore"]};const fz={Workbook:wx,ModelContainer:kx,stream:{xlsx:{WorkbookWriter:sD,WorkbookReader:dz}}};Object.assign(fz,A);var pz=fz;if(parseInt(process.versions.node.split(".")[0],10)<10)throw new Error("For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports");var mz=g(pz);function gz(e,t){let r="";for(let t=e+1;t>0;t=Math.floor((t-1)/26))r=String.fromCharCode((t-1)%26+65)+r;return r+(t+1)}var yz=(e,t)=>Object.prototype.toString.call(e)===`[object ${t}]`;var vz=e=>null!=e;var _z=e=>Array.isArray?Array.isArray(e):yz(e,"Array");var bz=function(e){const t=typeof e;return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?"number"===t:"number"===t||yz(e,"Number")};function wz(e){if(!e)return[0,0,0];if(e.startsWith("#")){let t=e.substring(1);3===t.length&&(t=t.replace(/(.)/g,"$1$1"));return[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16)]}if(e.startsWith("rgb(")){return e.substring(4,e.length-1).split(",").map(Number)}if(e.startsWith("rgba(")){return e.substring(5,e.length-1).split(",").map(Number)}if(bz(Sz[e]))return[(t=Sz[e])>>16,t>>8&255,255&t,1];if(bz(kz[e]))return function(e){return[e>>>24,e>>>16&255,e>>>8&255,255&e]}(kz[e]);var t;throw new Error("Unsupported color format")}function xz(e){if(3===e.length&&e.push(1),4!==e.length)throw new Error("Invalid RGBA array");const[t,r,n,i]=e.map(Math.round);return`${Math.round(255*i).toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}const kz={transparent:4294967040},Sz={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Ez(e,t){return{name:Cz(e.fontFamily)||"Arial",size:e.fontSize||10,bold:"bold"===e.fontWeight,italic:"italic"===e.fontStyle,color:Nz("link"===t?e._linkColor:e.color),underline:e.underline}}function Cz(e){return e.split(",").map((e=>e.trim()))[0]}function Tz(e){return{type:"pattern",pattern:"solid",fgColor:Nz(e.bgColor)}}function Oz(e){const{borderColor:t,borderLineWidth:r,borderLineDash:n,_strokeArrayWidth:i,_strokeArrayColor:s}=e;if(s||i){const e={};return s&&!s[0]||i&&!i[0]||(e.top={style:Rz(i?.[0]??r,n),color:Nz(s?.[0]??t)}),s&&!s[1]||i&&!i[1]||(e.right={style:Rz(i?.[1]??r,n),color:Nz(s?.[1]??t)}),s&&!s[2]||i&&!i[2]||(e.bottom={style:Rz(i?.[2]??r,n),color:Nz(s?.[2]??t)}),s&&!s[3]||i&&!i[3]||(e.left={style:Rz(i?.[3]??r,n),color:Nz(s?.[3]??t)}),e}if(0===r)return{};const o={style:Rz(r,n),color:Nz(t)};return{top:o,left:o,bottom:o,right:o}}function Rz(e,t){return t&&t.length?e<=2?"dashed":"mediumDashed":e<=.5?"hair":e<=1?"thin":e<=2?"medium":"thick"}function Az(e,t){return{horizontal:e.textAlign||"left",vertical:e.textBaseline||"middle",wrapText:e.autoWrapText||!1,indent:t||0}}function Nz(e){return{argb:xz(wz(e))}}function Iz(e,t,r){let n=0;const i=r.internalProps.layoutMap;if(i.isHeader(e,t)){const r=i.getHeader(e,t);vz(r?.hierarchyLevel)&&(n=(r.hierarchyLevel??0)*(i.rowHierarchyIndent??0))}else{const s=r.getBodyColumnDefine(e,t);if(s?.tree){const s=r.dataSource.getIndexKey(r.getRecordShowIndexByCell(e,t));n=Array.isArray(s)&&"none"!==r.getHierarchyState(e,t)?(s.length-1)*(i.hierarchyIndent??0):0}}return n}async function Pz(e,t,r,n,i,s){const{layoutMap:o}=r.internalProps,a=r.getCellType(e,t),l=r.getCellRawRecord(e,t);let h=(l&&l.vtableMergeName)??r.getCellValue(e,t);var u;!(u=h)||"object"!=typeof u&&"function"!=typeof u||"function"!=typeof u.then||(h=await h);const c=r.getCellStyle(e,t),d=r.getCellLocation(e,t),p="body"!==d?r.getHeaderDefine(e,t):r.getBodyColumnDefine(e,t);let m,g,y,v;if(("body"!==d||(p?.dragOrder||!!p?.icon||!!p?.tree))&&(m=r.getCellIcons(e,t)),"body"!==d?(g=p?.headerCustomRender,y=p?.headerCustomLayout):(g=p?.customRender||r.customRender,y=p?.customLayout),s?.formatExportOutput){const i={cellType:a,cellValue:h,table:r,col:e,row:t},o=s.formatExportOutput(i);if(void 0!==o){let i=n.getCell(gz(e,t));i.value=o,i.font=Ez(c,a),i.fill=Tz(c),i.border=Oz(c);const l=Iz(e,t,r);if(i.alignment=Az(c,Math.ceil(l/i.font.size)),i&&s?.formatExcelJSCell){const n=s.formatExcelJSCell({cellType:a,cellValue:h,table:r,col:e,row:t},i);n&&(i=n)}return i}}if("image"===a||"video"===a||"progressbar"===a||"sparkline"===a||o.isAxisCell(e,t)||!s?.ignoreIcon&&_z(m)&&m.length||g||y){const s=Fz(e,t,r),o=i.addImage({base64:s,extension:"png"});n.addImage(o,{tl:{col:e+1/80,row:t+1/120},br:{col:e+1,row:t+1},editAs:"oneCell"})}else if("text"===a||"link"===a){v=n.getCell(gz(e,t)),v.value=function(e,t){if("link"===t)return{text:e,hyperlink:e,tooltip:e};return e}(h,a),v.font=Ez(c,a),v.fill=Tz(c),v.border=Oz(c);const i=Iz(e,t,r);v.alignment=Az(c,Math.ceil(i/v.font.size))}else if("chart"===a){const s=r.scenegraph.getCell(e,t);f.renderChart(s.firstChild);const o=Fz(e,t,r),a=i.addImage({base64:o,extension:"png"});n.addImage(a,{tl:{col:e+1/80,row:t+1/120},br:{col:e+1,row:t+1},editAs:"oneCell"}),r.scenegraph.updateNextFrame()}if(v&&s?.formatExcelJSCell){const n=s.formatExcelJSCell({cellType:a,cellValue:h,table:r,col:e,row:t},v);n&&(v=n)}return v}function Fz(e,t,r){let n=r.scenegraph.getCell(e,t),i=!1;"empty"===n.role&&(n=f.updateCell(e,t,r,!0),n.setStage(r.scenegraph.stage),i=!0,n.stage.dirtyBounds.set(-1/0,-1/0,1/0,1/0));const s=n.attribute.stroke;n.attribute.stroke=!1;const o=f.graphicUtil.drawGraphicToCanvas(n,r.scenegraph.stage);return n.attribute.stroke=s,i&&n.parent?.removeChild(n),o.toDataURL()}e.downloadCsv=function(e,t){const r=new Blob([`\ufeff${e}`],{type:"text/csv;charset=utf-8"});b.saveAs(r,`${t}.csv`)},e.downloadExcel=function(e,t){const r=new Blob([e],{type:"application/octet-stream"});b.saveAs(r,`${t}.xlsx`)},e.exportVTableToCsv=function(e,t){const r=e.rowCount-1,n=e.colCount-1;let i="";for(let s=0;s<=r;s++){for(let r=0;r<=n;r++){const n=p(r,s,e,t);if("undefined"!=typeof Promise&&n instanceof Promise);else{const e=`${n}`;/^\[object .*\]$/.exec(e)||(i+=e)}i+=","}i+="\r\n"}return i},e.exportVTableToExcel=async function(e,t){const r=new mz.Workbook,n=r.addWorksheet("sheet1");n.properties.defaultRowHeight=40;const i=[],s=e.rowCount-1,o=e.colCount-1,a=[],l=new Set;for(let h=0;h<=o;h++){const o=e.getColWidth(h);i[h]={width:o/6};for(let i=0;i<=s;i++){if(0===h){const t=e.getRowHeight(i);n.getRow(i+1).height=t}await Pz(h,i,e,n,r,t);const s=e.getCellRange(h,i);if(s.start.col!==s.end.col||s.start.row!==s.end.row){const e=`${s.start.col},${s.start.row}:${s.end.col},${s.end.row}}`;l.has(e)||(l.add(e),a.push(s))}}}n.columns=i,a.forEach((e=>{n.mergeCells(e.start.row+1,e.start.col+1,e.end.row+1,e.end.col+1)}));const h=[];return e.frozenRowCount>0&&h.push({state:"frozen",ySplit:e.frozenRowCount,topLeftCell:gz(0,e.frozenRowCount)}),e.frozenColCount>0&&h.push({state:"frozen",xSplit:e.frozenColCount,topLeftCell:gz(e.frozenColCount,0)}),n.views=h,t?.excelJSWorksheetCallback&&t.excelJSWorksheetCallback(n),await r.xlsx.writeBuffer()}}));
91
+ */!function(e){const n=r,i=d,s=l,o=t,a={fs:n.constants,os:i.constants},h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",u=/XXXXXX/,c=3,f=(a.O_CREAT||a.fs.O_CREAT)|(a.O_EXCL||a.fs.O_EXCL)|(a.O_RDWR||a.fs.O_RDWR),p="win32"===i.platform(),m=a.EBADF||a.os.errno.EBADF,g=a.ENOENT||a.os.errno.ENOENT,y=[],v=n.rmdirSync.bind(n);let _=!1;function b(e,t){return n.rm(e,{recursive:!0},t)}function w(e){return n.rmSync(e,{recursive:!0})}function x(e,t){const r=N(e,t),i=r[0],s=r[1];try{P(i)}catch(e){return s(e)}let o=i.tries;!function e(){try{const t=I(i);n.stat(t,(function(r){if(!r)return o-- >0?e():s(new Error("Could not get a unique tmp filename, max tries reached "+t));s(null,t)}))}catch(e){s(e)}}()}function k(e){const t=N(e)[0];P(t);let r=t.tries;do{const e=I(t);try{n.statSync(e)}catch(t){return e}}while(r-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function S(e,t){const r=function(e){if(e&&!j(e))return t(e);t()};0<=e[0]?n.close(e[0],(function(){n.unlink(e[1],r)})):n.unlink(e[1],r)}function E(e){let t=null;try{0<=e[0]&&n.closeSync(e[0])}catch(e){if(!function(e){return M(e,-m,"EBADF")}(e)&&!j(e))throw e}finally{try{n.unlinkSync(e[1])}catch(e){j(e)||(t=e)}}if(null!==t)throw t}function C(e,t,r,n){const i=O(E,[t,e],n),s=O(S,[t,e],n,i);return r.keep||y.unshift(i),n?i:s}function T(e,t,r){const i=t.unsafeCleanup?b:n.rmdir.bind(n),s=O(t.unsafeCleanup?w:v,e,r),o=O(i,e,r,s);return t.keep||y.unshift(s),r?s:o}function O(e,t,r,n){let i=!1;return function s(o){if(!i){const a=n||s,l=y.indexOf(a);return l>=0&&y.splice(l,1),i=!0,r||e===v||e===w?e(t):e(t,o||function(){})}}}function R(e){let t=[],r=null;try{r=o.randomBytes(e)}catch(t){r=o.pseudoRandomBytes(e)}for(var n=0;n<e;n++)t.push(h[r[n]%h.length]);return t.join("")}function A(e){return void 0===e}function N(e,t){if("function"==typeof e)return[{},e];if(A(e))return[{},t];const r={};for(const t of Object.getOwnPropertyNames(e))r[t]=e[t];return[r,t]}function I(e){const t=e.tmpdir;if(!A(e.name))return s.join(t,e.dir,e.name);if(!A(e.template))return s.join(t,e.dir,e.template).replace(u,R(6));const r=[e.prefix?e.prefix:"tmp","-",process.pid,"-",R(12),e.postfix?"-"+e.postfix:""].join("");return s.join(t,e.dir,r)}function P(e){e.tmpdir=L(e);const t=e.tmpdir;if(A(e.name)||D(e.name,"name",t),A(e.dir)||D(e.dir,"dir",t),!A(e.template)&&(D(e.template,"template",t),!e.template.match(u)))throw new Error(`Invalid template, found "${e.template}".`);if(!A(e.tries)&&isNaN(e.tries)||e.tries<0)throw new Error(`Invalid tries, found "${e.tries}".`);e.tries=A(e.name)?e.tries||c:1,e.keep=!!e.keep,e.detachDescriptor=!!e.detachDescriptor,e.discardDescriptor=!!e.discardDescriptor,e.unsafeCleanup=!!e.unsafeCleanup,e.dir=A(e.dir)?"":s.relative(t,F(e.dir,t)),e.template=A(e.template)?void 0:s.relative(t,F(e.template,t)),e.template=function(e){return null===e||A(e)||!e.trim()}(e.template)?void 0:s.relative(e.dir,e.template),e.name=A(e.name)?void 0:e.name,e.prefix=A(e.prefix)?"":e.prefix,e.postfix=A(e.postfix)?"":e.postfix}function F(e,t){return e.startsWith(t)?s.resolve(e):s.resolve(s.join(t,e))}function D(e,t,r){if("name"===t){if(s.isAbsolute(e))throw new Error(`${t} option must not contain an absolute path, found "${e}".`);let r=s.basename(e);if(".."===r||"."===r||r!==e)throw new Error(`${t} option must not contain a path, found "${e}".`)}else{if(s.isAbsolute(e)&&!e.startsWith(r))throw new Error(`${t} option must be relative to "${r}", found "${e}".`);let n=F(e,r);if(!n.startsWith(r))throw new Error(`${t} option must be relative to "${r}", found "${n}".`)}}function j(e){return M(e,-g,"ENOENT")}function M(e,t,r){return p?e.code===r:e.code===r&&e.errno===t}function L(e){return s.resolve(e&&e.tmpdir||i.tmpdir())}process.addListener("exit",(function(){if(_)for(;y.length;)try{y[0]()}catch(e){}})),Object.defineProperty(e.exports,"tmpdir",{enumerable:!0,configurable:!1,get:function(){return L()}}),e.exports.dir=function(e,t){const r=N(e,t),i=r[0],s=r[1];x(i,(function(e,t){if(e)return s(e);n.mkdir(t,i.mode||448,(function(e){if(e)return s(e);s(null,t,T(t,i,!1))}))}))},e.exports.dirSync=function(e){const t=N(e)[0],r=k(t);return n.mkdirSync(r,t.mode||448),{name:r,removeCallback:T(r,t,!0)}},e.exports.file=function(e,t){const r=N(e,t),i=r[0],s=r[1];x(i,(function(e,t){if(e)return s(e);n.open(t,f,i.mode||384,(function(e,r){if(e)return s(e);if(i.discardDescriptor)return n.close(r,(function(e){return s(e,t,void 0,C(t,-1,i,!1))}));{const e=i.discardDescriptor||i.detachDescriptor;s(null,t,r,C(t,e?-1:r,i,!1))}}))}))},e.exports.fileSync=function(e){const t=N(e)[0],r=t.discardDescriptor||t.detachDescriptor,i=k(t);var s=n.openSync(i,f,t.mode||384);return t.discardDescriptor&&(n.closeSync(s),s=void 0),{name:i,fd:s,removeCallback:C(i,r?-1:s,t,!0)}},e.exports.tmpName=x,e.exports.tmpNameSync=k,e.exports.setGracefulCleanup=function(){_=!0}}(FB);var DB=FB.exports;function jB(e,t){return new Promise((r=>{let n=!1;const i=()=>{n||(n=!0,e.removeListener(t,i),r())};e.addListener(t,i)}))}const{EventEmitter:MB}=i,LB=Vh,BB=S,zB=Ol,$B=T,HB=R,UB=G,VB=J;let WB=class extends MB{constructor(e){let{workbook:t,id:r,iterator:n,options:i}=e;super(),this.workbook=t,this.id=r,this.iterator=n,this.options=i||{},this.name=`Sheet${this.id}`,this._columns=null,this._keys={},this._dimensions=new HB}destroy(){throw new Error("Invalid Operation: destroy")}get dimensions(){return this._dimensions}get columns(){return this._columns}getColumn(e){if("string"==typeof e){const t=this._keys[e];if(t)return t;e=$B.l2n(e)}if(this._columns||(this._columns=[]),e>this._columns.length){let t=this._columns.length+1;for(;t<=e;)this._columns.push(new VB(this,t++))}return this._columns[e-1]}getColumnKey(e){return this._keys[e]}setColumnKey(e,t){this._keys[e]=t}deleteColumnKey(e){delete this._keys[e]}eachColumnKey(e){BB.each(this._keys,e)}async read(){try{for await(const e of this.parse())for(const{eventType:t,value:r}of e)this.emit(t,r);this.emit("finished")}catch(e){this.emit("error",e)}}async*[Symbol.asyncIterator](){for await(const e of this.parse())for(const{eventType:t,value:r}of e)"row"===t&&(yield r)}async*parse(){const{iterator:e,options:t}=this;let r=!1,n=!1,i=null;if("emit"===t.worksheets)r=!0;switch(t.hyperlinks){case"emit":n=!0;break;case"cache":this.hyperlinks=i={}}if(!r&&!n&&!i)return;const{sharedStrings:s,styles:o,properties:a}=this.workbook;let l=!1,h=!1,u=!1,c=null,d=null,f=null,p=null;for await(const t of LB(e)){const e=[];for(const{eventType:m,value:g}of t)if("opentag"===m){const t=g;if(r)switch(t.name){case"cols":l=!0,c=[];break;case"sheetData":h=!0;break;case"col":l&&c.push({min:parseInt(t.attributes.min,10),max:parseInt(t.attributes.max,10),width:parseFloat(t.attributes.width),styleId:parseInt(t.attributes.style||"0",10)});break;case"row":if(h){const e=parseInt(t.attributes.r,10);if(d=new UB(this,e),t.attributes.ht&&(d.height=parseFloat(t.attributes.ht)),t.attributes.s){const e=parseInt(t.attributes.s,10),r=o.getStyleModel(e);r&&(d.style=r)}}break;case"c":d&&(f={ref:t.attributes.r,s:parseInt(t.attributes.s,10),t:t.attributes.t});break;case"f":f&&(p=f.f={text:""});break;case"v":case"is":case"t":f&&(p=f.v={text:""})}if(n||i)switch(t.name){case"hyperlinks":u=!0;break;case"hyperlink":if(u){const r={ref:t.attributes.ref,rId:t.attributes["r:id"]};n?e.push({eventType:"hyperlink",value:r}):i[r.ref]=r}}}else if("text"===m)r&&p&&(p.text+=g);else if("closetag"===m){const t=g;if(r)switch(t.name){case"cols":l=!1,this._columns=VB.fromModel(c);break;case"sheetData":h=!1;break;case"row":this._dimensions.expandRow(d),e.push({eventType:"row",value:d}),d=null;break;case"c":if(d&&f){const e=$B.decodeAddress(f.ref),t=d.getCell(e.col);if(f.s){const e=o.getStyleModel(f.s);e&&(t.style=e)}if(f.f){const e={formula:f.f.text};f.v&&("str"===f.t?e.result=zB.xmlDecode(f.v.text):e.result=parseFloat(f.v.text)),t.value=e}else if(f.v)switch(f.t){case"s":{const e=parseInt(f.v.text,10);t.value=s?s[e]:{sharedString:e};break}case"inlineStr":case"str":t.value=zB.xmlDecode(f.v.text);break;case"e":t.value={error:f.v.text};break;case"b":t.value=0!==parseInt(f.v.text,10);break;default:zB.isDateFmt(t.numFmt)?t.value=zB.excelToDate(parseFloat(f.v.text),a.model&&a.model.date1904):t.value=parseFloat(f.v.text)}if(i){const e=i[f.ref];e&&(t.text=t.value,t.value=void 0,t.hyperlink=e)}f=null}}if((n||i)&&"hyperlinks"===t.name)u=!1}e.length>0&&(yield e)}}};var qB=WB;const{EventEmitter:XB}=i,ZB=Vh,GB=A,YB=$d;var QB=class extends XB{constructor(e){let{workbook:t,id:r,iterator:n,options:i}=e;super(),this.workbook=t,this.id=r,this.iterator=n,this.options=i}get count(){return this.hyperlinks&&this.hyperlinks.length||0}each(e){return this.hyperlinks.forEach(e)}async read(){const{iterator:e,options:t}=this;let r=!1,n=null;switch(t.hyperlinks){case"emit":r=!0;break;case"cache":this.hyperlinks=n={}}if(r||n)try{for await(const t of ZB(e))for(const{eventType:e,value:i}of t)if("opentag"===e){const e=i;if("Relationship"===e.name){const t=e.attributes.Id;if(e.attributes.Type===YB.Hyperlink){const i={type:GB.RelationshipType.Styles,rId:t,target:e.attributes.Target,targetMode:e.attributes.TargetMode};r?this.emit("hyperlink",i):n[i.rId]=i}}}this.emit("finished")}catch(e){this.emit("error",e)}else this.emit("finished")}};const KB=r,{EventEmitter:JB}=i,{PassThrough:ez,Readable:tz}=Sl,rz=n,nz=oD,iz=DB,sz=async function*(e){const t=[];let r;e.on("data",(e=>t.push(e)));const n=new Promise((e=>r=e));let i=!1;e.on("end",(()=>{i=!0,r()}));let s=!1;for(e.on("error",(e=>{s=e,r()}));!i||t.length>0;){if(0===t.length)e.resume(),await Promise.race([jB(e,"data"),n]);else{e.pause();const r=t.shift();yield r}if(s)throw s}r()},oz=Vh,az=gc,lz=zd,hz=Kc,uz=qB,cz=QB;iz.setGracefulCleanup();class dz extends JB{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this.input=e,this.options={worksheets:"emit",sharedStrings:"cache",hyperlinks:"ignore",styles:"ignore",entries:"ignore",...t},this.styles=new az,this.styles.init()}_getStream(e){if(e instanceof rz.Readable||e instanceof tz)return e;if("string"==typeof e)return KB.createReadStream(e);throw new Error(`Could not recognise input: ${e}`)}async read(e,t){try{for await(const{eventType:r,value:n}of this.parse(e,t))switch(r){case"shared-strings":case"hyperlinks":this.emit(r,n);break;case"worksheet":this.emit(r,n),await n.read()}this.emit("end"),this.emit("finished")}catch(e){this.emit("error",e)}}async*[Symbol.asyncIterator](){for await(const{eventType:e,value:t}of this.parse())"worksheet"===e&&(yield t)}async*parse(e,t){t&&(this.options=t);const r=this.stream=this._getStream(e||this.input),n=nz.Parse({forceStream:!0});r.pipe(n);const i=[];for await(const e of sz(n)){let t,r;switch(e.path){case"_rels/.rels":break;case"xl/_rels/workbook.xml.rels":await this._parseRels(e);break;case"xl/workbook.xml":await this._parseWorkbook(e);break;case"xl/sharedStrings.xml":yield*this._parseSharedStrings(e);break;case"xl/styles.xml":await this._parseStyles(e);break;default:e.path.match(/xl\/worksheets\/sheet\d+[.]xml/)?(t=e.path.match(/xl\/worksheets\/sheet(\d+)[.]xml/),r=t[1],this.sharedStrings&&this.workbookRels?yield*this._parseWorksheet(sz(e),r):await new Promise(((t,n)=>{iz.file(((s,o,a,l)=>{if(s)return n(s);i.push({sheetNo:r,path:o,tempFileCleanupCallback:l});const h=KB.createWriteStream(o);return h.on("error",n),e.pipe(h),h.on("finish",(()=>t()))}))}))):e.path.match(/xl\/worksheets\/_rels\/sheet\d+[.]xml.rels/)&&(t=e.path.match(/xl\/worksheets\/_rels\/sheet(\d+)[.]xml.rels/),r=t[1],yield*this._parseHyperlinks(sz(e),r))}e.autodrain()}for(const{sheetNo:e,path:t,tempFileCleanupCallback:r}of i){let n=KB.createReadStream(t);n[Symbol.asyncIterator]||(n=n.pipe(new ez)),yield*this._parseWorksheet(n,e),r()}}_emitEntry(e){"emit"===this.options.entries&&this.emit("entry",e)}async _parseRels(e){const t=new hz;this.workbookRels=await t.parseStream(sz(e))}async _parseWorkbook(e){this._emitEntry({type:"workbook"});const t=new lz;await t.parseStream(sz(e)),this.properties=t.map.workbookPr,this.model=t.model}async*_parseSharedStrings(e){switch(this._emitEntry({type:"shared-strings"}),this.options.sharedStrings){case"cache":this.sharedStrings=[];break;case"emit":break;default:return}let t=null,r=[],n=0,i=null;for await(const s of oz(sz(e)))for(const{eventType:e,value:o}of s)if("opentag"===e){const e=o;switch(e.name){case"b":i=i||{},i.bold=!0;break;case"charset":i=i||{},i.charset=parseInt(e.attributes.charset,10);break;case"color":i=i||{},i.color={},e.attributes.rgb&&(i.color.argb=e.attributes.argb),e.attributes.val&&(i.color.argb=e.attributes.val),e.attributes.theme&&(i.color.theme=e.attributes.theme);break;case"family":i=i||{},i.family=parseInt(e.attributes.val,10);break;case"i":i=i||{},i.italic=!0;break;case"outline":i=i||{},i.outline=!0;break;case"rFont":i=i||{},i.name=e.value;break;case"si":i=null,r=[],t=null;break;case"sz":i=i||{},i.size=parseInt(e.attributes.val,10);break;case"strike":break;case"t":t=null;break;case"u":i=i||{},i.underline=!0;break;case"vertAlign":i=i||{},i.vertAlign=e.attributes.val}}else if("text"===e)t=t?t+o:o;else if("closetag"===e){switch(o.name){case"r":r.push({font:i,text:t}),i=null,t=null;break;case"si":"cache"===this.options.sharedStrings?this.sharedStrings.push(r.length?{richText:r}:t):"emit"===this.options.sharedStrings&&(yield{index:n++,text:r.length?{richText:r}:t}),r=[],i=null,t=null}}}async _parseStyles(e){this._emitEntry({type:"styles"}),"cache"===this.options.styles&&(this.styles=new az,await this.styles.parseStream(sz(e)))}*_parseWorksheet(e,t){this._emitEntry({type:"worksheet",id:t});const r=new uz({workbook:this,id:t,iterator:e,options:this.options}),n=(this.workbookRels||[]).find((e=>e.Target===`worksheets/sheet${t}.xml`)),i=n&&(this.model.sheets||[]).find((e=>e.rId===n.Id));i&&(r.id=i.id,r.name=i.name,r.state=i.state),"emit"===this.options.worksheets&&(yield{eventType:"worksheet",value:r})}*_parseHyperlinks(e,t){this._emitEntry({type:"hyperlinks",id:t});const r=new cz({workbook:this,id:t,iterator:e,options:this.options});"emit"===this.options.hyperlinks&&(yield{eventType:"hyperlinks",value:r})}}dz.Options={worksheets:["emit","ignore"],sharedStrings:["cache","emit","ignore"],hyperlinks:["cache","emit","ignore"],styles:["cache","ignore"],entries:["emit","ignore"]};const fz={Workbook:wx,ModelContainer:kx,stream:{xlsx:{WorkbookWriter:sD,WorkbookReader:dz}}};Object.assign(fz,A);var pz=fz;if(parseInt(process.versions.node.split(".")[0],10)<10)throw new Error("For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports");var mz=g(pz);function gz(e,t){let r="";for(let t=e+1;t>0;t=Math.floor((t-1)/26))r=String.fromCharCode((t-1)%26+65)+r;return r+(t+1)}var yz=(e,t)=>Object.prototype.toString.call(e)===`[object ${t}]`;var vz=e=>null!=e;var _z=e=>Array.isArray?Array.isArray(e):yz(e,"Array");var bz=function(e){const t=typeof e;return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?"number"===t:"number"===t||yz(e,"Number")};function wz(e){if(!e)return[0,0,0];if(e.startsWith("#")){let t=e.substring(1);3===t.length&&(t=t.replace(/(.)/g,"$1$1"));return[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16)]}if(e.startsWith("rgb(")){return e.substring(4,e.length-1).split(",").map(Number)}if(e.startsWith("rgba(")){return e.substring(5,e.length-1).split(",").map(Number)}if(bz(Sz[e]))return[(t=Sz[e])>>16,t>>8&255,255&t,1];if(bz(kz[e]))return function(e){return[e>>>24,e>>>16&255,e>>>8&255,255&e]}(kz[e]);var t;throw new Error("Unsupported color format")}function xz(e){if(3===e.length&&e.push(1),4!==e.length)throw new Error("Invalid RGBA array");const[t,r,n,i]=e.map(Math.round);return`${Math.round(255*i).toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}const kz={transparent:4294967040},Sz={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Ez(e,t){return{name:Tz(e.fontFamily)||"Arial",size:e.fontSize||10,bold:Cz(e.fontWeight),italic:"italic"===e.fontStyle,color:Iz("link"===t?e._linkColor:e.color),underline:e.underline}}function Cz(e){return"number"==typeof e?e>=600:Number(e)>=600||"bold"===e}function Tz(e){return e.split(",").map((e=>e.trim()))[0]}function Oz(e){return{type:"pattern",pattern:"solid",fgColor:Iz(e.bgColor)}}function Rz(e){const{borderColor:t,borderLineWidth:r,borderLineDash:n,_strokeArrayWidth:i,_strokeArrayColor:s}=e;if(s||i){const e={};return s&&!s[0]||i&&!i[0]||(e.top={style:Az(i?.[0]??r,n),color:Iz(s?.[0]??t)}),s&&!s[1]||i&&!i[1]||(e.right={style:Az(i?.[1]??r,n),color:Iz(s?.[1]??t)}),s&&!s[2]||i&&!i[2]||(e.bottom={style:Az(i?.[2]??r,n),color:Iz(s?.[2]??t)}),s&&!s[3]||i&&!i[3]||(e.left={style:Az(i?.[3]??r,n),color:Iz(s?.[3]??t)}),e}if(0===r)return{};const o={style:Az(r,n),color:Iz(t)};return{top:o,left:o,bottom:o,right:o}}function Az(e,t){return t&&t.length?e<=2?"dashed":"mediumDashed":e<=.5?"hair":e<=1?"thin":e<=2?"medium":"thick"}function Nz(e,t){return{horizontal:e.textAlign||"left",vertical:e.textBaseline||"middle",wrapText:e.autoWrapText||!1,indent:t||0}}function Iz(e){return{argb:xz(wz(e))}}function Pz(e,t,r){let n=0;const i=r.internalProps.layoutMap;if(i.isHeader(e,t)){const r=i.getHeader(e,t);vz(r?.hierarchyLevel)&&(n=(r.hierarchyLevel??0)*(i.rowHierarchyIndent??0))}else{const s=r.getBodyColumnDefine(e,t);if(s?.tree){const s=r.dataSource.getIndexKey(r.getRecordShowIndexByCell(e,t));n=Array.isArray(s)&&"none"!==r.getHierarchyState(e,t)?(s.length-1)*(i.hierarchyIndent??0):0}}return n}async function Fz(e,t,r,n,i,s){const{layoutMap:o}=r.internalProps,a=r.getCellType(e,t),l=r.getCellRawRecord(e,t);let h=(l&&l.vtableMergeName)??r.getCellValue(e,t);var u;!(u=h)||"object"!=typeof u&&"function"!=typeof u||"function"!=typeof u.then||(h=await h);const c=r.getCellStyle(e,t),d=r.getCellLocation(e,t),p="body"!==d?r.getHeaderDefine(e,t):r.getBodyColumnDefine(e,t);let m,g,y,v;if(("body"!==d||(p?.dragOrder||!!p?.icon||!!p?.tree))&&(m=r.getCellIcons(e,t)),"body"!==d?(g=p?.headerCustomRender,y=p?.headerCustomLayout):(g=p?.customRender||r.customRender,y=p?.customLayout),s?.formatExportOutput){const i={cellType:a,cellValue:h,table:r,col:e,row:t},o=s.formatExportOutput(i);if(void 0!==o){let i=n.getCell(gz(e,t));i.value=o,i.font=Ez(c,a),i.fill=Oz(c),i.border=Rz(c);const l=Pz(e,t,r);if(i.alignment=Nz(c,Math.ceil(l/i.font.size)),i&&s?.formatExcelJSCell){const n=s.formatExcelJSCell({cellType:a,cellValue:h,table:r,col:e,row:t},i);n&&(i=n)}return i}}if("image"===a||"video"===a||"progressbar"===a||"sparkline"===a||o.isAxisCell(e,t)||!s?.ignoreIcon&&_z(m)&&m.length||g||y){const s=Dz(e,t,r),o=i.addImage({base64:s,extension:"png"});n.addImage(o,{tl:{col:e+1/80,row:t+1/120},br:{col:e+1,row:t+1},editAs:"oneCell"})}else if("text"===a||"link"===a){v=n.getCell(gz(e,t)),v.value=function(e,t){if("link"===t)return{text:e,hyperlink:e,tooltip:e};return e}(h,a),v.font=Ez(c,a),v.fill=Oz(c),v.border=Rz(c);const i=Pz(e,t,r);v.alignment=Nz(c,Math.ceil(i/v.font.size))}else if("chart"===a){const s=r.scenegraph.getCell(e,t);f.renderChart(s.firstChild);const o=Dz(e,t,r),a=i.addImage({base64:o,extension:"png"});n.addImage(a,{tl:{col:e+1/80,row:t+1/120},br:{col:e+1,row:t+1},editAs:"oneCell"}),r.scenegraph.updateNextFrame()}if(v&&s?.formatExcelJSCell){const n=s.formatExcelJSCell({cellType:a,cellValue:h,table:r,col:e,row:t},v);n&&(v=n)}return v}function Dz(e,t,r){let n=r.scenegraph.getCell(e,t),i=!1;"empty"===n.role&&(n=f.updateCell(e,t,r,!0),n.setStage(r.scenegraph.stage),i=!0,n.stage.dirtyBounds.set(-1/0,-1/0,1/0,1/0));const s=n.attribute.stroke;n.attribute.stroke=!1;const o=f.graphicUtil.drawGraphicToCanvas(n,r.scenegraph.stage);return n.attribute.stroke=s,i&&n.parent?.removeChild(n),o.toDataURL()}e.downloadCsv=function(e,t){const r=new Blob([`\ufeff${e}`],{type:"text/csv;charset=utf-8"});b.saveAs(r,`${t}.csv`)},e.downloadExcel=function(e,t){const r=new Blob([e],{type:"application/octet-stream"});b.saveAs(r,`${t}.xlsx`)},e.exportVTableToCsv=function(e,t){const r=e.rowCount-1,n=e.colCount-1;let i="";for(let s=0;s<=r;s++){for(let r=0;r<=n;r++){const n=p(r,s,e,t);if("undefined"!=typeof Promise&&n instanceof Promise);else{const e=`${n}`;/^\[object .*\]$/.exec(e)||(i+=e)}i+=","}i+="\r\n"}return i},e.exportVTableToExcel=async function(e,t){const r=new mz.Workbook,n=r.addWorksheet("sheet1");n.properties.defaultRowHeight=40;const i=[],s=e.rowCount-1,o=e.colCount-1,a=[],l=new Set;for(let h=0;h<=o;h++){const o=e.getColWidth(h);i[h]={width:o/6};for(let i=0;i<=s;i++){if(0===h){const t=e.getRowHeight(i);n.getRow(i+1).height=t}await Fz(h,i,e,n,r,t);const s=e.getCellRange(h,i);if(s.start.col!==s.end.col||s.start.row!==s.end.row){const e=`${s.start.col},${s.start.row}:${s.end.col},${s.end.row}}`;l.has(e)||(l.add(e),a.push(s))}}}n.columns=i,a.forEach((e=>{n.mergeCells(e.start.row+1,e.start.col+1,e.end.row+1,e.end.col+1)}));const h=[];return e.frozenRowCount>0&&h.push({state:"frozen",ySplit:e.frozenRowCount,topLeftCell:gz(0,e.frozenRowCount)}),e.frozenColCount>0&&h.push({state:"frozen",xSplit:e.frozenColCount,topLeftCell:gz(e.frozenColCount,0)}),n.views=h,t?.excelJSWorksheetCallback&&t.excelJSWorksheetCallback(n),await r.xlsx.writeBuffer()}}));
package/es/excel/style.js CHANGED
@@ -4,13 +4,17 @@ export function getCellFont(cellStyle, cellType) {
4
4
  return {
5
5
  name: getFirstFontFromFontFamily(cellStyle.fontFamily) || "Arial",
6
6
  size: cellStyle.fontSize || 10,
7
- bold: "bold" === cellStyle.fontWeight,
7
+ bold: isFontBold(cellStyle.fontWeight),
8
8
  italic: "italic" === cellStyle.fontStyle,
9
9
  color: getColor("link" === cellType ? cellStyle._linkColor : cellStyle.color),
10
10
  underline: cellStyle.underline
11
11
  };
12
12
  }
13
13
 
14
+ function isFontBold(fontWeight) {
15
+ return "number" == typeof fontWeight ? fontWeight >= 600 : Number(fontWeight) >= 600 || "bold" === fontWeight;
16
+ }
17
+
14
18
  function getFirstFontFromFontFamily(fontFamily) {
15
19
  return fontFamily.split(",").map((font => font.trim()))[0];
16
20
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["excel/style.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG5D,MAAM,UAAU,WAAW,CAAC,SAAoB,EAAE,QAAkB;IAClE,OAAO;QACL,IAAI,EAAE,0BAA0B,CAAC,SAAS,CAAC,UAAoB,CAAC,IAAI,OAAO;QAC3E,IAAI,EAAE,SAAS,CAAC,QAAQ,IAAI,EAAE;QAC9B,IAAI,EAAE,SAAS,CAAC,UAAU,KAAK,MAAM;QACrC,MAAM,EAAE,SAAS,CAAC,SAAS,KAAK,QAAQ;QACxC,KAAK,EAAE,QAAQ,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,C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CAAC,CAAC;KACzC,CAAC;AACJ,CAAC","file":"style.js","sourcesContent":["import type ExcelJS from 'exceljs';\nimport { colorStringToRGB, rgbaToHex } from '../util/color';\nimport type { CellStyle, CellType, LineDashsDef } from '../util/type';\n\nexport function getCellFont(cellStyle: CellStyle, cellType: CellType): Partial<ExcelJS.Font> {\n return {\n name: getFirstFontFromFontFamily(cellStyle.fontFamily as string) || 'Arial', // only one font family name\n size: cellStyle.fontSize || 10,\n bold: cellStyle.fontWeight === 'bold', // only bold or not\n italic: cellStyle.fontStyle === 'italic', // only italic or not\n color: getColor(cellType === 'link' ? (cellStyle._linkColor as string) : (cellStyle.color as string)),\n underline: cellStyle.underline\n };\n}\n\nfunction getFirstFontFromFontFamily(fontFamily: string) {\n const fonts = fontFamily.split(',').map(font => font.trim());\n return fonts[0];\n}\n\nexport function getCellFill(cellStyle: CellStyle): ExcelJS.Fill {\n return {\n type: 'pattern',\n pattern: 'solid',\n fgColor: getColor(cellStyle.bgColor as string)\n };\n}\n\nexport function getCellBorder(cellStyle: CellStyle): Partial<ExcelJS.Borders> {\n const { borderColor, borderLineWidth, borderLineDash, _strokeArrayWidth, _strokeArrayColor } = cellStyle;\n if (_strokeArrayColor || _strokeArrayWidth) {\n const border: Partial<ExcelJS.Borders> = {};\n if (!((_strokeArrayColor && !_strokeArrayColor[0]) || (_strokeArrayWidth && !_strokeArrayWidth[0]))) {\n border.top = {\n style: getBorderStyle((_strokeArrayWidth?.[0] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[0] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[1]) || (_strokeArrayWidth && !_strokeArrayWidth[1]))) {\n border.right = {\n style: getBorderStyle((_strokeArrayWidth?.[1] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[1] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[2]) || (_strokeArrayWidth && !_strokeArrayWidth[2]))) {\n border.bottom = {\n style: getBorderStyle((_strokeArrayWidth?.[2] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[2] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[3]) || (_strokeArrayWidth && !_strokeArrayWidth[3]))) {\n border.left = {\n style: getBorderStyle((_strokeArrayWidth?.[3] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[3] as string) ?? (borderColor as string))\n };\n }\n return border;\n }\n\n if (borderLineWidth === 0) {\n return {};\n }\n const border = {\n style: getBorderStyle(borderLineWidth as number, borderLineDash),\n color: getColor(borderColor as string)\n };\n return {\n top: border,\n left: border,\n bottom: border,\n right: border\n };\n}\n\nfunction getBorderStyle(lineWidth: number, borderLineDash: LineDashsDef): ExcelJS.BorderStyle {\n // hair:0.5\n // thin:1\n // medium:2.0\n // thick:3.0\n if (borderLineDash && borderLineDash.length) {\n if (lineWidth <= 2) {\n return 'dashed';\n }\n return 'mediumDashed';\n }\n if (lineWidth <= 0.5) {\n return 'hair';\n } else if (lineWidth <= 1) {\n return 'thin';\n } else if (lineWidth <= 2) {\n return 'medium';\n }\n return 'thick';\n}\n\nexport function getCellAlignment(cellStyle: CellStyle, indent: number): Partial<ExcelJS.Alignment> {\n return {\n horizontal: cellStyle.textAlign || 'left',\n vertical: cellStyle.textBaseline || 'middle',\n wrapText: cellStyle.autoWrapText || false,\n indent: indent || 0\n } as any;\n}\n\nfunction getColor(color: string) {\n // to do: support gradient color\n return {\n argb: rgbaToHex(colorStringToRGB(color))\n };\n}\n"]}
1
+ {"version":3,"sources":["excel/style.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG5D,MAAM,UAAU,WAAW,CAAC,SAAoB,EAAE,QAAkB;IAClE,OAAO;QACL,IAAI,EAAE,0BAA0B,CAAC,SAAS,CAAC,UAAoB,C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AAO,MAAM,CAAC;KACf;SAAM,IAAI,SAAS,IAAI,CAAC,EAAE;QACzB,OAAO,QAAQ,CAAC;KACjB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,SAAoB,EAAE,MAAc;IACnE,OAAO;QACL,UAAU,EAAE,SAAS,CAAC,SAAS,IAAI,MAAM;QACzC,QAAQ,EAAE,SAAS,CAAC,YAAY,IAAI,QAAQ;QAC5C,QAAQ,EAAE,SAAS,CAAC,YAAY,IAAI,KAAK;QACzC,MAAM,EAAE,MAAM,IAAI,CAAC;KACb,CAAC;AACX,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAE7B,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;KACzC,CAAC;AACJ,CAAC","file":"style.js","sourcesContent":["import type ExcelJS from 'exceljs';\nimport { colorStringToRGB, rgbaToHex } from '../util/color';\nimport type { CellStyle, CellType, LineDashsDef } from '../util/type';\n\nexport function getCellFont(cellStyle: CellStyle, cellType: CellType): Partial<ExcelJS.Font> {\n return {\n name: getFirstFontFromFontFamily(cellStyle.fontFamily as string) || 'Arial', // only one font family name\n size: cellStyle.fontSize || 10,\n // bold: cellStyle.fontWeight === 'bold', // only bold or not\n bold: isFontBold(cellStyle.fontWeight), // only bold or not\n italic: cellStyle.fontStyle === 'italic', // only italic or not\n color: getColor(cellType === 'link' ? (cellStyle._linkColor as string) : (cellStyle.color as string)),\n underline: cellStyle.underline\n };\n}\n\nfunction isFontBold(fontWeight: string | number) {\n if (typeof fontWeight === 'number') {\n return fontWeight >= 600;\n }\n if (Number(fontWeight) >= 600) {\n return true;\n }\n return fontWeight === 'bold';\n}\n\nfunction getFirstFontFromFontFamily(fontFamily: string) {\n const fonts = fontFamily.split(',').map(font => font.trim());\n return fonts[0];\n}\n\nexport function getCellFill(cellStyle: CellStyle): ExcelJS.Fill {\n return {\n type: 'pattern',\n pattern: 'solid',\n fgColor: getColor(cellStyle.bgColor as string)\n };\n}\n\nexport function getCellBorder(cellStyle: CellStyle): Partial<ExcelJS.Borders> {\n const { borderColor, borderLineWidth, borderLineDash, _strokeArrayWidth, _strokeArrayColor } = cellStyle;\n if (_strokeArrayColor || _strokeArrayWidth) {\n const border: Partial<ExcelJS.Borders> = {};\n if (!((_strokeArrayColor && !_strokeArrayColor[0]) || (_strokeArrayWidth && !_strokeArrayWidth[0]))) {\n border.top = {\n style: getBorderStyle((_strokeArrayWidth?.[0] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[0] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[1]) || (_strokeArrayWidth && !_strokeArrayWidth[1]))) {\n border.right = {\n style: getBorderStyle((_strokeArrayWidth?.[1] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[1] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[2]) || (_strokeArrayWidth && !_strokeArrayWidth[2]))) {\n border.bottom = {\n style: getBorderStyle((_strokeArrayWidth?.[2] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[2] as string) ?? (borderColor as string))\n };\n }\n if (!((_strokeArrayColor && !_strokeArrayColor[3]) || (_strokeArrayWidth && !_strokeArrayWidth[3]))) {\n border.left = {\n style: getBorderStyle((_strokeArrayWidth?.[3] as number) ?? (borderLineWidth as number), borderLineDash),\n color: getColor((_strokeArrayColor?.[3] as string) ?? (borderColor as string))\n };\n }\n return border;\n }\n\n if (borderLineWidth === 0) {\n return {};\n }\n const border = {\n style: getBorderStyle(borderLineWidth as number, borderLineDash),\n color: getColor(borderColor as string)\n };\n return {\n top: border,\n left: border,\n bottom: border,\n right: border\n };\n}\n\nfunction getBorderStyle(lineWidth: number, borderLineDash: LineDashsDef): ExcelJS.BorderStyle {\n // hair:0.5\n // thin:1\n // medium:2.0\n // thick:3.0\n if (borderLineDash && borderLineDash.length) {\n if (lineWidth <= 2) {\n return 'dashed';\n }\n return 'mediumDashed';\n }\n if (lineWidth <= 0.5) {\n return 'hair';\n } else if (lineWidth <= 1) {\n return 'thin';\n } else if (lineWidth <= 2) {\n return 'medium';\n }\n return 'thick';\n}\n\nexport function getCellAlignment(cellStyle: CellStyle, indent: number): Partial<ExcelJS.Alignment> {\n return {\n horizontal: cellStyle.textAlign || 'left',\n vertical: cellStyle.textBaseline || 'middle',\n wrapText: cellStyle.autoWrapText || false,\n indent: indent || 0\n } as any;\n}\n\nfunction getColor(color: string) {\n // to do: support gradient color\n return {\n argb: rgbaToHex(colorStringToRGB(color))\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vtable-export",
3
- "version": "1.13.3-alpha.4",
3
+ "version": "1.13.3-alpha.6",
4
4
  "description": "The export util of VTable",
5
5
  "author": {
6
6
  "name": "VisActor",
@@ -30,14 +30,14 @@
30
30
  "access": "public"
31
31
  },
32
32
  "dependencies": {
33
- "@visactor/vtable": "1.13.3-alpha.4",
33
+ "@visactor/vtable": "1.13.3-alpha.6",
34
34
  "@visactor/vutils": "~0.18.14",
35
35
  "file-saver": "2.0.5",
36
36
  "@types/file-saver": "2.0.7",
37
37
  "exceljs": "4.4.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@visactor/vchart": "1.12.12",
40
+ "@visactor/vchart": "1.13.1-alpha.2",
41
41
  "@rushstack/eslint-patch": "~1.1.4",
42
42
  "react": "^18.0.0",
43
43
  "react-dom": "^18.0.0",