Reputation: 43
I`m trying to set a result query into an array or JSON object using ALASQL:
var resdata2 = [ { A: "test", B: "testB" } ]; // Destination array
// Select first and second column values from xlxs
alasql('select A,B into ? from xlsx("gohan.xlsx")', [resdata2]);
console.log(resdata2); // Shows one object for xlsx line!
console.log(resdata2.length); // Shows length of 1 only
$.each(resdata2,function(idx, obj) {
console.log(obj.A); // Shows only 'test'
console.log(obj.B); // Shows only 'testB'
});
The spreadsheet has 18 lines which appear in the first console.log()
, however in second console.log()
and in each function, it shows only first line "Test"
and "testB"
.
Any ideas to show all lines?
Upvotes: 1
Views: 1097
Reputation: 4107
Probably you nee to use callback interface:
var resdata2;
alasql('select A,B from xlsx("gohan.xlsx")', [], function(data) {
resdata2 = data;
});
Here you need to use AlaSQL's callback interface, because XLSX() function is async.
Upvotes: 1