我似乎无法将Alasql定义为已定义,我已经通过节点安装了它,而且我相当确定它是安装的,但每当我加载我的前端时。我不是百分百肯定哪里出错了,任何帮助都会非常感激!
require is not defined at Scope.$scope.exportData
$scope.exportData = function () {
var mystyle = {
sheetid: 'Account sheet',
headers: true,
caption: {
title:'My Big Table',
},
style:'background:#00FF00',
column: {
style:'font-size:30px'
},
columns: [
{columnid:'Date'},
{columnid:'Description'},
{columnid:'Due'},
{columnid:'Charged £'},
{columnid:'Received £'},
{columnid:'Balanced £'},
{
columnid:'name',
title: 'Number of letters in name',
width: '300px',
cell: {
value: function(value){return value.length}
}
},
],
row: {
style: function(sheet,row,rowidx){
return 'background:'+(rowidx%2?'red':'yellow');
}
},
rows: {
},
cells: {
2:{
2:{
}
}
}
};
$scope.exportData = function () {
var alasql = require('alasql');
alasql('SELECT * INTO XLS("report.xls",?) FROM ?',[mystyle,records]);
};
答案 0 :(得分:1)
1 - 来自他们自己的angularjs readme:
请正常包含该文件,而不是通过requireJS。请在requireJS之前包含alasql,以避免出现“mismatched anonymous define()module”。这个问题与requireJS有关。
2 - 当使用grunt构建我的项目时,我有“alasql未定义”。所以我必须在我的jshint文件中包含alasql“globals”部分:
{
.
.
.
"globals": {
"angular": false,
"confirm": false,
"console": false,
"alert": false,
"alasql": false
}
}
PS:我建议您导出为“.xlsx”而不是“.xls”。 Microsoft现在是refusing to open those files。