I'm using DocumentFormat.OpenXml.Wordprocessing
to add a table in a Word document. What I need is to remove the border of the first 4(/6) cells in the last 3(/N) rows of the table. These rows are added like:
t.Append(new TableRow(
new TableCell(new Paragraph(new Run(new Text()))),
new TableCell(new Paragraph(new Run(new Text()))),
new TableCell(new Paragraph(new Run(new Text()))),
new TableCell(new Paragraph(new Run(new Text()))),
new TableCell(new Paragraph(new Run(new Text("Total:")))),
new TableCell(new Paragraph(new Run(new Text(priceTotal.ToString()))))
));
How do I set the TableCellBorders
? I've tried a few things like:
TableCell cell = new TableCell();
cell.TableCellProperties.TableCellBorders.LeftBorder.Size.Value = 0;
cell.TableCellProperties.TableCellBorders.RightBorder.Size.Value = 0;
cell.TableCellProperties.TableCellBorders.TopBorder.Size.Value = 0;
cell.TableCellProperties.TableCellBorders.BottomBorder.Size.Value = 0;
However, everything that I've tried returns System.NullReferenceException
. What is the proper way of removing the cell borders?
You can create a table in word with no borders like this:
Customize and optimize it, to your needs :)