Saturday, 7 September 2013

How do I create a downloadable excel sheet from an HTML-table?

How do I create a downloadable excel sheet from an HTML-table?

I have a table in HTML, like this:
<table>
<thead>
<tr>
<th>Column1</th>
<th>Column2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data1</td>
<td>Data2</td>
</tr>
</tbody>
</table>
I want to download this data in the form of an Excel-sheet. I've tried
some "simple" methods of just opening the data in a new window like this:
javascript:window.open('data:application/vnd.ms-excel,'+document.documentElement.innerHTML);
But the actual table I want to export has too many lines and it crashes
the browser..
Any ideas on how to solve this?
Thanks!

No comments:

Post a Comment