Friday, June 13, 2014

OpenXML >> Setting the border property of table cells

By default, when you add the cell to table a single line border appears. Say you want to insert a cell in to the table and do not want to give any border or your own customized border to the cell. This can be done by following code:

TableRow newRow = new TableRow();
                        TableCell newcell = new TableCell();

                        newcell.Append(new TableCellProperties(
                            new TableCellBorders(
                                new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Nil) },
                                new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Nil)})));
newRow.Append(newcell);

Using this code, you can create a 0-border cell in the table. You can insert the created row to the existing table. I covered the method to access existing table and insert row to it in my another blog here.

The details of TableCellBorders can be referred MSDN .

No comments:

Post a Comment