插件

const nodeExcel = require('node-xlsx');
const fs=require('fs');

导入

const list = nodeExcel.parse('./lzyAPI.xlsx'); // 同步操作

list的格式为

[
	{
		name:'sheet1',
		data:[
			['data1','data2','data3'],
			['data2','data3','data4']
		]
	},
	{
		name:'sheet2',
		data:[
			['data1','data2','data3'],
			['data2','data3','data4']
		]
	}
]

对应的excel文件内容是
使用node导入导出excel文件

导出

const buffer = nodeExcel.build(list);// list 的格式也需要跟上述格式一致

fs.writeFile('excelfile.xlsx', buffer, function (err) {
    if (err)
        throw err;
    console.log('Write to xls has finished');
}
);

相关文章:

  • 2021-09-21
  • 2021-05-15
  • 2021-11-08
  • 2021-11-11
  • 2021-06-02
  • 2021-12-09
  • 2021-08-26
  • 2021-12-19
猜你喜欢
  • 2021-12-22
  • 2021-12-22
  • 2021-08-26
  • 2021-12-15
  • 2021-11-23
  • 2021-12-04
  • 2021-12-25
相关资源
相似解决方案