着色细胞的excel片 [英] coloring cells of excel sheet

查看:159
本文介绍了着色细胞的excel片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在c#中对excel表格的某些特定单元格进行着色。但我没有得到它。
我使用的代码为:

I want to color some particular cells of excel sheet in c#. but I am not getting it.. I am using the code as:

  dsNew.Tables[0].Columns[j].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.DeepPink);

但是这不是wrking ..
这是怎么做的
请执行某些操作。
它给出一个错误无法解析symbol'interior

but this is not wrking.. how this can be done.. please do something.. it is giving an error "cannot resolve symbol'interior'"

推荐答案

Range.Interior 属性:

Range data_cell = work_sheet.Cells[row, column];
data_cell.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.DeepPink);

其中 work_sheet 是Excel.Worksheet希望改变细胞。 row 或要更改的单元格的索引。

where work_sheet is the Excel.Worksheet you wish to change the cells of. row and column or the indices of the cells to change.

您的示例可能返回列索引器的对象。尝试这样:

Your example may be returning an object for the column indexer. Try this:

((Range)dsNew.Tables[0].Columns[j]).Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.DeepPink);

这篇关于着色细胞的excel片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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