I see from Microsoft's documentation that I can access the particular border edges of a cell using the 'xlBordersIndex' property and for example set the border style for the left edge of a cell:
range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft].LineStyle = Excel.XlLineStyle.xlContinuous;
But what if I just want to draw all borders? I have tried
range.BorderAround2();
but that just draws a box around the range itself, which I understand. So then I tried
range.Cells.BorderAround2();
thinking that it would go through each of the cells within the range and place all borders around each cell. This is not what occurred. So in order to get all borders around all cells in a range, must I manually access each of the four border indices?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…