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

Free Support Forum - aspose.com

CellSpacing changing borders on .NET Table object

Hi,

I have found an issue when manipulating CellSpacing on a Table object.

When I construct a Table and change its defualt CellSpacing from 0 to a different value i.e. 1 and then back to 0, borders are not the same, they are duplicated. See code example below. Could you please fix this?

P.S. if you uncomment SetBorder lines, the result is even more surprising.

        var doc= new Document();
        var builder = new DocumentBuilder(doc);
        var table = builder.StartTable();
        var row1 = new Row(doc);

        var row2 = new Row(doc);
        var cell1 = new Cell(doc);
        var cell2 = new Cell(doc);
        var cell3 = new Cell(doc);
        var cell4 = new Cell(doc);
        row1.AppendChild(cell1);
        row1.AppendChild(cell2);
        table.AppendChild(row1);
        row2.AppendChild(cell4);
        row2.AppendChild(cell3);
        table.AppendChild(row2);
        //table.SetBorder(BorderType.Bottom,LineStyle.None, 0, Color.Black, false);
        //table.SetBorder(BorderType.Left, LineStyle.None, 0, Color.Black, false);
        //table.SetBorder(BorderType.Top, LineStyle.None, 0, Color.Black, false);
        //table.SetBorder(BorderType.Right, LineStyle.None, 0, Color.Black, false);
        table.CellSpacing = 1;
        table.CellSpacing = 0;
        builder.EndTable();
        builder.Document.Save(@".\test2.docx");

Thanks,
Lukasz

@acturisaspose,

Thanks for your inquiry. Please note that Aspose.Words mimics the behavior of MS Word. If you set the cell spacing as 1 and then 0 using MS Word, you will get the same output.