Import HTML table with CSS to MS Word
I have created a table below using R
with HTML code attached at the end of the question.
The default output from R
fits perfectly my need, but I need table to be shown and editable in MS Word. I tried: i) copy-and-paste the table from firefox to MS Word; and ii) open the html file using MS Word. Both give me table with distorted style.
Is there anyway to copy the table as it is seen below from HTML to word?
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<style>table { border-collapse:collapse; border:none; }
th { border-bottom: 1px solid; }
table td { padding:0.2cm; }
.summary td { padding-top:0.1cm; padding-bottom:0.1cm }
.colnames td { font-style:italic }
.firstsumrow { border-top:1px solid }
.lasttablerow { border-bottom: double; }
.topborder { border-top:2px solid }
.depvarhead { text-align:center; border-bottom:1px solid; border-top:1px solid }
.topcontentborder { border-top:double }
.annorow { border-top:2px solid }
.annostyle { text-align:right }
</style>
</head>
<body>
<table>
<tr class="topborder">
<td rowspan="2"><em>Predictors</em></td>
<td colspan="3" class="depvarhead"><em>Dependent Variables</em></td>
</tr>
<tr>
<td colspan="3">Barthel-Index</td>
</tr>
<tr class="colnames">
<td> </td>
<td>B (CI)</td><td>std. Beta</td><td>p</td>
</tr>
<tr class="topcontentborder">
<td>(Intercept)</td>
<td>93.76 (85.95-101.57)</td> <td></td><td><b>0.000</b></td>
</tr>
<tr>
<td>Carer's Age</td>
<td>-0.55 (-0.69--0.41)</td> <td>-0.25</td><td><b>0.000</b></td>
</tr>
<tr class="summary firstsumrow">
<td>Observations</td>
<td colspan="3">880</td>
</tr>
<tr class="summary">
<td>R<sup>2</sup> / adj. R<sup>2</sup></td>
<td colspan="3">0.061 / 0.060</td>
</tr>
<tr class="summary">
<td>AIC</td>
<td colspan="3">8424.34</td>
</tr>
<tr class="annorow">
<td>Notes</td><td class="annostyle" colspan="3"><em>* p<0.005 ** p<0.01 *** p<0.001</em></td>
</tr>
</table>
</body></html>
Solution 1:
Import to libreoffice, save as .doc and open in Word. Libreoffice does a better job of importing html tables.