表格(table)数据导出成Excel

使用xlxs-js

function exportExcel () {
    var wb = XLSX.utils.table_to_book(document.querySelector('.my-el-table'))
    var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
    try {
          FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), 'userlist.xlsx')
    } catch (e) { 
           if (typeof console !== 'undefined') console.log(e, wbout) 
    }
    return wbout
},

 

posted @ 2018-05-03 11:05  _zhiqiu  阅读(1876)  评论(0编辑  收藏  举报