如何使用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);