2016-07-08 70 views
0

我正在使用angularjs和javascript,並希望使用alasql將兩個數組導出到Excel。 Excel文件有兩張紙,每張紙上有一個數組。alasql導出到xlsx刪除hashkey

在我的Excel結果中,我找到了一個額外的列$$hashkey。 根據我發現的信息,使用angularjs,$$hashkey被自動刪除。我也嘗試加入'alasql.options.angularjs'但它沒有幫助。 我在做什麼錯?

我使用這樣的兩個數組:

$scope.ExecutionsLC1: [[Execution,1,2,3],[Operators,1014,1019,1020],[Result,X,X,V]]; 
$scope.ExecutionsLC2: [[Execution,1,2,3],[Operators,2014,2019,2020],[Result,X,X,V]]; 

var opts = [{sheetid:'LC1',header:false},{sheetid:'LC2',header:false}]; 
var res = alasql('SELECT INTO XLSX("LCDetail.xlsx",?) FROM ?',[opts,[$scope.ExecutionsLC1,$scope.ExecutionsLC2]]); 

回答

1

看來我可以使用angular.copy()來去掉$$ hashkey。

var data1 = angular.copy($scope.ExecutionsLC1); 
var data2 = angular.copy($scope.ExecutionsLC2); 
var opts = [{sheetid:'One',header:false},{sheetid:'Two',header:false}]; 
var res = alasql('SELECT INTO XLSX("restest344b.xlsx",?) FROM ?', 
       [opts,[data1,data2]]); 
+0

angular.toJson()也可以工作 –