Free Support Forum -

Can't reset border (47.0 KB)
attached is my project.
expected.docx is what I’m expecting to see.
got.docx is what I got.

I am storing table borders, adding some rows, clearing the borders, then restoring the borders from what was saved.
however, the borders are not restoring.

(tracked it down to the border clear. if you comment that out, it works fine).


Thanks for your inquiry. Please use the following modified code to get the desired output. Hope this helps you.

static void testborders(Document aDocument, int tIndex)
    Table aTable = (Table)aDocument.GetChild(NodeType.Table, tIndex, true);
    Row aRow;
    BorderCollection borders = aTable.FirstRow.RowFormat.Borders;
    aRow = AppendRow(aDocument, aTable, 3);
    aRow = AppendRow(aDocument, aTable, 3);
    aRow = AppendRow(aDocument, aTable, 3);
    DeleteRow(aTable, 0);
    foreach (Row row in aTable)
    aTable.SetBorder(BorderType.Left, borders.Left.LineStyle, borders.Left.LineWidth, borders.Left.Color, true);
    aTable.SetBorder(BorderType.Right, borders.Right.LineStyle, borders.Right.LineWidth, borders.Right.Color, true);
    aTable.SetBorder(BorderType.Bottom, borders.Bottom.LineStyle, borders.Bottom.LineWidth, borders.Bottom.Color, true);
    aTable.SetBorder(BorderType.Top, borders.Top.LineStyle, borders.Top.LineWidth, borders.Top.Color, true);