Search code examples
c#ms-wordopenxmlopenxml-sdk

Open XML - Word Processing Document - Table Cell Border


I can add a border to a table row, but how can I add a top border to a table cell? I cannot seem to find this in the ECMA documentation.

   TableProperties tblProperties = new TableProperties();
    TableBorders tblBorders = new TableBorders();
    TopBorder topBorder = new TopBorder();
    topBorder.Val = new EnumValue<BorderValues>(BorderValues.Thick);
    topBorder.Color = "CC0000";
    tblBorders.AppendChild(topBorder);

    tblProperties.AppendChild(tblBorders);

Solution

  • Flydog57's comment to using the OpenXML Productivity Tool is the correct approach. You will spend way too much time attempting to figure things out on your own. Make a word document and then view it using the OpenXML Productivity Tool. Rinse and repeat.