I am Using XLSX npm package to read the data from Excel and convert into JSON format
I'm using Angular 7.
const reader = new FileReader();
const file = ev.target.files[0];
reader.onload = (event) => {
const data = reader.result;
console.log(data);
workBook = XLSX.read(data, { type: 'binary' });
jsonData = workBook.SheetNames.reduce((initial, name) => {
const sheet = workBook.Sheets[name];
initial[name] = XLSX.utils.sheet_to_json(sheet);
return initial;
}, {});
const dataString = JSON.stringify(jsonData);
};
Tried using reader.onload and reader.onloadend, it's not even throwing an error but the events are not firing. Can anyone help how to make it work? Thanks in Advance.