我原以为这很容易,但显然不是。我正在处理的报告中有一些消息来源飙升。这意味着我需要隐藏工作表的2 / 3rds并将隐藏的标签颜色设置为红色,以便清楚哪些正在使用中,哪些不是。到目前为止,我已经尝试过多种方式的Tab.Color和Tab.ColorIndex,但没有找到方法。
完整的ARGB:
System.Drawing.Color clr = System.Drawing.Color.FromArgb(255, 255, 0, 0);
int index = clr.ToArgb();
int hiddenTabColor = index;
...
worksheet.Tab.Color = hiddenTabColor;
添加System.ComponentModel以使用Converter:
var converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Color));
Color clr = (Color)converter.ConvertFromString("#FFFF0000");
...
worksheet.Tab.Color = clr;
我尝试了十几种这些不成功的排列。结果总是显示xlAutomatic为黑色的选项卡。我已经尝试了方法的每个重载。
重要信息是Visual Studio 2013使用Interop写入Microsoft Office Professional Plus 2013(Excel)。
答案 0 :(得分:1)
使用LINQPad,我可以毫不费力地使用它:
set