简体   繁体   中英

Is there a way to create an XLSX with multiple sheets using alaSql?

What i´m trying to do is generating an xlsx file with multiple sheets by using alaSql . They only need to have the columns and no data at all (it´s going to be used as a template available for download)

    var tasksData = [{
        UserName:"",
        Application:"",
        Module:""
    }];
    var objectsData = [{
        UserName:"",
        Application:"",
        Module:""
    }];
    var conflictsData = [{
        UserName:"",
        Application:"",
        Module:""
    }];

    var opts = [{
        sheetid: 'TasksData',
        headers: false
        }, {
        sheetid: 'ObjectsData',
        headers: false
        }, {
        sheetid: 'ConflictsData',
        headers: false
        }];

        alasql('SELECT * INTO XLSX("MatrixSODTemplate.xlsx",?) FROM ?',[opts,[tasksData,objectsData,conflictsData]]);

i need the output to be a single xlsx file with 3 sheets. And no data in it, only the columns.

Sheet TaskData: -UserName -Application -Module

Sheet ObjectsData: -UserName -Application -Module

Sheet ConflictsData: -UserName -Application -Module

So i found out what was going on. I had an old version of alasql in my project. So i upgrade it and then i found this helpfull link where the developers explain how to do it.

var data1 = [{a:1,b:10},{a:2,b:20}];
var data2 = [{a:100,b:10},{a:200,b:20}];
var opts = [{sheetid:'One',header:true},{sheetid:'Two',header:false}];
var res = alasql('SELECT INTO XLSX("restest344b.xlsx",?) FROM ?',[opts,[data1,data2]],
  function(){
    done();
  });

https://github.com/agershun/alasql/wiki/How-to-create-multiple-worksheets-into-a-workbook

Hope it helps someone

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM