1

I'm using alasql to export to xls file. I'm able to export a HTML table to xls. But I have multiple tables in my HTML and I want export to xls which should have only one sheet with multiple tables; like image below.

enter image description here

Is there a way to do this?

Amir Suhail
  • 1,284
  • 3
  • 12
  • 31

1 Answers1

0

hi i made small changes in alasql file

//alasql

Object.objsize = function(Myobj) {
    var osize = 0, key;
    for (key in Myobj) {
        if (Myobj.hasOwnProperty(key)) osize++;
    }
    return osize;
};

var bigtable = undefined; var tableindex = 0; var reqSize = undefined;

        data.forEach(function(entry, index) {
            var objsize = Object.objsize(entry);

            if(reqSize == undefined){
                reqSize = objsize;
                bigtable = tableindex;
            }

            if(reqSize < objsize){
                bigtable = tableindex;
                reqSize = objsize;
            }
            ++tableindex;
        })

        columns = Object.keys(data[bigtable]).map(function(columnid) {
            return {columnid: columnid};
        });

// your HTML

Name Number Prashanth 756943912X Email Company Experience prasanthreddy568@gmail.com Aryagami 4 years

// your script var fileName = "Users"; data1 = alasql('SELECT * FROM HTML("#table1",{header:true})'); data2 = alasql('SELECT * FROM HTML("#table2",{header:true})'); data = data1.concat(data2); alasql('SELECT * INTO CSV("' + fileName + '",{headers:false}) FROM ?', [data]);