闲来无事,就试着玩了一下这个库
import xlsx from 'node-xlsx';
import * as fs from 'fs';
import path from "path"
// const data = [
// [1, 2, 3],
// [true, false, null, 'sheetjs'],
// ['foo', 'bar', new Date('2014-02-19T14:30Z'), '0.3'],
// ['baz', null, 'qux'],
// ];
// var buffer = xlsx.build([{ name: 'mySheetName', data: data }]); // Returns a buffer
// fs.writeFileSync('./test.xlsx', buffer, { 'flag': 'w' });
const options = {
type: "buffer",
cellDates: true,
cellHTML: false,
dateNF: "yyyy-mm-dd hh:mm:ss",
cellNF: true
};
const workSheetsFromFile = xlsx.parse(`${path.resolve()}/test.xlsx`, options);
console.log(workSheetsFromFile[0].data);