本文介绍了如何使用C#更改excel单元格的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!

我的英语不是很好,所以试着理解我



我想用c#自动化一个过程,但是有一个很多信息,我需要改变一些细胞的颜色,但我不知道名字在哪里,







请帮帮我



谢谢



我试过的:



i allready使用System.Drawing但我不知道如何使用它,我尝试用if,但我避风港没有成功。

Hello!
My english isn't very well, so try to understand me

I want to automate a process with c#, but there is a lot of information, i need to change the color of some cells, but i don't know where is the name,



Please help me

Thanks

What I have tried:

i allready use the System.Drawing but i don't know how i can use it, i try to do with a if, but i haven't success.

推荐答案

Range range = MySheet.get_Range("B3");
string someValue = "ValueToFlag";
if (range.Value.ToString() == someValue) {
  range.Interior.Color = Color.Red;
  range.Font.Color = Color.Yellow;
}
else {
  range.Interior.Color = Color.White;
  range.Font.Color = Color.Black;
}
Console.ReadKey();




这篇关于如何使用C#更改excel单元格的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 22:32
查看更多