我有一个 HTML 表格,如下所示:
<table>
<thead>
<tr>
<th>Column1</th>
<th>Column2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data1</td>
<td>Data2</td>
</tr>
</tbody>
</table>
我想以 Excel 表格的形式下载这些数据。我尝试了一些“简单”的方法,在新窗口中打开数据,如下所示:
javascript:window.open('data:application/vnd.ms-excel,'+document.documentElement.innerHTML);
但是我要导出的实际表有太多行,它会使浏览器崩溃..
关于如何解决这个问题的任何想法?
澄清:我想通过网页来做到这一点,例如使用一个按钮来触发一个功能来创建 Excel 表并开始下载它。像这样:
<button onclick="downloadExcelSheet()">Download the table as an excel sheet</button>