更改单元格的用C#背景 [英] Change the background of Cells with C#

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

问题描述

我正在开发使用C#来操作Excel文档的程序,我使用

I'm developing an program using C# to manipulate an Excel document, and I'm using

    Microsoft.Office.Interop.Excel._Worksheet worksheet;

当我插入的东西砍掉,Y电池使用:

When I insert something to a x,y cell I use :

worksheet.Cells[x, y] = "something";

现在我想知道是否有可能修改背景色从C#中的细胞[X,Y]的。

Now I want to know if it's possible to change the backColor of the Cells[x,y] from C#.

感谢您。

推荐答案

尝试

worksheet.Cells[x, y].Interior.Color

您将无法使用。在净色直接,他们将需要一个翻译

You won't be able to use the Colors in .Net directly, they will require a translation.

建议使用以下(从银明显改变):

It is recommended to use the following (obviously change from silver) :

worksheet.Cells[x, y].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Silver);

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

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