Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
like image 556
Rob Avatar asked Dec 06 '25 18:12

Rob


1 Answers

And if you want to have shade on the specific row.

Kindly add the following to your row element.

TableCellProperties tableCellProperties = new TableCellProperties();

                                      var shading = new Shading()
                                      {
                                          Color = "auto",
                                          Fill = "D9D9D9",
                                          Val = ShadingPatternValues.Clear
                                      };
                                      tableCellProperties.Append(shading);
                                      rowElement.Append(tableCellProperties);

Attached the expected result. enter image description here

like image 110
Marc Kenneth Lomio Avatar answered Dec 10 '25 20:12

Marc Kenneth Lomio