VB 中创建表格(2)

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

Private Function createContactTable() As String
        Try
            Dim dt As DataTable = getInformation()
            Dim i As Integer = 0
            Dim html As New System.Text.StringBuilder
            If dt.Rows.Count = 0 Then
                html.Append("<h4> No contact information avaialble at this time.</h4>")
            Else
                For i = 0 To dt.Rows.Count - 1
                    With html
                        .Append("<table class = ""contactTable"">")
                        .Append("   <tr>")
                        .Append("       <td><b>Company:</b></td>")
                        .Append("       <td>")
                        .Append(dt.Rows(i).Item("COMPANY"))
                        .Append("       </td>")
                        .Append("   </tr>")
                        .Append("   <tr>")
                        .Append("       <td><b>Name:</b></td>")
                        .Append("       <td>")
                        .Append(dt.Rows(i).Item("NAME"))
                        .Append("       </td>")
                        .Append("   </tr>")
                        .Append("   <tr>")
                        .Append("       <td><b>Position:</b></td>")
                        .Append("       <td>")
                        .Append(dt.Rows(i).Item("POSITION"))
                        .Append("       </td>")
                        .Append("   </tr>")
                        .Append("   <tr>")
                        .Append("       <td><b>Phone Number:</b></td>")
                        .Append("       <td>")
                        .Append(dt.Rows(i).Item("PHONE"))
                        .Append("       </td>")
                        .Append("   </tr>")
                        .Append("   <tr>")
                        .Append("       <td><b>E-mail:</b></td>")
                        .Append("       <td>")
                        .Append(dt.Rows(i).Item("EMAIL"))
                        .Append("       </td>")
                        .Append("   </tr>")
                        .Append("</table>")
                        .Append("<HR>")
                    End With
                Next
            End If

            Return html.ToString

        Catch ex As Exception
            Throw
        End Try
    End Function