In excel, how do I set the cell font to be bold programatically?
My code so far follows:
dr = GFun.ReadSql(sql);
xlRow = 3;
while (dr.Read())
{
xlWorkSheet.Cells[xlRow,1] = dr[0].ToString().Trim();
chartRange = xlWorkSheet.get_Range("A" + xlRow, "E" + xlRow);
chartRange.MergeCells = true;
chartRange.Cells.Font.Bold = true;
chartRange.Cells.Font.FontStyle = HorizontalAlignment.Center;
xlRow = xlRow + 1;
xlWorkSheet.Cells[xlRow, 1] = "Date";
xlWorkSheet.Cells[xlRow, 2] = "Session 1";
xlWorkSheet.Cells[xlRow, 3] = "Session 2";
xlWorkSheet.Cells[xlRow, 4] = "Session 3";
xlWorkSheet.Cells[xlRow, 5] = "Session 4";
xlRow = xlRow + 1;
}
I wrote the line below but in excel it is not bold. How can I do this? From my code below, what is the mistake? Please help me.
chartRange.Cells.Font.Bold = true;