c# – 在Excel中左,右,底部和顶部更改边框

前端之家收集整理的这篇文章主要介绍了c# – 在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);

解决方法

好的我找到了解决方案,这是我的代码
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;
原文链接:https://www.f2er.com/csharp/101102.html

猜你在找的C#相关文章