0

How can I export an excel files with multiple sheets with special characters in sheet name? For example, I tried this but the file cannot be opened:

window.saveFile = function saveFile () {
        var data1 = [{a:1,b:10},{a:2,b:20}];
    var data2 = [{a:100,b:10},{a:200,b:20}];
    var opts = [{sheetid:'Good1&2',header:true},{sheetid:'Two',header:false}];
    var res = alasql('SELECT INTO XLSX("MyAwesomeData.xlsx",?) FROM ?',[opts,[data1,data2]]);
}
Jerry
  • 97
  • 5

2 Answers2

0

Finally I found the solution, I need to escape the sheetid in xml since it's generated in xml format to the excel.

Here is the source: http://jsfiddle.net/ry8fq0dL/125/

 window.saveFile = function saveFile () {
var data1 = [{a:1,b:10},{a:2,b:20}];
    var data2 = [{a:100,b:10},{a:200,b:20}];
    var opts = [{sheetid:"One1&2",header:true},{sheetname:'Two',header:false}];
    var res = alasql('SELECT INTO XLSX("restest344b.xlsx",?) FROM ?',
                     [opts,[data1,data2]]);
}
Jerry
  • 97
  • 5
0

It seems that the library is updated so I don't have to escape the character now.

> http://jsfiddle.net/nvhoang115/L2gmkx1b/2/
Jerry
  • 97
  • 5