如何使用 C# 用颜色填充 I 单元格 A1:A5? [英] How can fill I cells A1:A5 with a color using C#?

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

问题描述

我有以下代码:

Excel.Range chartRange;
chartRange = xlWorkSheet.get_Range("A3", "R3");

我想用一种颜色填充这个单元格范围.我已经尝试过:

I want to fill this range of cells with a color. I have already tried with:

System.Drawing.Color = "yellow"

但是它抛出了一个需要对象引用的异常.

but it is throwing an exception that an object reference is required.

如何修复我的代码以用颜色填充这些单元格?

How can I fix my code to fill these cells with a color?

推荐答案

试试这个:

chartRange.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Yellow);

这篇关于如何使用 C# 用颜色填充 I 单元格 A1:A5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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