How do I bold the table header column captions? This is what I have and it builds the tables perfectly but I can’t bold the column caption (the first row).
Public Sub BuildTable(ByVal id_Sales As String, sproc As String, ByVal doc As Document, ByVal builder As DocumentBuilder)
Dim dt As DataTable = New DataTable
Try
Using myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("cnn_BC").ConnectionString)
Dim myCommand As New SqlCommand(sproc, myConnection)
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.Add(New SqlParameter("@id_sales", SqlDbType.Int))
myCommand.Parameters("@id_sales").Value = CInt(id_Sales)
myConnection.Open()
myCommand.ExecuteNonQuery()
Dim dr As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
dt.Load(dr)
myConnection.Close()
End Using
Catch myException As Exception
End Try
Dim table = builder.StartTable()
Dim row As New Row(doc)
row.RowFormat.AllowBreakAcrossPages = True
row.RowFormat.HeadingFormat = True
table.AppendChild(row)
' We can now apply any auto fit settings.
table.AutoFit(AutoFitBehavior.AutoFitToContents)
For Each myColumn As DataColumn In dt.Columns
' Create a cell and add it to the row
Dim cell As New Cell(doc)
cell.CellFormat.Shading.ForegroundPatternColor = Color.Transparent
cell.CellFormat.Width = 80
' Add a paragraph to the cell as well as a new run with some text.
cell.AppendChild(New Paragraph(doc))
cell.FirstParagraph.AppendChild(New Run(doc, myColumn.ColumnName))
' Add the cell to the row.
row.AppendChild(cell)
Next myColumn
row = New Row(doc)
row.RowFormat.AllowBreakAcrossPages = True
table.AppendChild(row)
'Add the data rows.
For Each myRow As DataRow In dt.Rows
For Each myColumn As DataColumn In dt.Columns
' Create a cell and add it to the row
Dim cell As New Cell(doc)
cell.CellFormat.Shading.BackgroundPatternColor = Color.Transparent
cell.CellFormat.Width = 80
' Add a paragraph to the cell as well as a new run with some text.
cell.AppendChild(New Paragraph(doc))
cell.FirstParagraph.AppendChild(New Run(doc, myRow(myColumn.ColumnName).ToString()))
' Add the cell to the row.
row.AppendChild(cell)
Next myColumn
row = New Row(doc)
row.RowFormat.AllowBreakAcrossPages = True
table.AppendChild(row)
Next myRow
'move into center of page
'table.Alignment = TableAlignment.Center
End Sub