Quantcast
Channel: CodeProject Latest postings for ASP.NET
Viewing all articles
Browse latest Browse all 3938

How do layout out the columns using stringbuilder?

$
0
0
I am dynamically creating a PDf in memory and sending a PDF attachment via email.

This works fine.

What I am having problem with is presenting the data in the format management wants.

For instance, they would want the layout in following format:

John Doe                    12345
Employee Name                Employee ID

john doe
Signature

11/04/2016
Date

How do I fix the code below to accomplish this?

Thanks in advance

I have modified my request and narrowed the help I need to one specific issue.
 
I need to lay out the results to look similar to this sample below:
 

<pre><pre lang="PHP">
John Doe 12345

Employee Name Employee ID

john doe

Signature

11/04/2016

Date

So far, everything is wrapping to one column.

I am using stringbuilder.

How do I fix this?

Private Sub SendPDFEmail(dtb As DataTable)
    Using sw As New StringWriter()
        Using hw As New HtmlTextWriter(sw)
            Dim FullName As String = txtFullName.Text
            Dim userAs String = txtUserName.Text
            Dim signedName As String = txtSignature.Text
            Dim lDate As String = txtDate.Text
            Dim sb As New StringBuilder()
            sb.Append("<table border = '0'>")
            sb.Append("<tr>")
            For Each columnAs DataColumn In dtb.Columns
                sb.Append("<th style = 'background-color: #ffffff;color:#000000'>")
                sb.Append(column.ColumnName)
                sb.Append("</th>")
            Next
            sb.Append("</tr>")
            For Each row As DataRow In dtb.Rows
                sb.Append("<tr>")
                For Each columnAs DataColumn In dtb.Columns
                    sb.Append("<td>")
                    sb.Append(row(column))
                    sb.Append("</td>")
                Next
                sb.Append("</tr>")
            Next
            sb.Append("</table>")
            sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>")
            sb.Append("<tr><td align='center' style='background-color: #ffffff' colspan = '1'></td></tr>")
            sb.Append("<tr><td colspan = '3'>")
            sb.Append(""& FullName & "</td><td>" & user& "</td></tr>")
            sb.Append("<tr><td>Employee ID: </td><td>Employee Signature: ")
            sb.Append("</td></tr><tr><td colspan = '3'>")
            sb.Append(""& signedName & "")
            sb.Append("</td><td> </td></tr><tr><td>Employee Signature")
            sb.Append("</td><td> </td></tr>")
            sb.Append("<tr><td colspan = '2'>"& lDate & "</td><td> </td></tr>")
            sb.Append("<tr><td colspan = '2'>Date :</td><td> </td>")
            sb.Append("</tr>")
            sb.Append("</table>")
            sb.Append("
")

Viewing all articles
Browse latest Browse all 3938

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>