hi - I have not been able to set the font of the first line (in blue background) to be bold.
public void InsertAt(string bookMark, System.Data.DataTable aTable, System.Drawing.Font defaultFont, bool lineAtBottom)
{
if (mBuilder == null) throw new Exception("Null builder");
if (bookMark == string.Empty) throw new Exception("No bookmark found in InsertAt");
if (aTable != null && aTable.Rows.Count > 0)
{
mBuilder.MoveToBookmark(bookMark);
OPWord.Tables.Table outputTable = mBuilder.StartTable();
// outputTable.ClearBorders();
int nRow = 0;
mBuilder.ParagraphFormat.Style.Font.Name = defaultFont.Name;
mBuilder.RowFormat.Height = 18.4;
mBuilder.RowFormat.HeightRule = OPWord.HeightRule.Exactly;
foreach (System.Data.DataRow aRow in aTable.Rows)
{
nRow++;
for (int j = 0; j
{
// mBuilder.CellFormat.Width = 30.0;
OPWord.Tables.Cell aCell = mBuilder.InsertCell();
aCell.CellFormat.ClearFormatting();
aCell.CellFormat.Borders.ClearFormatting();
aCell.CellFormat.PreferredWidth = OPWord.Tables.PreferredWidth.FromPercent((double)(100.0 / aTable.Columns.Count));
aCell.FirstParagraph.ParagraphFormat.Alignment = OPWord.ParagraphAlignment.Center;
aCell.CellFormat.VerticalAlignment = OPWord.Tables.CellVerticalAlignment.Center;
if (nRow == aTable.Rows.Count && lineAtBottom)
{
aCell.CellFormat.Borders.Bottom.LineStyle = OPWord.LineStyle.Thick;
aCell.CellFormat.Borders.Bottom.LineWidth = 1.5;
}
if (nRow == 1)
{
aCell.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.FromArgb(0, 51, 153);
aCell.FirstParagraph.ParagraphFormat.Style.Font.Bold = true;
}
else
{
aCell.FirstParagraph.ParagraphFormat.Style.Font.Bold = false;
}
aCell.FirstParagraph.AppendChild(new Aspose.Words.Run(mDoc, aRow[j].ToString()));
// mBuilder.Write(aRow[j].ToString());
}
mBuilder.EndRow();
}
// outputTable.PreferredWidth = OPWord.Tables.PreferredWidth.FromPoints(450);
mBuilder.EndTable();
}
}