我正在尝试从Excel文件中读取数据。以下代码停止在IE11上运行,我不知道为什么?当我放入控制台日志时,我看到没有触发onloadend。请让我知道解决此问题的任何方法。
private myReader: FileReader = new FileReader();
changeListener($event): void {
readThis($event.target);
}
readThis(inputValue: any): void {
const file: File = inputValue.files[0];
public test: String[] = [];
if (fileType === 'xlsx') {
console.log(this.myReader);
this.myReader.onloadend = (e) => {
/* read workbook */
const bstr: string = this.myReader.result;
const wb: XLSX.WorkBook = XLSX.read(bstr, { type: 'binary' });
/* grab first sheet */
const wsname: string = wb.SheetNames[0];
const ws: XLSX.WorkSheet = wb.Sheets[wsname];
this.data = XLSX.utils.sheet_to_json(ws, { header: 1 });
this.data.forEach(eachline => {
if (eachline[0] !== undefined) {
test.push(eachline[0]) ;
}
}
});
};
this.myReader.readAsBinaryString(file);
}
}