您当前的位置: 首页 > 

漏刻有时

暂无认证

  • 0浏览

    0关注

    717博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

xlsx.full.js实现将excle导入表格转为二维数组的解决方案

漏刻有时 发布时间:2021-02-04 10:06:57 ,浏览量:0

在这里插入图片描述 在这里插入图片描述

   const reader = new FileReader();
        reader.readAsBinaryString(file);
        reader.onload = function (e) {
            const data = e.target.result;
            const zzexcel = window.XLS.read(data, {
                type: 'binary'
            });
            const newData = window.XLS.utils.sheet_to_csv(zzexcel.Sheets[zzexcel.SheetNames[0]]);
            //替换转化csv文件的换行符;
            var str = newData.replace(/[\n]/g, ",");
            str = str.substring(0, str.lastIndexOf(','));
            var a = str.split(",");
            var result = transArr(a, 4);//输出具体名称;
            console.log(result);
            var b = JSON.stringify(result);//将对象数组转成字符串传递;
            localStorage.setItem("data", b);//本地储存数据;
            //window.location.href = 'lockdata.html?timestamp=' + +new Date();
        }

lockdatav Done!

关注
打赏
1661217259
查看更多评论
立即登录/注册

微信扫码登录

0.0387s