anita shrivastava
anita shrivastava

Reputation: 329

How to check for blank cell using getcell in exceljs

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

Answers (1)

Shivam Kubde
Shivam Kubde

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

Related Questions