• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
小码哥-倩倩
博客园    首页    新随笔    联系   管理    订阅  订阅

网页表格导出excel表格第二种方法

需要引入jquery.table2excel组件,jquery.table2excel下载地址:https://github.com/rainabba/jquery-table2excel/blob/master/src/jquery.table2excel.js

DEMO代码:

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div>
<script type="text/javascript" src="ui/jquery.js"></script>
<script type="text/javascript" src="jquery.table2excel.js"></script>

<table class="table2excel">
<tr>
<th>生产厂家</th>
<th>产品名称</th>
<th>...</th>
<th> class="noExl">操作</th>
</tr>
<tr>
<td>厂家1<td>
<td>产品1<td>
<td>...<td>
<td class="noExl"><button>删除</button><button>修改</button><td>
</tr>
<tr>
<td>厂家2<td>
<td>产品2<td>
<td>...<td>
<td class="noExl"><button>删除</button><button>修改</button><td>
</tr>
</table>
<table>
<tr>
<td>
<input type="button" value="导出到excel中" class="btn btn-primary" onclick="table2Excel('出库信息明细.xls')"/>
</td>
</tr>
</table>
</div>
<script>
//filename 导出的excel文件名
//方法可带filename参数,亦可不带参数直接定义
function table2Excel(filename){
$(".table2excel").table2excel({
exclude: ".noExl",//class="noExl"的列不导出
name: "Excel Document Name",
filename: filename,//文件名称
fileext: ".xls",//文件后缀名
exclude_img: true,//导出图片
exclude_links: true,//导出超链接
exclude_inputs: true//导出输入框内容
});
}
</script>
</body>
</html>
posted @ 2019-11-16 14:53  小码哥-倩倩  阅读(839)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3