Vue export and upload Excel tables

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);
    })
}

reference

Refer to this blog

Guess you like

Origin blog.csdn.net/qq_38686150/article/details/110069453