J'utilise un code similaire à mentionner le code à http://www.dutch-creatives.com/post/2009/08/11/Export-ListView-to-Excel.aspx exporter Listview vers ExcelListview vers Excel HTML question de balisage
Mon listview
<asp:ListView ID="lv" runat="server">
<LayoutTemplate>
<table runat="server" id="table1" class="datatable" >
<tr class="row" id="tableRow" runat="server">
<th rowspan="2"></th>
</tr>
<tr runat="server" id="itemPlaceholder"></tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr1" runat="server" class="row">
<td id="Td1" runat="server">
<asp:Label ID="Label6" runat="server"
Text='<%#Eval("xyz") %>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
J'ajoute en-tête comme suit
' Create a form to contain the grid
Dim table = New HtmlTable()
Dim tCell = New HtmlTableCell()
Dim tRow = New HtmlTableRow()
'Add the header row
Dim header As HtmlTableRow = DirectCast(_listview.FindControl("tableRow"), HtmlTableRow)
ExlUtil.ConvertControl(header)
table.Rows.Add(header)
Et puis chaque article comme
For Each item As ListViewDataItem In _listview.Items
tCell.Controls.Add(item)
tRow.Controls.Add(tCell)
ExlUtil.ConvertControl(item)
table.Rows.Add(tRow)
Next
table.RenderControl(htw) //htw is htmltextwriter object
Mais (table.RenderControl) est rendu le code html final
<table>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
<tr> 'problem here
<td> 'problem here
<tr> <td></td> </tr>
<tr> <td></td> </tr>
</td>
</tr>
</table>
J'ai essayé de débogage, de comprendre pourquoi il génère un td supplémentaire tr sans pouvoir y parvenir. Quelqu'un peut-il me dire pourquoi il génère ce supplément tr, td?