coloring cells of excel sheet
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.ToO开发者_JAVA百科le(System.Drawing.Color.DeepPink);
but this is not wrking.. how this can be done.. please do something.. it is giving an error "cannot resolve symbol'interior'"
Try the Range.Interior property:
Range data_cell = work_sheet.Cells[row, column];
data_cell.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.DeepPink);
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);
精彩评论