zoukankan      html  css  js  c++  java
  • 之前写的页面导出Excel表格

    废话不多说,直接上代码

     1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
     2 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"  %>
     3 <%
     4 String path = request.getContextPath();
     5 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
     6 %>
     7 
     8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     9 <html>
    10   <head>
    11     <base href="<%=basePath%>">
    12     
    13     <title>My JSP 'Allshow.jsp' starting page</title>
    14     
    15     <meta http-equiv="pragma" content="no-cache">
    16     <meta http-equiv="cache-control" content="no-cache">
    17     <meta http-equiv="expires" content="0">    
    18     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    19     <meta http-equiv="description" content="This is my page">
    20     <!--
    21     <link rel="stylesheet" type="text/css" href="styles.css">
    22     -->
    23     <script src="assets/js/jquery-1.8.2.min.js"></script>
    24     <script src="jquery-table2excel-master/dist/jquery.table2excel.js"></script>
    25     <script>
    26     $(function() {
    27      $("#btn6").click(function(){
    28          $(".table2excel").table2excel({
    29             exclude: ".noExl",
    30             name: "Excel Document Name",
    31             filename: "yanfa3",
    32             exclude_img: true,
    33             exclude_links: true,
    34             exclude_inputs: true
    35             
    36          });
    37      });
    38      
    39     });
    40   </script>
    41   </head>
    42   
    43   <body> 
    44   
    45   
    46    <table border="2px" bordercolor="blue" cellpadding="5px" cellspacing="0" style="text-align: center;"  align="center" class="table2excel">
    47        <tr>
    48            <th>座位号</th>
    49            <th>学员姓名</th>
    50            <th>咨询师</th>
    51            <th>状态</th>
    52            <th>开始时间</th>
    53            <th>结束时间</th>
    54        </tr>
    55        <c:forEach items="${requestScope.list}" var="li">
    56    <tr>
    57            <td>${li.id}</td>
    58            <td>${li.studentName}</td>
    59            <td>${li.counselorName}</td>
    60            <td>${li.color}</td>
    61            <td>${li.startDate}</td>
    62            <td>${li.overDate}</td>
    63    </tr>
    64    </c:forEach>
    65    </table>
    66   <div align="center" style="margin-top:10px">
    67             <input style=" 100px;height: 50px" value="打印" type="button" onclick="javascript:window.print()" />
    68                 &nbsp;&nbsp;&nbsp;&nbsp;
    69             <input id="btn6" style=" 100px; height: 50px;align:center;" value="导出" type="button" />
    70         </div>
    71   </body>
    72 </html>

    69行  id="btn6"

    关键就是24行引的一个js

      <script src="jquery-table2excel-master/dist/jquery.table2excel.js"></script> 

     下载地址链接:https://pan.baidu.com/s/1cwJIlo 密码:ehza

    2017-12-14  14:18:35
  • 相关阅读:
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    整理任正非思想:团结奋斗 再创华为佳绩-1994
    整理任正非思想:赴美考察散记-1994
    你不能不知道的六种 Python 图像库的图片读取方法总结
    Spring boot 2.0 Actuator 的健康检查
    Springboot启动后只能本地访问,无法通过外部IP访问
    Ironic 的 Rescue 救援模式实现流程
  • 原文地址:https://www.cnblogs.com/angelye/p/8037511.html
Copyright © 2011-2022 走看看