exceljs
exceljs copied to clipboard
can't get counter value
I want to ask, I made a func to convert xlsx files to database.
when res.send({desc : `${count} data, ${matchcount} data`}) the count and matchcount are 0,
even though insert or update to db success
so if i console.log this is what works =
- convert xlsx to rowarray
- this send a response directly
- insert db update process
this is my code =
var matchcount = 0; //match counter
var count = 0; //counter
//convert xlsx file to rowarray
await workbook.xlsx.readFile(req.file.path)
.then(workbook => {
workbook.eachSheet(async (sheet, id) => {
sheet.eachRow(async (row, rowIndex) => {
if (isOVO) {
///insert import function///
count++
for (var i = 0; i < dataKonekthing.length; i++) {
if (isSameData) {
///insert match data func///
///update import data func///
matchcount ++
}
}
}
})
})
//send response
})
.then(() => res.send({desc : `${count} data, ${matchcount} data`}))
i'm new in nodejs , so please help me solve this problem sorry for my bad english