Reputation: 87
I am not able to set the this.isHiddenColumnAvail
value. How to set this value?
checkHiddenRowAndColumns(file) {
const workbook = new Excel.Workbook();
const arryBuffer = new Response(file).arrayBuffer();
arryBuffer.then(function (data) {
workbook.xlsx.load(data)
.then(function () {
const worksheet = workbook.getWorksheet(1);
//check hidden columns
for(var i=0; i < worksheet.columns.length; i++) {
if(worksheet.columns[i].hidden == true){
this.isHiddenColumnAvail = true;
break;
}
}
//check hidden rows
worksheet.eachRow(function (row,rowNumber) {
if(row.hidden == true) {
this.isHiddenColumnAvail = true;
}
});
});
});
}
Upvotes: 0
Views: 1045
Reputation: 156
It's simple you need to change the function to an arrow function.
Using Arrow functions you can use this, allowing you access outside/global variables.
See the example bellow:
worksheet.eachRow((row,rowNumber) => {
if(row.hidden == true) {
this.isHiddenColumnAvail = true;
}
});
In your code, replace the other functions with arrow functions
Observations:
Reference:
Upvotes: 4