I'm successfully reading my Excel file in React by following this SO thread as.
var reader = new FileReader();
reader.onload = function (e) {
var data = e.target.result;
let readedData = XLSX.read(data, {type: 'binary'});
const wsname = readedData.SheetNames[0];
const ws = readedData.Sheets[wsname];
/* Converts a worksheet object to an array of JSON objects*/
const parsedData = XLSX.utils.sheet_to_json(ws, {header:1});
console.log(parsedData);
}
reader.readAsBinaryString(fileName)
But having a simple problem, i.e., it's reading empty rows as well and causing empty entries in array.
Output of console.log(parsedData); in the above code is
I know a quick hack is to remove empty entries from the array but I want to know a better approach to avoid this problem even happening.
