加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 08:12:19 所属栏目:百科 来源:网络整理
导读:首先,我将纸张的颜色边框更改为白色,因为我想要一张白纸.然后我做了一些标题,并想围绕它做边框.问题是它在标题中的值之间建立了边界,但顶部,向下是不可见的. 我的代码: xlWorkSheet5.Columns.Borders.Color = System.Drawing.ColorTranslator.ToOle(System.
首先,我将纸张的颜色边框更改为白色,因为我想要一张白纸.然后我做了一些标题,并想围绕它做边框.问题是它在标题中的值之间建立了边界,但顶部,向下是不可见的.

我的代码:

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;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读