我正在尝试使用excel to处理excel表,但需要在处理每一行并将信息输入数据库时将数据插入数据库。在每一行处理结束时,我需要将值插入为“成功”/“失败”,并将其作为带有失败的excel工作表返回。我需要一个接一个地处理这些行。
发布于 2018-05-14 13:32:21
您可以查看精益求精文档,其中清楚地提到了迭代工作表中的行的步骤。
允许您这样做的worksheet.eachRow()函数。
// Iterate over all rows that have values in a worksheet
worksheet.eachRow(function(row, rowNumber) {
console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
//Do whatever you want to do with this row like inserting in db, etc
});
// Iterate over all rows (including empty rows) in a worksheet
worksheet.eachRow({ includeEmpty: true }, function(row, rowNumber) {
console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
//Do whatever you want to do with this row like inserting in db, etc
});https://stackoverflow.com/questions/49814939
复制相似问题