javascript - Excel data extraction using SheetJS/js-xlsx and its usage in AngularJS -


i want extract xlsx data , display onto webpage. have used sheetjs/js-xlsx extraction of data xl sheet. data getting extraced not sure how data angularjs further usage.

/* set xmlhttprequest */  var url = "test.xlsx";  var oreq = new xmlhttprequest();  oreq.open("get", url, true);  oreq.responsetype = "arraybuffer";    oreq.onload = function(e) {    var arraybuffer = oreq.response;      /* convert data binary string */    var data = new uint8array(arraybuffer);    var arr = new array();    (var = 0; != data.length; ++i) arr[i] = string.fromcharcode(data[i]);    var bstr = arr.join("");      /* call xlsx */    var workbook = xlsx.read(bstr, {      type: "binary"    });      /* workbook here */    var first_sheet_name = workbook.sheetnames[0];    /* worksheet */    var worksheet = workbook.sheets[first_sheet_name];    var xldata = xlsx.utils.sheet_to_json(worksheet, {      raw: true    })    console.log(xldata);  }    oreq.send();

in console, able see data contained in test.xlsx excel sheet. use data contained in xldata variable, how go in angular js? tried this. not work. can please help?

   var app=angular.module("my-app",[]); app.controller("myctrl",function($scope){     $scope.message=xldata; });  <div ng-controller="myctrl"> {{message}} </div> 

this error getting:

referenceerror: xldata not defined


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -