I am currently utilizing the js-xlsx library. If necessary, you can access my excel sheet here. The code I have implemented is as follows:
/* setting 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;
/* converting 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("");
/* Calling XLSX */
var workbook = XLSX.read(bstr, {type:"binary"});
/* PROCESS workbook DATA HERE */
var first_sheet_name = workbook.SheetNames[0];
/* Accessing worksheet */
var worksheet = workbook.Sheets[first_sheet_name];
console.log(XLSX.utils.sheet_to_json(worksheet,{raw:true}));
}
oReq.send();
In the console log, I receive the following output:
(3) […]0: Object { FirstName: "Mayuresh", MiddleName: "Dinkar ", LastName: "Joshi", … }1: Object { FirstName: "Arun", MiddleName: "Vikas", LastName: "Pathak", … }2: Object { FirstName: "Narendra", MiddleName: "Damodardas", LastName: "Modi", … }length: 3<prototype>: Array []
I am struggling to access this data. I am unsure of how to refer to it by name. I attempted using `arr.length`, but it only returned 1 instead of the expected 3. The JavaScript script does return a length of 3, although I am uncertain where this value is derived from. I simply need assistance in accessing that array. Thank you.