Vue export and upload Excel tables
With the help of xlsx-style plugin
- installation
npm install xlsx-style --save
- Introduce
var XLSX = require("xlsx"); // 不支持 import 引入
Excel file upload
- Read files locally
function read(file) {
return new Promise((res, rej) => {
var reader = new FileReader();
var data;
reader.onload = function(e) {
data = e.target.result;
res(data)
};
reader.readAsBinaryString(file);
})
}