8000 XLS · AlaSQL/alasql Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

XLS

8000
Mathias Rangel Wulff edited this page Mar 14, 2017 · 10 revisions

Excel 2003 files: .XLS

AlaSQL can export data in Excel 2003 format (.xls) with coloring of cells.

Please know that we recommend exporting to ".xlsx" instead of ".xls" as Microsoft has started refusing to open files in the old format.

    var opts = {
      headers: true,
      sheetid: 'My Birds',
      style:"background:#00ff00",
      columns: [
        {columnid:'a',title:'Albatroses',
          style:'background:red;font-size:20px',
          cell:{style:'background:blue'}
        },
        {columnid:'b',title:'Bird',cell:{
          style:function(value,sheet,row,column,rowidx,columnidx){
            return 'background'+(value==10?'brown':'white')
        }}},
        { 
          columnid: 'b', cell:{value:function(value){ return value * value}}
        }
      ]
    };

    var res = alasql('SELECT * INTO XLS("restest257a",?) FROM ?',[opts,data]); 

Please, see the example with advanced color syntax in jsFiddle.

You can pass the object as a Blob:

alasql('SELECT * FROM XLS(?,{headers:true}',[myblob]);

To read .xls files, please include the xlsx lib from https://cdnjs.com/libraries/xlsx

If you need Excel 2007 files please check out XLSX

Clone this wiki locally
0