import{r as N,u as d,x as R}from"./xlsx-GLiMJrM3.js";import{d as S,r as x,h as v,o as E,aE as F,i as _,aF as C,ab as B,l as k,aU as I}from"./index-9PRMimni.js";const b=S({__name:"ImportExcel",emits:["success","error"],setup(m,{emit:l}){const a=l,c=x(null),i=x(!1);function u(e){if(!e||!e["!ref"])return[];const t=[],s=d.decode_range(e["!ref"]),r=s.s.r;for(let n=s.s.c;n<=s.e.c;++n){const o=e[d.encode_cell({c:n,r})];let f="UNKNOWN "+n;o&&o.t&&(f=d.format_cell(o)),t.push(f)}return t}function p(e){const t=[];for(const s of e.SheetNames){const r=e.Sheets[s],n=u(r),o=d.sheet_to_json(r);t.push({header:n,results:o,meta:{sheetName:s}})}return t}function h(e){return i.value=!0,new Promise((t,s)=>{const r=new FileReader;r.onload=async n=>{try{const o=n.target&&n.target.result,f=N(o,{type:"array"}),D=p(f);a("success",D),t("")}catch(o){s(o),a("error")}finally{i.value=!1}},r.readAsArrayBuffer(e)})}async function w(e){const t=k(c);t&&(t.value=""),await h(e)}function y(e){const t=e&&e.target.files,s=t&&t[0];s&&w(s)}function g(){const e=k(c);e&&e.click()}return(e,t)=>(E(),v("div",null,[F(_("input",{ref_key:"inputRef",ref:c,type:"file",accept:".xlsx, .xls",onChange:y},null,544),[[C,!1]]),_("div",{onClick:g},[B(e.$slots,"default")])]))}}),{utils:j,writeFile:A}=R,U="excel-list.xlsx";function $({data:m,header:l,filename:a=U,json2sheetOpts:c={},write2excelOpts:i={bookType:"xlsx"}}){const u=[...m];l&&(u.unshift(l),c.skipHeader=!0);const p=j.json_to_sheet(u,c),h={SheetNames:[a],Sheets:{[a]:p}};A(h,a,i)}I(b);export{$ as j};
