I am working on a project that creates excel files.
I am having trouble placing a border on multiple cells to organize the excel file.
Let\'s say I want a b
This is the code that sets a border around each cell:
xlWS.get_Range("C9", "N9").Cells.Borders.Weight = XL.XlBorderWeight.xlMedium;
This code puts a border around the area from (row1,col1) to (row2,col2). Individual cells do not get a border. The variable color is an integer color index number. See http://www.databison.com/excel-color-palette-and-color-index-change-using-vba/ for a list of index numbers and their corresponding colors.
Range cell1 = worksheet.Cells[row1,col1];
Range cell2 = worksheet.Cells[row2,col2];
Range range = worksheet.get_Range(cell1,cell2);
range.BorderAround(
Type.Missing, XlBorderWeight.xlThick, (XlColorIndex)color, Type.Missing );