如何创建可以将html导出到CSV文件的功能?
|
我有以下html文件:
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" dir=\"ltr\" lang=\"en\">
<head>
</head>
<body>
<p align=\"center\"><strong>Claims Search Results</strong></p>
<table id=\"ClaimsListPrint\" class=\"printClaims\">
<thead>
<tr style=\"background-color: rgb(241, 241, 241);\">
<th style=\"background-color: rgb(215, 227, 235);\">
Member
</th>
<th style=\"background-color: rgb(215, 227, 235);\">
Date of Service
</th>
<th style=\"background-color: rgb(215, 227, 235);\">
Provider
</th>
<th style=\"background-color: rgb(215, 227, 235);\">
Claim Type
</th>
<th style=\"background-color: rgb(215, 227, 235);\">
Status
</th>
<th style=\"background-color: rgb(215, 227, 235);\">
Billed Amount
</th>
<th style=\"background-color: rgb(215, 227, 235);\">
Paid by Plan
</th>
<th style=\"background-color: rgb(215, 227, 235);\">
Member Responsiblity
</th>
</tr>
</thead>
<tbody>
<tr style=\"background-color: rgb(255, 255, 240);\" class=\"claim\">
<td class=\"claim-member\">
John Sample
</td>
<td class=\"claim-dateOfService\">
02/27/2011
</td>
<td class=\"claim-provider\">
TestProv1
</td>
<td class=\"claim-claimType\">
Medical
</td>
<td class=\"claim-status\">
Processed
</td>
<td class=\"claim-billedAmount\">
$145
</td>
<td class=\"claim-paidByPlan\">
$125
</td>
<td class=\"claim-memberResponsibility\">
$25
</td>
</tr>
<tr style=\"background-color: rgb(241, 241, 241);\" class=\"claim\">
<td class=\"claim-member\">
John Sample
</td>
<td class=\"claim-dateOfService\">
02/27/2011
</td>
<td class=\"claim-provider\">
TestProv1
</td>
<td class=\"claim-claimType\">
Medical
</td>
<td class=\"claim-status\">
In-Process
</td>
<td class=\"claim-billedAmount\">
-
</td>
<td class=\"claim-paidByPlan\">
-
</td>
<td class=\"claim-memberResponsibility\">
-
</td>
</tr>
</tbody>
</table>
</body>
</html>
我希望最终用户能够按如下所示链接文件中的链接:
<a id=\"link3\" class=\"links\" href=\"home.html\">Export to Microsoft Excel</a>
当他们单击它时,我希望将表导出为csv文件。我该怎么做?我可以使用Javascript或PHP或其他方式执行此操作吗?
没有找到相关结果
已邀请:
5 个回复
蜂佬渺
您可以在此HTML Table To CSV演示中看到此操作。
诉嘎归亮
孝箱捆讨
炬卤遁蝎变
版萍层分
传递格式化数据,然后在PHP中将响应类型更改为CSV。用户将获得一个很好的“另存为...”对话框。我相信代码看起来像这样: