September grab a share of the tail plug XLSX

git official website

installation:

cnpm install --save xlsx file-saver

.vue file:
1. Plug-referenced table / table layout to write <table EL-ID = "My-table"> </ EL-table>
2. dependent incorporated

import FileSaver from 'file-saver' 
import XLSX from 'xlsx'

3. Download function uses:

exportExcel () {
   / * generated from the workbook object table * / 
  var WB = XLSX.utils.table_to_book (document.querySelector ( 'My-Table #' ))
     / * Get a binary string as output * / 
    var wbout = XLSX .write (WB, {bookType: 'XLSX', bookSST: to true , type: 'Array' })
     the try {
         / * stored locally * / 
        FileSaver.saveAs ( new new Blob ([wbout], {type: 'file application / OCTET the -stream '}),' sheetjs.xlsx ' ) 
    } the catch (E) { IF ( typeof Console! ==' undefined ' ) the console.log (E,
    wbout) }
    return wbout;
},

 

The detailed finishing components:

 

Guess you like

Origin www.cnblogs.com/padding1015/p/11613751.html