使用C#的Excel中单元格的条件格式 [英] Conditional format of cells in Excel with c#

查看:298
本文介绍了使用C#的Excel中单元格的条件格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Visual Studio(c#)创建了一个excel模板,以在工作表中填充一些数据.
在此工作表上,我想添加一些条件格式的单元格.我希望模板的用户填写是"或否",并根据单元格的值使单元格为绿色/红色.知道怎么做吗?

我在网上找到了很多有关条件格式的信息,但是我不知道该怎么做. :confused:

I have created a excel template with Visual Studio (c#) to fill the worksheet with some data.
On this worksheet I want to add some conditional formatting of the cells. I want the user of the template to fill in a "Yes" or a "No" and make the cell green / red depending on the value of the cell. Any idea how to do this?

I found a lot on the net about conditional formatting, but I can''t figure out how to do this. :confused:

推荐答案

本文为以编程方式设置条件格式提供了一个很好的示例:

在Excel 2007中设置条件格式 [
DD ...你知道那是如此明显以至于我从未发生过吗? :〜
This article goives a good exmple for conditional formatting programmatically:

Setting Conditional Formatting in Excel 2007[^]

DD Says...Rick, I use this quite a lot, but if I borrow your brain, I have not found out a way of doing it for dates.
That is, if a date is over 60 days, I would like that cell highlighted.
I can only do it by a macro, not CondForming, unless you know better?

Dave, You can use Today()-60 with a "less than" rule. Rick

DD...Do you know that was so obvious it never occurred to me? :~


这篇关于使用C#的Excel中单元格的条件格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆