js in my angular js project to export a grid to excel, heres my code:
inventaire.exportMyDataVille = function(data) {
var city='Safi';
alasql('SELECT * INTO XLSX("data.xlsx",{headers:true}) FROM ? WHERE secteur='+city+' GROUP BY secteur,agence,serie', [inventaire.myDataSource]);
};
what im trying to do is to pass a parametre in the alasql but it gives a empty excel file??is there somthing wrong in the request
You need to wrap string values in quotes when applying them in SQL clauses.
Based on your previous choice, use double quotes as follows:
alasql('SELECT * INTO XLSX("data.xlsx",{headers:true}) FROM ? WHERE secteur="'+city+'" GROUP BY secteur,agence,serie', [inventaire.myDataSource]);
.Note the change from
'+city+'
to"'+city+'"