htmlms-wordhtml-table

How to convert an HTML document with lots of tables into a Word document?


I have created an HTML document with many tables. How can I convert the document to Word?

The problem is that if I open an HTML document with Word, I get non-standard double-lines tables for some reason.

<table border="1" color="#000000" cellpadding="0" cellspacing="0" width=100%>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td width = 15%>0</td>
<td width = 15%>0</td>
<td width = 40%>0</td>
<td> - </td>
</tr>
</table>

Solution

  • Solved the problem convert a lot of tables to Word document using css styles. After open Generate.html with Word all tables normal

    File CSSTable.css

    table.CSSTable {
    border-width: 1px;
    border-spacing: 0px;
    border-style: solid;
    border-color: black;
    border-collapse: collapse;
    background-color: white;
    }
    table.CSSTable th {
        border-width: 1px;
        padding: 0px;
        border-style: solid;
        border-color: black;
        background-color: white;
        -moz-border-radius: ;
    }
    table.CSSTable td {
        border-width: 1px;
        padding: 0px;
        border-style: solid;
        border-color: black;
        background-color: white;
        -moz-border-radius: ;
    }
    

    Generate.html

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf8">
    <link rel="stylesheet" href="CSSTable.css" type="text/css">
    </head>
    <body>
    <table class="CSSTable" width=100%>
    <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    </tr>
    <tr>
    <td width = 15%>0</td>
    <td width = 15%>0</td>
    <td width = 40%>0</td>
    <td> - </td>
    </tr>
    </table>