Hi Guys,
I am very new to codeceptjs. As per my requirement I need to get a value from excel file when status column value is “Y” and I wanted to return the value from Name Column to the calling function and excel sheet contains the data is as follows
Name Number status
YYYY 1234 N
XXXXX 3456 Y
Function I have written like this
var Excel = require(‘exceljs’);
var workbook = new Excel.Workbook();
var selectStatus =’’;
module.exports = function() {
return actor({
trimSelectName: function(
) {
workbook.xlsx.readFile("E:/testData.xlsx")
.then(function(sheetName) {
// use workbook
i=1;
try {
var workSheet = workbook.getWorksheet("trim");
workSheet.eachRow({ includeEmpty: false }, function(row, rowNumber) {
if(i==1) {
i=0;
} else {
currRow = workSheet.getRow(rowNumber);
console.log("Name :" + currRow.getCell(1).value +", Number :" +currRow.getCell(2).value +
"Select Status :" + currRow.getCell(3).value) ;
selectStatus = currRow.getCell(3).value;
if(selectStatus == "Y") {
return selectStatus;
}
}
});
}
catch(Error) {
console.log(Error);
}
});
},
});
};
But I am trying to the print value from the calling function, I am always getting it as undefined
Calling function:
Const selected = trimDataSelection.trimSelectName();
Could you please let me know where could be the issue?