ExcellentExport导出文件插件


ExcellentExport可以直接导出页面中的表格

引入ExcellentExport

<!--<script src="./lib/excellentexport.js"></script>-->
<!--可去百度自行搜索文件进行下载-->

两种方式实现导出

<table id="datatable">
     <thead>
         <tr>
             <th>序号</th>
             <th>名称</th>
             <th>单价</th>
             <th>数量</th>
             <th>总价</th>
         </tr>  
     </thead>
     <tbody> 
         <tr>
             <td>1</td>
             <td>苹果</td>
             <td>¥2.00</td>
             <td>3</td>
             <td>¥6.00</td>
         </tr>
      </tbody>
 </table>

1.html页面中

<a download="xxx.xls" href="#" onclick="return ExcellentExport.excel(this, 'datatable', 'Sheet Name Here');" >
   <button class="btn btn-default" type="button">导出</button>
</a>

注意:使用ExcellentExport由于a标签的download属性所以要配合a标签使用,才能将页面中的表格进行导出,其中datatable是指你表格的id

2.js中

function downloadClick(that){
	return ExcellentExport.excel(that,'datatable','Sheet Name Here');
}
$('#download1').click(function(){
	return ExcellentExport.excel(this,'datatable','Sheet Name Here');
})

其中downloadClick是指在a标签上的点击事件,download1是a标签的id

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值