0

I have a input type=file and I'm trying to have js-xls load it.

<input ngf-select ng-model="mypage.myfile" type="file" id="file_input" name="myfile" >

Here are three different ways I've tried to load the file in my controller:

var workbook = XLS.readFile(mypage.myfile);

It says:

TypeError: Cannot read property 'readFileSync' of undefined

I also tried this:

var workbook = XLS.read(mypage.myfile, {type:"binary"});

And get:

TypeError: f.charCodeAt is not a function

And finally:

var workbook = XLS.read(mypage.myfile.toString(), {type:"binary"});

And get:

Error: Unsupported file 91

I verified each time that the mypage.myfile is actually there and what I expect.

Greg
  • 45,306
  • 89
  • 231
  • 297

1 Answers1

0

Ok this ended up being the answer: https://stackoverflow.com/a/37083658/13009

I changed the XLSX to XLS which I think will handle both. I also removed the outer function, I'm not sure what it was doing, and added a callback to do the actual work.

Community
  • 1
  • 1
Greg
  • 45,306
  • 89
  • 231
  • 297