首先是对alasql
项目的贡献者的高度赞扬。将我的 JSON 数据导出到 excel 文件对我有很大帮助。但对于接下来的步骤,我需要一些有关格式化 excel 文件的帮助。
是否可以定义具有自动宽度的单元格?我需要为一列着色。
我在另一个thread 看到过一个帖子,但这在我的示例中不起作用。
这是我的代码:
var opts = {
headers: true,
column: {
style: {
Font: {
Bold: "1"
}
}
},
rows: {
1: {
style: {
Font: {
Color: "#FF0077"
}
}
}
},
cells: {
1: {
1: {
style: {
Font: {
Color: "#00FFFF"
}
}
}
}
}
};
vm.btnExport = function () {
alasql('shortcode AS Short_Code, \ ' +
'fname AS Fullname, \ ' +
'INTO XLSX("test.xlsx", ?) FROM ?', [opts, vm.list]);
};
最佳答案
我有个好主意试试这个..
var opts = {
sheetid : ' Report',
headers : true,
style : 'font-size:25px',
caption : {
title : 'Report',
},
columns : [
{
title : "column Name",
columnid : "key value"
}
],
rows: {
//for putting background color in particular column
0: {
cell: {
style: 'font-size:17px;background:#115ea2;color:white;font-weight:bold'
}
},
},
cells: {
//if you want to put style in particular cell
1: {
5: {
style: 'font-size:20px;background:#115ea2 ;color:white;font-weight:bold;text-align:right',
value: function(value){return value;}
},
}
}
};
vm.btnExport = function () {
alasql('shortcode AS Short_Code, \ ' +
'fname AS Fullname, \ ' +
'INTO XLSX("test.xlsx", ?) FROM ?', [opts, vm.list]);
};
关于javascript - 使用 ALASQL (AngularJS) 格式化导出的 Excel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36404656/