12 |
- import{F as e}from"../file-saver/file-saver.s25CNEyP.js";import{w as t,u as r,S as n}from"../xlsx/xlsx.DAT2ZpCq.js";import"../axios/axios.CUN3se9v.js";function o(e,t){for(var o,s={},a={s:{c:1e7,r:1e7},e:{c:0,r:0}},l=0;l!=e.length;++l)for(var h=0;h!=e[l].length;++h){a.s.r>l&&(a.s.r=l),a.s.c>h&&(a.s.c=h),a.e.r<l&&(a.e.r=l),a.e.c<h&&(a.e.c=h);var c={v:e[l][h]};if(null!=c.v){var f=r.encode_cell({c:h,r:l});"number"==typeof c.v?c.t="n":"boolean"==typeof c.v?c.t="b":c.v instanceof Date?(c.t="n",c.z=n._table[14],c.v=(o=c.v,(Date.parse(o)-new Date(Date.UTC(1899,11,30)))/864e5)):c.t="s",s[f]=c}}return a.s.c<1e7&&(s["!ref"]=r.encode_range(a)),s}function s(){if(!(this instanceof s))return new s;this.SheetNames=[],this.Sheets={}}function a(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n!=e.length;++n)r[n]=255&e.charCodeAt(n);return t}function l(r){var n=function(e){for(var t=[],r=e.querySelectorAll("tr"),n=[],o=0;o<r.length;++o){for(var s=[],a=r[o].querySelectorAll("td"),l=0;l<a.length;++l){var h=a[l],c=h.getAttribute("colspan"),f=h.getAttribute("rowspan"),i=h.innerText;if(""!==i&&i==+i&&(i=+i),n.forEach((function(e){if(o>=e.s.r&&o<=e.e.r&&s.length>=e.s.c&&s.length<=e.e.c)for(var t=0;t<=e.e.c-e.s.c;++t)s.push(null)})),(f||c)&&(f=f||1,c=c||1,n.push({s:{r:o,c:s.length},e:{r:o+f-1,c:s.length+c-1}})),s.push(""!==i?i:null),c)for(var u=0;u<c-1;++u)s.push(null)}t.push(s)}return[t,n]}(document.getElementById(r)),l=n[1],h=n[0],c="SheetJS",f=new s,i=o(h);i["!merges"]=l,f.SheetNames.push(c),f.Sheets[c]=i;var u=t(f,{bookType:"xlsx",bookSST:!1,type:"binary"});e.saveAs(new Blob([a(u)],{type:"application/octet-stream"}),"test.xlsx")}function h({multiHeader:n=[],header:l,data:h,sheetname:c,filename:f,merges:i=[],autoWidth:u=!0,bookType:g="xlsx"}={}){f=f||"excel-list",h=[...h];for(var p=0;p<l.length;p++)h[p].unshift(l[p]);for(let e=n.length-1;e>-1;e--)h.unshift(n[e]);for(var v=c,m=new s,S=[],w=0;w<l.length;w++)S.push(o(h[w]));if(i.length>0&&(S["!merges"]||(S["!merges"]=[]),i.forEach((e=>{S["!merges"].push(r.decode_range(e))}))),u){for(var y=[],b=0;b<l.length;b++)y.push(h[b].map((e=>e.map((e=>null==e?{wch:10}:e.toString().charCodeAt(0)>255?{wch:2*e.toString().length}:{wch:e.toString().length})))));let e=[];for(b=0;b<y.length;b++){e[b]=y[b][0];for(let t=1;t<y[b].length;t++)for(let r=0;r<y[b][t].length;r++)e[b][r].wch<y[b][t][r].wch&&(e[b][r].wch=y[b][t][r].wch)}for(var x=0;x<e.length;x++)S[x]["!cols"]=e[x]}for(b=0;b<l.length;b++)m.SheetNames.push(v[b]),m.Sheets[v[b]]=S[b];var d=t(m,{bookType:g,bookSST:!1,type:"binary"});e.saveAs(new Blob([a(d)],{type:"application/octet-stream"}),`${f}.${g}`)}export{h as export_json_to_excel,l as export_table_to_excel};
|