mercredi 23 mars 2016

Using ember-cli-sheetjs in an ember component

I'm creating a website using ember and am currently having difficulty using the 'ember-cli-sheetjs' module in a component titled 'add-student.js'. I cannot seem to call any functions in the documentation using my current code.

To get the module in ember I added it to my dev dependencies inside package.json and then ran the "npm install" command which successfully installed the "ember-cli-sheetjs" module. I then try and use it by writing:

    import Ember from 'ember';
    import xlsx from 'npm:ember-cli-sheetjs';

    export default Ember.Component.extend({
       fileinput: null, //this is set with an input handler in the hbs

    actions: {
       fileLoaded: function() {
          console.log(this.get('fileinput')); //properly outputs the file name
          var workbook = xlsx.readFile(this.get('fileinput'));
       },
    }

However this results an error saying:

add-student.js:134 Uncaught TypeError: _npmEmberCliSheetjs.default.readFile is not a function

I feel like the problem is that its not following the correct path to the function (which exists in the function documentation). If anyone can tell me what I'm doing wrong it would be a huge help.

Link to the module: http://ift.tt/1ZtnjzC




Aucun commentaire:

Enregistrer un commentaire