我正在使用 alasql 导出到 excel,并且我正在尝试执行如下所示的自定义标题。所有其他字段名称都很好,除非它是“动作”
function myCtrl($scope) {
$scope.exportData = function () {
alasql('SELECT name as MY_NAME, action as MY_ACTION INTO XLSX("john.xlsx",{headers:true}) FROM ?',[$scope.items]);
};
$scope.items = [{
name: "John Smith",
action: "j.smith@example.com",
dob: "1985-10-10"
}, {
name: "Jane Smith",
action: "jane.smith@example.com",
dob: "1988-12-22"
}, {
name: "Jan Smith",
action: "jan.smith@example.com",
dob: "2010-01-02"
}, {
name: "Jake Smith",
action: "jake.smith@exmaple.com",
dob: "2009-03-21"
}, {
name: "Josh Smith",
action: "josh@example.com",
dob: "2011-12-12"
}, {
name: "Jessie Smith",
action: "jess@example.com",
dob: "2004-10-12"
}];
};
给了我以下错误
Error: Parse error on line 1:
...CT name as MY_NAME, action as MY_ACTION
-----------------------^
Expecting 'LITERAL', 'BRALITERAL', 'LPAR', 'NUMBER', 'STRING', 'SHARP', 'DOLLAR', 'AT', 'COLON', 'NOT', 'PLUS', 'STAR', 'QUESTION', 'CURRENT_TIMESTAMP', 'JAVASCRIPT', 'NEW', 'CAST', 'CONVERT', 'SUM', 'COUNT', 'MIN', 'MAX', 'AVG', 'FIRST', 'LAST', 'AGGR', 'ARRAY', 'TRUE', 'FALSE', 'NSTRING', 'NULL', 'EXISTS', 'BRAQUESTION', 'CASE', 'MINUS', 'ATLBRA', 'LCUR', got 'ACTION'
at Object.parseError (alasql.min.js:3)
at Object.parse (alasql.min.js:3)
at Function.alasql.parse (alasql.min.js:3)`