Hello,
As I’m using an approved template to build the document I need to adhere to the formats consistent throughout; I’ve got a couple of issues with a table I’m dynamically inserting into a Word document:
-
I need to set the table border color to ‘Automatic’. Not sure how to do this as it is not one of the available values for System.Drawing.Color
-
I’m trying to merge 2 cells at the table header but it’s not working
-
I’ve specified the font for the text being written inside the table but it’s coming out in a different font style (it’s odd because when I place the cursor on the text of the generated document MS Word shows the correct font style in the font box but I can clearly see it’s Times New Roman.
Here is the code I’m using:
Dim ProdTable As Table = OFbuilder.StartTable()
OFbuilder.Font.Name = "Calibri (Body)"
OFbuilder.Font.Bold = True
OFbuilder.Font.Size = 11
OFbuilder.InsertCell()
OFbuilder.Write("Current Monthly Recurring Subscriptions")
OFbuilder.InsertCell()
OFbuilder.CellFormat.HorizontalMerge = CellMerge.First
OFbuilder.EndRow()
OFbuilder.InsertCell()
OFbuilder.Write("Product")
OFbuilder.InsertCell()
OFbuilder.Write("Service Type")
OFbuilder.EndRow()
OFbuilder.Font.Bold = False
Do While RowCount > 0
OFbuilder.InsertCell()
OFbuilder.Write(dtProducts.Rows(RowCount - 1).Item(1))
OFbuilder.InsertCell()
OFbuilder.Write(dtProducts.Rows(RowCount - 1).Item(0))
OFbuilder.EndRow()
RowCount -= 1
Loop
ProdTable.SetBorders(LineStyle.Outset, 0.75, System.Drawing.Color.DimGray)
ProdTable.LeftIndent = 5
OFbuilder.EndTable()