Hi,
I am creating a table. I want cell spacing, I do not want a border around the entire table. This is a sample from my code. If I remove the line ‘outerTable.CellSpacing = 2;’ my table does not have a border or cell spacing. When this line is included, the table gets a black border around the outside in addition to the cell spacing. Is there a workaround to prevent this from happening? I am using the latest version.
Table outerTable = tableDocBuilder.StartTable();
tableDocBuilder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
tableDocBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
for (int i = 0; i < 5; i++) {
Cell wordCell = tableDocBuilder.InsertCell();
wordCell.CellFormat.Borders.ClearFormatting();
tableDocBuilder.CellFormat.TopPadding = 2;
tableDocBuilder.CellFormat.RightPadding = 2;
tableDocBuilder.CellFormat.BottomPadding = 2;
tableDocBuilder.CellFormat.LeftPadding = 2;
tableDocBuilder.Write(i.ToString());
}
tableDocBuilder.EndRow();
outerTable.CellSpacing = 2;
tableDocBuilder.EndTable();
Hi David,
Thanks for your inquiry. In your case, once the table construction is finished, please clear the borders at the end as shown below:
DocumentBuilder tableDocBuilder = new DocumentBuilder();
Table outerTable = tableDocBuilder.StartTable();
tableDocBuilder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
tableDocBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
for (int i = 0; i < 5;
i++)
i++)
{
Cell wordCell = tableDocBuilder.InsertCell();
wordCell.CellFormat.Borders.ClearFormatting();
tableDocBuilder.CellFormat.TopPadding = 2;
tableDocBuilder.CellFormat.RightPadding = 2;
tableDocBuilder.CellFormat.BottomPadding = 2;
tableDocBuilder.CellFormat.LeftPadding = 2;
tableDocBuilder.Write(i.ToString());
}
tableDocBuilder.EndRow();
tableDocBuilder.EndTable();
outerTable.CellSpacing = 10;
outerTable.ClearBorders();
tableDocBuilder.Document.Save(@“C:\temp\out.docx”);
I hope, this will help.
Best Regards,