Pim Jager Pim Jager - 2 months ago 17
HTML Question

Present tabular data on webpage so the user can directly copy it into Excel

On my webpage I want to able to present tabular data and give the user the possibility to copy it directly into excel. This however doesn't work, all of the data is pasted in one cell:

<table>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Data 1.1</td><td>Data 2.1</td></tr>
<tr><td>Data 1.2</td><td>Data 2.2</td></tr>
</table>


How to present this data so it can be copied directly into excel.

Answer

I just thought of the solution while typing out the question. You need to specify the table body:

<table>
<tbody>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Data 1.1</td><td>Data 2.1</td></tr>
<tr><td>Data 1.2</td><td>Data 2.2</td></tr>
</tbody>
</table>