gpt4 book ai didi

c# - 在 Excel 中更改边框的左、右、下和上

转载 作者:太空狗 更新时间:2023-10-29 19:59:59 25 4
gpt4 key购买 nike

首先,我将工作表的颜色边框更改为白色,因为我想要一张白色的工作表。

然后我做了一些标题,想在它周围做一个边框。问题是它在 header 中的值之间设置了边界,但顶部和底部不可见。

我的代码:

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;

关于c# - 在 Excel 中更改边框的左、右、下和上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13817702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com