首先,我将纸张的颜色边框更改为白色,因为我想要一张白纸.然后我做了一些标题,并想围绕它做边框.问题是它在标题中的值之间建立了边界,但顶部,向下是不可见的.
我的代码:
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);
解决方法
好的我找到了解决方案,这是我的代码:
xlWorkSheet5.Cells[7,1].Borders[Excel.XlBordersIndex.xlEdgeLeft].Weight = 1d; xlWorkSheet5.Cells[7,1].Borders[Excel.XlBordersIndex.xlEdgeRight].Weight = 1d; xlWorkSheet5.Cells[7,1].Borders[Excel.XlBordersIndex.xlEdgeTop].Weight = 1d; xlWorkSheet5.Cells[7,1].Borders[Excel.XlBordersIndex.xlEdgeBottom].Weight = 1d;