Created
November 8, 2013 10:07
-
-
Save fdeitelhoff/7368922 to your computer and use it in GitHub Desktop.
Format a 170 x 170 cell area in Excel 2013 with a gray background and a black border.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void ApplyFormatting(int rows, int columns) | |
{ | |
// Complete surrounding borders of the gray box. | |
Range[Cells[1, 1], Cells[rows, columns]].Interior.Color = Color.LightGray; | |
Range[Cells[1, 1], Cells[rows, columns]].Borders[XlBordersIndex.xlEdgeTop].LineStyle = XlLineStyle.xlContinuous; | |
Range[Cells[1, 1], Cells[rows, columns]].Borders[XlBordersIndex.xlEdgeLeft].LineStyle = XlLineStyle.xlContinuous; | |
Range[Cells[1, 1], Cells[rows, columns]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous; | |
Range[Cells[1, 1], Cells[rows, columns]].Borders[XlBordersIndex.xlEdgeRight].LineStyle = XlLineStyle.xlContinuous; | |
// Set all column width to 2.14. That's a nice looking width. | |
for (var i = 1; i <= 170; i++) | |
{ | |
var column = Columns[i, System.Type.Missing] as Range; | |
if (column != null) column.EntireColumn.ColumnWidth = 2.14; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment