excel
excel
this is my code
< html >
<head>
<meta charset="UTF-8">
<title></title>
<script src="http://oss.sheetjs.com/js-xlsx/xlsx.full.min.js"></script>
<script src="http://oss.sheetjs.com/js-xlsx/FileSaver.min.js"></script>
</head>
<body>
<input type="file"onchange="importf(this)" />
<div id="demo"></div>
<script>
var to_json2 = function to_json(workbook) {
var result = {};
workbook.SheetNames.forEach(function(sheetName) {// workbook.SheetNames
var roa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName],{header:1});//json
if(roa.length) result[sheetName] = roa;
});
console.log(JSON.stringify(result, 2, 2));
return JSON.stringify(result, 2, 2);
};
function do_file(files) {
rABS = true;
var f = files[0];
var reader = new FileReader();
reader.onload = function(e) {
if(typeof console !== "undefined") console.log("onload", new Date(), rABS);
var data = e.target.result;
if(!rABS) data = new Uint8Array(data);
var wb=XLSX.read(data, {type: rABS ? "binary" : "array"});
var json=to_json2(wb);
};
if(rABS) reader.readAsBinaryString(f);// html5
else reader.readAsArrayBuffer(f);//ArrayBuffer html5
};
function importf(obj) {//
if(!obj.files) {return;}
do_file(obj.files);
}
problem description
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)