Hi,
I have a table with rows and cells. For the cells I want to set the HorizontalAlignment but is does not change the alignment. I use the next code:
Dim row As WTableRow = table.AddRow()
Dim cell As WTableCell = row.AddCell()
cell.Width = 200
cell.CellFormat.BackColor = Color.DarkBlue
cell.CellFormat.Borders.BorderType = BorderStyle.None
Call AlignCellContent(cell, VerticalAlignment.Middle, HorizontalAlignment.Right)
cell.AddParagraph().AppendText("XXXXX")
cell = row.AddCell()
cell.Width = 200
cell.CellFormat.BackColor = Color.DarkBlue
cell.CellFormat.Borders.BorderType = BorderStyle.None
Call AlignCellContent(cell, VerticalAlignment.Middle, HorizontalAlignment.Center)
cell.AddParagraph().AppendText("YYYYY")
Private Sub AlignCellContent(ByVal tableCell As WTableCell, ByVal verticalAlignment As VerticalAlignment, ByVal horizontalAlignment As HorizontalAlignment)
tableCell.CellFormat.VerticalAlignment = verticalAlignment
AlignCellContentForTextBody(tableCell, horizontalAlignment)
End Sub
Private Sub AlignCellContentForTextBody(ByVal textBody As WTextBody, ByVal horizontalAlignment As HorizontalAlignment)
For i As Integer = 0 To textBody.ChildEntities.Count - 1
Dim bodyItemEntity As IEntity = textBody.ChildEntities(i)
Select Case bodyItemEntity.EntityType
Case EntityType.Paragraph
Dim paragraph As WParagraph = TryCast(bodyItemEntity, WParagraph)
paragraph.ParagraphFormat.HorizontalAlignment = horizontalAlignment
Case EntityType.Table
AlignCellContentForTable(TryCast(bodyItemEntity, WTable), horizontalAlignment)
Case EntityType.BlockContentControl
Dim blockContentControl As BlockContentControl = TryCast(bodyItemEntity, BlockContentControl)
AlignCellContentForTextBody(blockContentControl.TextBody, horizontalAlignment)
End Select
Next
End Sub
Private Sub AlignCellContentForTable(ByVal table As WTable, ByVal horizontalAlignment As Syncfusion.DocIO.DLS.HorizontalAlignment)
For Each row As WTableRow In table.Rows
For Each cell As WTableCell In row.Cells
AlignCellContentForTextBody(cell, horizontalAlignment)
Next
Next
End Sub