import XLSX from ‘xlsx’
downloadTemplate() {
const filename = 'template_01.xlsx'
const templateData = [['employeeNo', 'employeeName', 'departmentId', 'departmentName', 'jobId', 'jobName', 'jobLevel', 'area', 'educational', 'reason', 'dutyLine']]
this.downloadExcel(filename, templateData)
},
downloadExcel(filename, templateData) {
const ws_name = 'SheetJS'
if (typeof console !== 'undefined') console.log(new Date())
var wb = XLSX.utils.book_new()
var ws = XLSX.utils.aoa_to_sheet(templateData)
/* add worksheet to workbook */
XLSX.utils.book_append_sheet(wb, ws, ws_name)
/* write workbook */
if (typeof console !== 'undefined') console.log(new Date())
XLSX.writeFile(wb, filename)
if (typeof console !== 'undefined') console.log(new Date())
}
|