浏览器端JS导出EXCEL——001
<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"
}]
}
最新文章
- JDK安装配置
- Hyper-V初涉_虚拟磁盘链错误的解决方案
- Spring控制多张表的提交事务操作
- Tuple的用法
- mac osx 启动wireshark闪退
- C#垃圾回收机制(GC)
- [转]NHibernate之旅(5):探索Insert, Update, Delete操作
- JavaScript对css样式表操作
- jsp中的两种跳转方式分别是?有什么区别?
- 解决sqlite删除数据后,文件大小不变问题(VACUUM)
- 左右v$datafile和v$tempfile中间file#
- Permanent Generation Removal Overview(译文)
- iOS进阶之页面性能优化
- Django admin 一些有用的设置
- Centos7下安装部署oracle数据库方法及问题汇总
- HikariCP 脑火Failed to obtain JDBC Connection: You need to run the CLI build and you need target/classes in your classpath to run.
- mysqldump脚本crontab执行失败,但是手动执行成功
- Redis&;PHP的使用安装-windows版
- DP系列——树形DP(Codeforces543D-Road Improvement)
- CodeChef April Challenge 2019题解
热门文章
- 深入理解Activity启动流程(一)–Activity启动的概要流程
- Android-->;状态栏高度,导航栏高度,Window高度,DecorView高度,heightPixels
- Linux进程管理(3):总结
- iOS开发 ----- 加载动画之牛顿摆的实现
- netd ResponseCode
- cache数据库之表的存储结构
- vue2.0 + vux (二)Footer组件
- c#高级编程笔记----委托
- Android开发之实现锁屏功能
- [RFC] Simplifying kernel configuration for distro issues