js json=>excel

import * as XLSX from 'xlsx';

    const sheetData = [
      {'年龄':112,'姓名':'张三'},
      {'年龄':212,'姓名':'张四'}
    ]
    const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet(sheetData);
    const wb: XLSX.WorkBook = XLSX.utils.book_new();
    const timestamp = (new Date()).getTime();
    XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
   // XLSX.writeFile(wb, 'dataList.xlsx');
    XLSX.writeFile(wb,"dataList"+timestamp+".xlsx");

你可能感兴趣的:(javascript)