console
var wb;
function importf(obj) {
if (!obj.files) {
return;
}
var f = obj.files[0];
var reader = new FileReader();
reader.readAsArrayBuffer(f);
reader.onload = function(e) {
var data = e.target.result;
var wb = XLSX.read(btoa(fixedData(data)), {
type: 'base64'
});
console.log(XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]));
document.getElementById("excel").innerHTML = JSON.stringify(XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]));
};
}
function fixedData(data) {
let o = ''let l = 0 const w = 10240
for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w))) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w))) return o
}
<script src="http://oss.sheetjs.com/js-xlsx/xlsx.full.min.js">
</script>
<a href="./file/模版-批量导入会员.xls" download="excel测试文件">
下载测试文件
</a>
<input type="file" onchange="importf(this)" />
<div id="excel">
</div>