如何在 C# Excel VSTO 中为单元格添加彩色边框?
我通过下面的链接找到了API,里面有一些关于添加边框的说明,但不是很具体。奇怪的是 VS2010 不识别 BorderAround() 方法。它似乎只识别BorderAround2(),但提示我输入的参数。
下面是我试过的代码,但是 VS 提示参数无效。
range.BorderAround2(Excel.XlLineStyle.xlDash, Type.Missing, Type.Missing, System.Drawing.Color.Red, Type.Missing);
请您参考如下方法:
我自己的方法类似于 idssl 建议的方法,但利用了 ColorTranslator.ToOle方法。
range.Borders.LineStyle = Excel.XlLineStyle.xlDot;
range.Borders.Color = ColorTranslator.ToOle(Color.Red);
这也适用于我。
