Note. It is assumed that you will declare constants for row and column indices named COLUMN_HEADING_ROW , FIRST_COL and LAST_COL , and _xlSheet is the name ExcelSheet (using Microsoft.Interop.Excel )
First determine the range:
var columnHeadingsRange = _xlSheet.Range[ _xlSheet.Cells[COLUMN_HEADING_ROW, FIRST_COL], _xlSheet.Cells[COLUMN_HEADING_ROW, LAST_COL]];
Then set the background color of this range:
columnHeadingsRange.Interior.Color = XlRgbColor.rgbSkyBlue;
Finally, set the font color:
columnHeadingsRange.Font.Color = XlRgbColor.rgbWhite;
And here is the code combined:
var columnHeadingsRange = _xlSheet.Range[ _xlSheet.Cells[COLUMN_HEADING_ROW, FIRST_COL], _xlSheet.Cells[COLUMN_HEADING_ROW, LAST_COL]]; columnHeadingsRange.Interior.Color = XlRgbColor.rgbSkyBlue; columnHeadingsRange.Font.Color = XlRgbColor.rgbWhite;
B. Clay Shannon Nov 15 '15 at 1:21 2015-11-15 01:21
source share