<script src="https://rawgithub.com/eligrey/FileSaver.js/master/FileSaver.js" type="text/javascript"></script>
<div ng-controller="myCtrl">
<button ng-click="exportData()">Export</button>
<br />
<div id="exportable">
<table width="100%">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>DoB</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in items">
<td>{{item.name}}</td>
<td>{{item.email}}</td>
<td>{{item.dob | date:'MM/dd/yy'}}</td>
</tr>
</tbody>
</table>
</div>
</div>

function myCtrl($scope) {
$scope.exportData = function () {
var blob = new Blob([document.getElementById('exportable').innerHTML], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
});
saveAs(blob, "Report.xls");
};

$scope.items = [{
name: "John Smith",
email: "j.smith@example.com",
dob: "1985-10-10"
}, {
name: "Jane Smith",
email: "jane.smith@example.com",
dob: "1988-12-22"
}, {
name: "Jan Smith",
email: "jan.smith@example.com",
dob: "2010-01-02"
}, {
name: "Jake Smith",
email: "jake.smith@exmaple.com",
dob: "2009-03-21"
}, {
name: "Josh Smith",
email: "josh@example.com",
dob: "2011-12-12"
}, {
name: "Jessie Smith",
email: "jess@example.com",
dob: "2004-10-12"
}]
}

最新文章

  1. JDK安装配置
  2. Hyper-V初涉_虚拟磁盘链错误的解决方案
  3. Spring控制多张表的提交事务操作
  4. Tuple的用法
  5. mac osx 启动wireshark闪退
  6. C#垃圾回收机制(GC)
  7. [转]NHibernate之旅(5):探索Insert, Update, Delete操作
  8. JavaScript对css样式表操作
  9. jsp中的两种跳转方式分别是?有什么区别?
  10. 解决sqlite删除数据后,文件大小不变问题(VACUUM)
  11. 左右v$datafile和v$tempfile中间file#
  12. Permanent Generation Removal Overview(译文)
  13. iOS进阶之页面性能优化
  14. Django admin 一些有用的设置
  15. Centos7下安装部署oracle数据库方法及问题汇总
  16. HikariCP 脑火Failed to obtain JDBC Connection: You need to run the CLI build and you need target/classes in your classpath to run.
  17. mysqldump脚本crontab执行失败,但是手动执行成功
  18. Redis&amp;PHP的使用安装-windows版
  19. DP系列——树形DP(Codeforces543D-Road Improvement)
  20. CodeChef April Challenge 2019题解

热门文章

  1. 深入理解Activity启动流程(一)–Activity启动的概要流程
  2. Android--&gt;状态栏高度,导航栏高度,Window高度,DecorView高度,heightPixels
  3. Linux进程管理(3):总结
  4. iOS开发 ----- 加载动画之牛顿摆的实现
  5. netd ResponseCode
  6. cache数据库之表的存储结构
  7. vue2.0 + vux (二)Footer组件
  8. c#高级编程笔记----委托
  9. Android开发之实现锁屏功能
  10. [RFC] Simplifying kernel configuration for distro issues