此代码将在 html 文件中下载表格:我从这里得到它:http ://www.kunalbabre.com/projects/table2CSV.php
<form action="getcsv.php" method ="post" >
<input type="hidden" name="csv_text" id="csv_text"/>
<input type="submit" value="Get CSV File" onclick="getCSVData()">
</form>
<script>
function getCSVData(){
var csv_value=$('#example1').table2CSV({delivery:'value'});
//$("#csv_text").val(csv_value);
}
</script>
获取csv.php:
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"my-data.csv\"");
$data=stripcslashes($_REQUEST['csv_text']);
echo $data;
?>
但是,我提取的表格是分页的。我只能得到第一页。如何在 csv 中包含表中的所有数据?
分页表如下所示:
<div id="paging_container8">
<div class="page_navigation">
</div>
<table id="my-table">
<tr style="display: table-row;">
<tr style="display: table-row;">
<tr style="display: none;"> // next page (paginated)
<tr style="display: none;"> //next page (paginated)
</table>
<div class="page_navigation">
</div>
<br>
</div>