首先,我将我的工作表的彩色边框更改为白色,因为我想要有一张白色的工作表。然后,我制作了一些标题,并希望围绕它制作边框。问题是它使标题中的值之间的边界成为边界,但是顶部,下部是不可见的。在Excel中左右,底部和顶部更改边框
我的代码:
xlWorkSheet5.Columns.Borders.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White); // Color Sheet5 to white, BusLoad
xlWorkSheet5.Columns.NumberFormat = "@";
Excel.Range rng = (Excel.Range)xlWorkSheet5.get_Range("A7","J7");
rng.RowHeight = 25.5;
rng.BorderAround2(Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight.xlHairline, Excel.XlColorIndex.xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic);
rng.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
rng.Borders.Weight = 1d;
rng.Font.Bold = true;
rng.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
rng.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGray);
使用'BorderAround'在'BorderAround2'代替? –
@K_B:我试过了,但结果是一样的 –
用你的第一行代码你不会将单元格的颜色改为白色,但是边界的颜色... –