头图

background

The front-end obtains the data and generates a csv file through the xlsx library. The file is opened in excel and the long number is displayed in scientific notation, and the time is not displayed in full, but the second is not displayed. Unless the time of the cell is selected, the congruent problem will be displayed.

How to solve

  1. bookType is set to csv but the file suffix is set to excel
    The problem is that when the file is opened with excel, it will prompt the file format question and ask whether to continue to open it.

     XLSX.writeFile(wb, `发送日志-${moment().format('YYYY-MM-DD')}.xlsx`, { type: 'binary', bookType: 'csv' });
  2. Add additional characters to display problematic fields

     {
      发送时间: moment(sendTime).format('YYYY-MM-DD HH:mm:ss') + '\t',
      userId: userId + '\t'
    }

chic
1.1k 声望50 粉丝