-1

I want send Excel with Angular to my Server (SpringBoot). I can't do this.

Error 500 in server

So, I thought that my problem maybe is "Angular doesn't read Excel." I am trying read my Excel with Angular and I get error ->

My intention is "If Angular can read the Excel, then I will try send Excel."

Because I am trying send Excel and I can't send...

Then:

In this code:

 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

ERROR TypeError: Cannot read property '0' of undefined

This code I got the ->

Upload a File and Read Data with FileReader in Angular 2

Before I try with this code:

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]);
  }

resultenter image description here

With this code I get name the File and last modification but I can't get cells of Excel.

Catija
  • 359
  • 6
  • 21
EduBw
  • 866
  • 5
  • 20
  • 40

1 Answers1

0

use 'xlsx' package.

npm install xlsx