美好的一天,
我的报告中有一个功能,可以将html表转换为excel文件。它适用于1,500行的表,但比它多。它不起作用。我目前正在使用一个名为table2excel的js插件,它也不会产生任何错误..它可能是内存问题还是某种?感谢您的提示..我正在尝试导出日志表,自然它会随着时间的推移生成很多行..
代码:
<div class="box" id="dataTable">
<?php $excel_title = "GENERAL LEDGER"; $col_no = 9; ?>
<table class="table table-bordered report-table" >
<thead>
<th width="10%" >Account</th>
<th width="4%">Date</th>
<th width="5%" >Trans #</th>
<th width="20%" >Description</th>
<th width="9%" class="ar" >Ref #.</th>
<th width="9%" class="ar" >Debit</th>
<th width="9%" class="ar" >Credit</th>
<th width="9%" class="ar">Amount</th>
<th width="9%" class="ar" >Balance</th>
</thead>
<tbody>
<tr>
<th>value#</th>
<th>value#</th>
<th>value#</th>
<th>value#</th>
<th>value#</th>
<th>value#</th>
<th>value#</th>
<th>value#</th>
<th>value#</th>
</tr>
</tbody>
</table>
</div>
$('#table2xcel').click(function(){
$("#dataTable").table2excel({
exclude: ".xpage",
name: "Worksheet Name",
filename: "{{$excel_title}} -" //do not include extension
});
});
答案 0 :(得分:0)
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function () {
$("#btnExport").click(function (e) {
window.open('data:application/vnd.ms-excel,' + $('#dvData').html());
e.preventDefault();
});
});
</script>
</head>
<body>
<input type="button" id="btnExport" value="Export" />
<div id="dvData">
<table>
<tr>
<th>Column One</th>
<th>Column Two</th>
<th>Column Three</th>
</tr>
<tr>
<td>row1 Col1</td>
<td>row1 Col2</td>
<td>row1 Col3</td>
</tr>
<tr>
<td>row2 Col1</td>
<td>row2 Col2</td>
<td>row2 Col3</td>
</tr>
<tr>
<td>row3 Col1</td>
<td>row3 Col2</td>
<td><a href="http://www.jquery2dotnet.com/">http://www.jquery2dotnet.com/</a>
</td>
</tr>
</table>
</div>
</body>
</html>