我想将带有Angular的excell发送到我的服务器(SpringBoot),我做不到。
所以,我认为我的问题可能是“ Angular无法读取excell”,我正在尝试使用Angular读取我的excell,但出现错误->
我的意图是“如果Angular可以读取excell,那么我将尝试发送excell” 因为我正在尝试发送excell,但无法发送...
然后:
在此代码中:
fileChange(event) {
let file: File = event.files[0];
let myReader: FileReader = new FileReader();
let fileType = event.parentElement.id;
myReader.onloadend = function (e) {
console.log(myReader.result);
}
console.log('fileType' , fileType);
myReader.readAsText(file);
}
错误
ERROR TypeError: Cannot read property '0' of undefined
我得到的这段代码->
Getting Data from FileReader in Angular 2
在尝试使用此代码之前:
fileChange(event) {
let fileList: FileList = event.target.files;
if (fileList.length > 0) {
let file: File = fileList[0];
this.formData.append('uploadFile', file, file.name);
console.log('al cambiar file' , file);
}
console.log(' formdata' , this.formData );
console.log(' fileList' , fileList);
console.log('stack' , event.files[0]);
}
使用此代码,我将文件命名为File,并进行了最后修改,但是我无法获取Excells单元格。
我需要帮助阅读o以便以角度发送excell我自星期五以来一直在尝试...
答案 0 :(得分:0)
使用'xlsx'软件包。
npm install xlsx