亲测有效~~
要引入xlsx.full.min.js插件
html部分:按钮,用来上传文件(只能上传excel文件);还有用来存放数据的table
<input type="file" id="import_Excel" onchange="importf(this)" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" />
<table id="list">
<thead>
<tr>
<th scope="col" style="width: 40px;">序号</th>
<th class="txt">名称</th>
</tr>
</thead>
</table>
js部分:
function importf(obj) {
//excel导入
if (!obj.files) {
return;
}
var wb;//读取完成的数据