Reputation: 329
I am writing a code where i am checking the contents of an excel file using exceljs. I have to check if a cell is empty but I am unable to do that. I have tried the following things:
if(!worksheet.getCell(`L${colNumber}`).value)
if(worksheet.getCell(`L${colNumber}`).value === '')
if(worksheet.getCell(`L${colNumber}`).value == null)
if(worksheet.getCell(`L${colNumber}`).value === undefined)
if(worksheet.getCell(`L${colNumber}`).value.length === 0) //logging it gave the length as 1
if(!!worksheet.getCell(`L${colNumber}`).value)
Upvotes: 1
Views: 4609
Reputation: 623
You can iterate on non empty columns cells by using
const dobCol = worksheet.getColumn(3);
// iterate over all current cells in this column excluding empty cells
dobCol.eachCell({ includeEmpty: false }, function(cell, rowNumber) {
...
});
As described in the documentation
Upvotes: 0