我正在使用 xlsx 包https://www.npmjs.com/package/xlsx
我正在尝试读取一个大小为 50 MB 的 xl 文件,该文件包含 50 列和大约 175,000 条记录。 使用
读取文件花费的时间太长(75秒)// starting at time t = 0;
const xlValue: xlsx.WorkBook = xlsx.readFile(filePathToExtractDataFrom, {
cellDates: true,
dateNF: "DD-MM-YYYY",
});
const sheetNameList: string[] = xlValue.SheetNames;
const xlJsonData: any = xlsx.utils.sheet_to_json(xlValue.Sheets[sheetNameList[0]]);
// completing at time t=75;
// start working on xlJsonData, operations of type: modify values, check values
有没有其他方法可以更快地阅读它?
数据转成json格式后需要做一些处理
你可以使用 fs.createReadStream('path/to/file.xlsx'); 然后 const workbook = new XLSX.stream().xlsx.read(stream);