Missing Borders in cell using builder.CellFormat


Hi, I'm using Aspose Words and I'm trying to build a table using
some code like the following
builder.Font.Name = "Arial"

builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center
builder.CellFormat.Borders.LineStyle = LineStyle.None
builder.CellFormat.Width = 2 * px

'Even commenting the following rows I can't get top and bottom borders
builder.CellFormat.Borders(Aspose.Words.BorderType.Top).LineStyle = LineStyle.Single
builder.CellFormat.Borders(Aspose.Words.BorderType.Left).LineStyle = LineStyle.Single
builder.CellFormat.Borders(Aspose.Words.BorderType.Bottom).LineStyle = LineStyle.Single
builder.CellFormat.Borders(Aspose.Words.BorderType.Right).LineStyle = LineStyle.Single
'Even commenting the previous rows I can't get top and bottom borders
builder.CellFormat.Borders.LineStyle = LineStyle.Single
builder.CellFormat.Borders.LineWidth = 1
builder.CellFormat.Width = 4 * px '7"
builder.Bold = True
builder.RowFormat.Alignment = RowAlignment.Center
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center

I obtain the word document attached and the top and bottom borders of the cell
with NORME as text are missing, only left and right bordes are visible.

How can I get it working ?

Thank You

Claudio Mellina


The code that you have posted works correctly in my test. Please attach a complete project or try to compose the smaller test project reproducing the error.

Best regards,



I've found the problem and how to reproduce it.

Using the attached code, uncommenting the line between TODO the table looses top and bottom borders.

Private Sub Sostituisci(ByRef doc As Aspose.Words.Document, ByRef errMsg As String)

Dim builder As DocumentBuilder = New DocumentBuilder(doc)
Dim ncol As Int32
Dim px As Int32 = 66

DeleteParagraph(doc, "P37", errMsg)
'If I execute also the following line the table loses top and bottom borders
'DeleteParagraph(doc, "P38", errMsg)

builder = New DocumentBuilder(doc)
builder.Font.Name = "Arial"



Thank you for this. I will check it up and let you know ASAP.

Best regards,


The DeleteParagraph procedure does not look good. Using exceptions as part of application logic is generally a bad idea. The behavior of library code after the exception is 'swallowed' by calling app is unpredictable. Why not using the simple code like this:

Private Sub DeleteParagraph(ByRef doc As Aspose.Words.Document, ByVal bookmark As String, ByRef errMsg As String)

Dim builder As DocumentBuilder = New DocumentBuilder(doc)

If builder.MoveToMergeField(bookmark) Then


End If

End Sub

The problems with disappearing borders are eliminated after this.

Best regards,


Thank You, I'll try