<table summary="merhaba" class="datagrid" id="tablo1" runat="server">
<thead><tr>
<th id="Th1" style="border:solid 1px #000000" runat="server">ad</th>
<th id="Th2" runat="server">Soyad</th>
<th id="Th3" runat="server">TC</th>
</tr>
</thead>
<tbody>
<tr>
<td>ebrar</td>
<td>bayburt</td>
<td>999</td>
</tr>
</tbody>
</table>
次の方法で行を追加できます。
$('#button').click(function () {//tabloya veri ekleme
$('#tablo1 > tbody:last')
.append('<tr><td class="A">' +
$('#ad_').val()
+ '</td><td class="K">' +
$('#soyad_').val()
+ '</td><td class="A">' +
$('#tc_').val()
+ '</td></tr>');
});
そして、次のコードを使用して、テーブルを Excel にエクスポートできます。
protected void Button1_Click2(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=myexcel.xls");
Response.ContentType = "application/ms-excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(sw);
tablo1.RenderControl(hw);
Response.Write(sw.ToString());
Response.End();
}
しかし、Excel ファイルを開くと、クライアントから追加された行が表示されず、コードで追加した行のみが表示されます。
<tbody>
<tr>
<td>ebrar</td>
<td>bayburt</td>
<td>999</td>
</tr>
</tbody>
私はこの質問をした
HTMLテーブルをExcelにエクスポートするための私の最初の質問
しかし、jqueryで行を追加する必要があります。追加した後、追加された行がいっぱいになった状態でhtmlテーブルをExcelにエクスポートする必要があります。方法はありますか?