[英]Export to Excel from HTML
有什么方法可以从 HTML 表中导出到 excel。 我在 .NET 核心应用程序中使用了 HTML 表,需要使用样式格式化表,同样必须导出到 excel。
是的,您可以使用Datatables Plugin 来实现它
<table id="example" class="display nowrap" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
</table>
<script src='https://code.jquery.com/jquery-3.5.1.js'></script>
<script src='https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js'></script>
<script>
$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
'csv', 'excel', 'pdf', 'print'
]
} );
} );
</script>
库tableToExcel.517b1af9.js
在这里https://github.com/linways/table-to-excel/blob/master/dist/tableToExcel.517b1af9.js
<script src="/tableToExcel.517b1af9.js"></script>
<script>
TableToExcel.convert(document.getElementById("idTable"));
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.