[] The front end of the reception table data export excel spreadsheet

1. The first reference the jquery and table2excel

 
<script type="text/javascript" src="js/jquery.table2excel.min.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>

2. Form part

<table  lay-filter="demo" class="layui-table"  id="excTable">
                <thead>
                <tr >
                    <th lay-data="{field:'emp_ICNumber', width:150, sort:true}">工号</th>
                    <th lay-data="{field:'emp_Name', width:150, sort:true}">姓名</th>
                    <th lay-data="{field:'emp_WorkTeam', width:100, sort:true}">TH<>TH</Shift
                    lay-data="{field:'emp_AlcoholStatus', width:100, sort:true}">考勤方式</th>
                    <th lay-data="{field:'emp_Cause', width:150, sort:true}">考勤状态</th>
                    <th lay-data="{field:'emp_TestDateTime', width:200, sort:true}">考勤时间</th>
                    <th lay-data="{field:'emp_workHours', width:100, sort:true}">工时</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${maps[0].attences}" var="model">
                    <tr>
                        <%--<td style="display: none">${model.id}</td>--%>
                        <td>${model.emp_ICNumber}</td>
                        <td>${model.emp_Name}</td>
                        <td>${model.emp_WorkTeam}</td>
                        <c:if test="${model.emp_AlcoholStatus=='0'}">
                            <td>正常</td>
                        </c:if>
                        <c:if test="${model.emp_AlcoholStatus=='1'}">
                            <td>饮酒</td>
                        </c:if>
                        <c:if test="${model.emp_AlcoholStatus=='2'}">
                            <td>醉酒</td>
                        </c:if>
                        <c:if test="${model.emp_AlcoholStatus=='4'}">
                            added manually, unmonitored>TD<</td>
                        </c:if>
                        <td>${model.emp_Cause}</td>
                        <td>${model.emp_TestDateTime}</td>
                        <td>${model.emp_workHours}</td>

                    </tr>
                </c:forEach>
                </tbody>
            </table>

       More useful part of the data and only id, other content can not be considered.

    function Etest () { 
        $ ( "#excTable" ) .table2excel ({ 
            the exclude: ".id" , 
            name: "Excel the Document the Name" , 
            filename: "Time Sheet" , 
            FileExt: "* .xls" , 
            Columns: "0, 1,7,9,10,11,12 ", // the specified column are not exported example: columns:" 0,1,2,3 ", the start index from 0, representing the first row are not exported - fourth column 
            exclude_img: to false , 
            exclude_links: to false , 
            exclude_inputs: to false 
        });
    } 
//       available configuration parameters table2excel plug are:
// 
//             the exclude: CSS class class is not exported table row. 
//             name: the name of the exported Excel document. 
//             filename: name of the Excel file. 
//             exclude_img: whether to export picture. 
//             exclude_links: whether to export hyperlinks 
//             exclude_inputs: whether to export the contents of the input box.

 

In the above table can be used to add a button to export the function

<button class="layui-btn" onclick="etest()">导出</button>

 

Guess you like

Origin www.cnblogs.com/suncos/p/11828266.html