在Excel中使用C#中的条件格式更改单元格颜色 [英] Cell color change In Excel Using Conditional formatting in C#

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

问题描述

我已成功将数据表导出到Excel.现在,我必须使用C#在Excel工作表中使用条件格式更改某些单元格颜色.例如,如果一个单元格包含"Cat"文本,则应以绿色显示,如果一个单元格包含"Dog"文本,则应以蓝色显示.现在我该怎么办?

I have exported datatable to Excel successfully. Now I have to change some cell color using Conditional formatting in Excel sheet using C#. For example if a cell contains text as "Cat" it should be display in Green color and if a cell contains text as "Dog" it should display in blue Color. Now how can I do this?

推荐答案

单击该单元格,然后从菜单中选择条件格式".然后选择等于单元格的规则"之类的内容.填写"Cat"(等于),然后选择格式.

Click the cell and select "Conditional formatting" from the menu. Then select something like "rules for cells that equals". Fill in "Cat" as what is should be equal to and choose your formatting.

检查以下内容: http://www.contextures.com/xlcondformat03.html

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

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