我使用tableexport.js
插件进行html
表格导出。
我有这样的html
表。
<table id="all_category_data">
..
...
.....
</table>
我javascript
我正在做这样的事情
$('#all_category_data').tableExport({ type: 'excel', escape: 'false' });
这里是jsfiddle :https://jsfiddle.net/2kt4u8hn/3/
请提前帮助我!!
答案 0 :(得分:1)
documentation明确指出:
要使用此插件,请包含jQuery库FileSaver.js脚本, 和HTML的结束标记之前的TableExport.js插件 文档。
在您的代码中,您没有包含jquery和fileserver.js。请参阅下面的小提琴的工作变体。
$('#all_category_data').tableExport({ type: 'excel', escape: 'false' });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/eligrey/FileSaver.js/e241bd15288553341b3629f5d1e0bc7aaa8a7a38/FileSaver.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/TableExport/3.3.9/js/tableexport.min.js"></script>
<table border=1 id="all_category_data" class="table table-striped table-bordered table-hover">
<tbody>
<tr>
<th>User Name</th>
<th>User Belongs to</th>
<th>Total Work Assigned</th>
<th>Not Emailed</th>
<th>Email Sent</th>
<th>Response Recieved</th>
<th>Interested</th>
<th>Not Interested</th>
</tr>
<tr>
<td>vidyaranyapura</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>bangalore</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>karnataka</td>
<td><span style="color:#3498db;">Company</span></td>
<td>200</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>otherstates</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>global</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>business</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>software</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>placement</td>
<td><span style="color:#3498db;">Company</span></td>
<td>28</td>
<td>28</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>training</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>realestate</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>techparks</td>
<td><span style="color:#3498db;">Company</span></td>
<td>117</td>
<td>117</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>tienetwork</td>
<td><span style="color:#3498db;">Company</span></td>
<td>2488</td>
<td>2487</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>linkedin</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>facebook</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>individual</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>schools</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>colleges</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>clubs</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>temples</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>hospital</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>financial</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>marketing</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>products</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>mahesh</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>postmail</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>landline</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>email</td>
<td><span style="color:#3498db;">Company</span></td>
<td>6932</td>
<td>6932</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>whatsapp</td>
<td><span style="color:red;">Not Assigned</span></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr style="color:#4A148C;font-size:33px;">
<td></td>
<td></td>
<td>9765 <span style="color:red;font-size:11px;">Total work assigned</span></td>
<td>9564 <span style="color:red;font-size:11px;">Not Emailed</span></td>
<td>0 <span style="color:red;font-size:11px;">Email Sent</span></td>
<td>0 <span style="color:red;font-size:11px;">Response Recieved</span></td>
<td>0 <span style="color:red;font-size:11px;"> Interested</span></td>
<td>0 <span style="color:red;font-size:11px;">Not Interested</span></td>
</tr>
</tbody>
</table>