We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Right border of merged cell of table is lost using VB.NET

When I add all borders to a merged cell in a table the right border is not shown when opening the document in word.
The same works fine on a non merged cell.
I’m using version 16.11.0.0 of Aspose.Words.

Please use the vb.net code below to demonstrate the problem.

Thomas

Dim doc As New Document()
Dim builder As New DocumentBuilder(doc)

Dim table As Table = builder.StartTable()
'create some cells
For introw As Integer = 0 To 4
For intcol As Integer = 0 To 5
builder.InsertCell()
builder.Writeln(String.Format(“Row:{0} Col:{1}”, introw, intcol))
Next
builder.EndRow()
Next

builder.EndTable()
table.ClearBorders()

'merge cells in third row
table.Rows(2).Cells(0).CellFormat.HorizontalMerge = CellMerge.First
table.Rows(2).Cells(1).CellFormat.HorizontalMerge = CellMerge.Previous

'add border in merged cell
With table.Rows(2).Cells(0).CellFormat.Borders
.Left.LineStyle = LineStyle.Single
.Left.LineWidth = 1
.Left.Color = Color.Black
.Right.LineStyle = LineStyle.Single
.Right.LineWidth = 1
.Right.Color = Color.Black
.Top.LineStyle = LineStyle.Single
.Top.LineWidth = 1
.Top.Color = Color.Black
.Bottom.LineStyle = LineStyle.Single
.Bottom.LineWidth = 1
.Bottom.Color = Color.Black
End With

'add border in non-merged cell
With table.Rows(1).Cells(0).CellFormat.Borders
.Left.LineStyle = LineStyle.Single
.Left.LineWidth = 1
.Left.Color = Color.Black
.Right.LineStyle = LineStyle.Single
.Right.LineWidth = 1
.Right.Color = Color.Black
.Top.LineStyle = LineStyle.Single
.Top.LineWidth = 1
.Top.Color = Color.Black
.Bottom.LineStyle = LineStyle.Single
.Bottom.LineWidth = 1
.Bottom.Color = Color.Black
End With

doc.Save(“c:\temp\merged_with_border.doc”)
Process.Start(“c:\temp\merged_with_border.doc”)

Hi Thomas,


Thanks for your inquiry. We have tested the scenario using Aspose.Words for .NET 17.3.0 and noticed the border issue of merged cell, so logged a ticket WORDSNET-15104 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

We are sorry for the inconvenience.

Best Regards,

I just saw this problem with a client again.
Has this ever been fixed?
If yes in which version?

Thomas

@toschf71de

Please accept my apologies for your inconvenience.

It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-15104) as ‘Not a Bug’.

You can create document without horizontal merge of cells. Comment this lines of code to get table without merged cells.

Cells of the third row can be merged in MS Word (GUI) manually to check original behavior. You can see that right border of the merged cell is missed (see attached not_merged_with_border.zip (2.3 KB) document). So, current behavior is valid.

Please use following code snippet to set the borders for specified example:

Dim _with1 = table.Rows(2).Cells(0).CellFormat.Borders
_with1.Left.LineStyle = LineStyle.Single
_with1.Left.LineWidth = 1
_with1.Left.Color = Color.Black
_with1.Top.LineStyle = LineStyle.Single
_with1.Top.LineWidth = 1
_with1.Top.Color = Color.Black
_with1.Bottom.LineStyle = LineStyle.Single
_with1.Bottom.LineWidth = 1
_with1.Bottom.Color = Color.Black
_with1 = table.Rows(2).Cells(1).CellFormat.Borders
_with1.Right.LineStyle = LineStyle.Single
_with1.Right.LineWidth = 1
_with1.Right.Color = Color.Black