I need to read data from a local XLSX file and save it to an object (or array).
The data looks like this:

and I need the data like this:

so I can work with it (compare it to other objects/display it...)
How is this possible?
I tried an AJAX call with the following code:
/* set up 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 to binary string */
  var data = new Uint8Array(arraybuffer);
  var arr = new Array();
  for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
  var bstr = arr.join("");
  /* Call XLSX */
  var workbook = XLSX.read(bstr, {type:"binary"});
  /* DO SOMETHING WITH workbook HERE */
  var first_sheet_name = workbook.SheetNames[0];
  /* Get worksheet */
  var worksheet = workbook.Sheets[first_sheet_name];
  var test = XLSX.utils.sheet_to_json(worksheet,{raw:true})
  console.log(test)
}
oReq.send();
console.log(test) //I can not access it here..
It worked and I got the object as I needed but the problem is I can not access the object outside of the function. I made a post a few hours ago: How to get an object from an async call (xlsx file) to global scope
 
     
    