<div id="exportable">
<table width="100%">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>小明</td>
<td>dsds@163.com</td>
</tr>
</tbody>
</table>
</div>
var blob = new Blob([document.getElementById('exportable').innerHTML], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
});
saveAs(blob, "日记账.xls");
};
\\ angular 需要导入xlsx.core.min.js alasql.min.js
\\ 文件结构
var arr = [
{
'收入':1,
'支出':2,
'结存':3
},
{
'收入':4,
'支出':5,
'结存':6
}
]
\\ 生成 excel 文件
alasql('SELECT * INTO XLSX("日记账.xlsx",{headers:true}) FROM ?',[arr]);
// 导出excel
$scope.exportToExcel=function(){
var data = angular.copy($scope.pageData.list)
var arr = [];
var type = null;
var amountIN = 0;
var amountOUT = 0;
angular.forEach(data,function (item) {
// 兑付情况
if(item.isHappened){
type = '未兑付'
}else{
type = '已兑付'
}
// 收入
if(item.itemModel=='INCOME'){
amountIN = item.amount
}
// 支出
if(item.itemModel=='OUTCOME'){
amountOUT = item.amount
}
arr.push({
'兑付情况':type,
'合同':item.keyId,
'收付日期':$filter('date')(item.updateTime,'yyyy-MM-dd'),
'科目':item.itemType.value,
'收入':$filter('number')(amountIN,2),
'支出':$filter('number')(amountOUT,2),
'结存':$filter('number')(item.balance,2)
})
})
if(arr.length < 1){
ToasterTool.error('暂无数据,导出失败!');
}else{
// alasql('SELECT * INTO XLSX("日记账.xlsx",{headers:true}) FROM ?',[arr]);
alasql.promise('SELECT * INTO XLSX("日记账-'+ DateTool.format(new Date(),'yyyy-MM-dd HH:mm:ss') + "-"+ $scope.loginUser.userName +'.xlsx",{headers:true}) FROM ?',[arr])
.then(function (data) {
if(data == 1){
$timeout(function(){
ToasterTool.success('数据导出成功!')
})
}
})
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有