Hello, I have a custom table ( in a dotnet web application), I am using Aspose word documentation and I am facing issue that in my custom table I am not able to close the table (the final table border is not appearing).
Below is the code I am using for creating my custom table:
private void AddCustomTable(DocumentBuilder builder, List<SomeCustomListItem> rows, string title)
{
var columns = new List<string>
{
"Value1",
"Value2"
};
Table table = builder.StartTable();
FormatRowHeading();
//Insert first merged cell
for (int i = 0; i < columns.Count; i++)
{
builder.InsertCell();
builder.CellFormat.HorizontalMerge = i == 0 ? CellMerge.First : CellMerge.Previous;
if (i == 0)
{
builder.Write(title);
}
}
builder.EndRow();
FormatHeaderColumns();
// Create a new row and insert the name of each column into the first row of the table.
builder.CellFormat.HorizontalMerge = CellMerge.None;
foreach (var column in columns)
{
builder.InsertCell();
builder.Write(column);
}
builder.EndRow();
FormatRows();
foreach (var row in rows)
{
builder.InsertCell();
builder.Write(row.Value1?.ToString() ?? string.Empty);
builder.InsertCell();
builder.Write(row.Value2?.ToString() ?? string.Empty);
builder.EndRow();
}
// We have finished inserting all the data from the DataTable, we can end the table.
builder.EndTable();
builder.Writeln();
builder.Writeln();
void FormatRowHeading()
{
builder.Font.Bold = true;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
builder.Font.Size = 8;
builder.Font.Color = ColorTranslator.FromHtml("#ffffff");
builder.Font.Name = "EYInterstate Light";
builder.ParagraphFormat.SpaceAfter = 3;
builder.ParagraphFormat.SpaceBefore = 3;
builder.CellFormat.Shading.BackgroundPatternColor = ColorTranslator.FromHtml("#797991");
builder.CellFormat.Borders.Color = ColorTranslator.FromHtml("#ffffff");
builder.CellFormat.Borders.LineWidth = 0.01;
builder.CellFormat.SetPaddings(1, 1, 1, 1);
builder.CellFormat.Borders.Bottom.LineStyle = LineStyle.None;
}
void FormatRows()
{
builder.Font.Bold = false;
builder.Font.Color = ColorTranslator.FromHtml("#000000");
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.CellFormat.Shading.BackgroundPatternColor = ColorTranslator.FromHtml("#ffffff");
builder.CellFormat.Borders.Color = ColorTranslator.FromHtml("#D2D2DA");
builder.RowFormat.Height = 17;
builder.RowFormat.HeightRule = HeightRule.AtLeast;
}
void FormatHeaderColumns()
{
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.Font.Bold = true;
builder.Font.Color = ColorTranslator.FromHtml("#000000");
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.CellFormat.Shading.BackgroundPatternColor = ColorTranslator.FromHtml("#D2D2DA");
}
}
Please assist me on the same.