1

这是我在 C# 代码中的 html 代码

tosend = "<p><tr><th>The directory searched:  " + path + " </th><th> between the dates " + fdate + " and  " + ldate + "</th></tr> <br> </p> <tr><th>File Name</th>  <th>File Date</th>  <th>File Hash</th>  <th>Beamer Date</th>  <th>Beamer Hash</th> <th>Status</th></tr>";
for (int i = 0; i < thexfiles.Length; i++)
{ 
    tosend = tosend + "<tr><td>" + thexfiles[i] + "</td><td>" + filedate[i] + "</td><td>" + hashList[i] + "</td><td>" + thexdates[i] + "</td><td>" + beamerHash[i] + "</td><td>" +status[i] + "</td></tr>"; 
}
tosend = "<html><table border="+1+">" + tosend + "</table></html>"; 

这是它的外观链接:点击这里

我想做的是,

  1. 我想扩展第一行,使其与其他行的大小相同,
  2. 如您所见,日期行和状态行的高度太多,我希望它们看起来像一条线,例如展开。

这就是我所需要的,到目前为止我已经尝试过正常的 html width-height 等,我可能因为错误的符号而无法成功。

4

3 回答 3

1

您可以使用colspan="100%"扩展第一行(或使用设置的列数)。除此之外,您只是想将太多数据挤入一个小区域。您必须缩短时间或删除一列才能使行高与您拥有的数据正常工作。您还可以强制较长的列为其他列提供更多空间,但也会导致它们换行。

另请注意,<br></>p>行之间的标签不是有效的 HTML。

tosend = "<tr><th>The directory searched:  " + path + " </th><th colspan='100%'> between the dates " + fdate + " and  " + ldate + "</th></tr><tr><th>File Name</th>  <th>File Date</th>  <th>File Hash</th>  <th>Beamer Date</th>  <th>Beamer Hash</th> <th>Status</th></tr>";

for (int i = 0; i < thexfiles.Length; i++)
{  
    tosend = tosend + "<tr><td>" + thexfiles[i] + "</td><td>" + filedate[i].ToShortDateString() + "</td><td>" + hashList[i] + "</td><td>" + thexdates[i].ToShortDateString() + "</td><td>" + beamerHash[i] + "</td><td>" +status[i] + "</td></tr>";  
}
tosend = "<html><table border="+1+">" + tosend + "</table></html>"; 
于 2012-07-12T12:18:26.780 回答
0

正如@David 所说,HTML 的构造是无效的。

  • 在“tr”中间有一个“p”和“br”标签
  • 标签也丢失了。

尝试以这种方式构建表格。我单独放置 HTML 代码

 <html>
<body>
<table border=1>
     <tr>
        <th colspan="3">The directory searched</th>
        <th colspan="3"> between the dates </th>
     </tr>
     <tr>
        <th>File Name</th>
        <th>File Date</th>
        <th>File Hash</th>
        <th>Beamer Date</th>
        <th>Beamer Hash</th>
        <th>Status</th>
     </tr>

     <tr>
        <td>thexfiles[i]</td>
        <td>filedate[i]</td>
        <td>hashList[i]</td>
        <td>thexdates[i]</td>
        <td>beamerHash[i]</td>
        <td>status[i]</td>
    </tr>
</table>
</body>
 </html>
于 2012-07-12T12:15:32.117 回答
0
  1. 对于第一行的单元格,如果您希望它以 5 列的形式出现,请使用 <td colspan="5">。

  2. 将 <td nowrap="nowrap"> 用于您希望在 1 行中包含的单元格。

于 2012-07-12T12:15:38.160 回答