Search code examples
javascriptalasql

alasql xlsx export problems


I am new to alasql and I would like to export several data in specific cell using alasql,

for example data1 goes do D4, data2 goes to G3, ..., data_n goes to F3

To do that I use the following javascript/alasql code:

window.saveFile = function saveFile () {
            var data1 = [{a:"Hi",b:"Hey"},{a:"test",b:"test2"}];
            var data2 = [{a:100,b:10},{a:200,b:20}];
            var opts = [{sourcefilename:"test.xlsx", header:false, range:"D13", sheetid:"RECTO"},{sourcefilename:"test.xlsx", header:false, range:"G4", sheetid:"VERSO"}];
            var res = alasql('SELECT * INTO XLSX("myxlsx.xlsx",?) FROM ?',[opts,[data1,data2]]);
        }

As you can see, I would like my data to go to some specific cell from a sourcefile document (an xlsx file with an empty table) Theses data would go to D13 and G4 in the sheet named "RECTO" and "VERSO"

However, when I open my output files, I can observe that:

  • My output does not look to my sourcefile (I've checked and "test.xlsx" is in my directory)
  • My headers are visible even if I put "header:false"

If anyone know how to fix my mistakes, it would help me A LOT


Solution

  • header problem is fixed, I replaced header: by headers: in both " { " brackets and it works, remains the problem of the source file

    var opts = [{sourcefilename:"test.xlsx", headers:false, range:"D13", sheetid:"RECTO"},{sourcefilename:"test.xlsx", headers:false, range:"G4", sheetid:"VERSO"}];