Search code examples
javascriptfuturealasql

Alasql -Multiple sheetids within single promise statement


I am trying to call multiple sheets from the excel file ,by implementing single promise statement but it always outputs the data of first sheet. Thank you.

    alasql.promise('select * from xls("raw/food.xls",[{sheetid:"Data"}, {sheetid:"Guideline"}])')
        .then(function (data) {
            console.log(data);
        }).catch(function (err) {
            console.log('Error:', err);
        });

Need to call both sheets data using single promise statement.


Solution

  • You need more than one promise, so try this:

    alasql.promise(['select * from xls("raw/food.xls",[{sheetid:"Data"}])','select * from xls("raw/food.xls",[{sheetid:"Guideline"}])'])
        .then(function (data) {
            console.log(data);
        }).catch(function (err) {
    console.log('Error:', err);
    });
    

    Here are some more examples