Export HTML Table to Word Document in ASP.Net

Last Reply one year ago By dharmendr

Posted one year ago

Hello Sir,

Below is the html table which i want to export it to word document.

Please help me out.

<html>
<head>
    <style>
        table, th, tr, td
        {
            border: 1px solid;
        }
    </style>
</head>
<body>
    <div class="table-responsive" id="Div1" runat="server">
        <table class="table">
            <thead>
                <tr>
                    <th>
                        Date
                    </th>
                    <th>
                        Day
                    </th>
                    <th>
                        Time
                    </th>
                    <th>
                        Time1
                    </th>
                    <th>
                        Time3
                    </th>
                    <th>
                        Hours1
                    </th>
                    <th>
                        hours2
                    </th>
                    <th>
                        Hours3
                    </th>
                    <th>
                        Total Hours
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>
                        <asp:TextBox ID="TextBox1" CssClass="form-control" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox3" Text="Monday" CssClass="form-control" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox4" CssClass="form-control" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox5" CssClass="form-control" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox6" CssClass="form-control" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox7" CssClass="form-control" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox8" CssClass="form-control" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox9" CssClass="form-control" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox10" CssClass="form-control" runat="server"></asp:TextBox>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
</html>

Thanks 

You are viewing reply posted by: dharmendr one year ago.
Posted one year ago

Hi democloud,

Set runat=server property and assign id=gvDetails to table. Then refer below link for exporting to word document.

Export GridView To Word Excel PDF CSV Formats in ASP.Net