This project has moved and is read-only. For the latest updates, please go here.

Background Color

Mar 7, 2011 at 10:07 PM

How do I set the background color of a cell?

I thought this would work, but the compiler is telling me the field is read only and cannot be assigned.

myWs.Cells[1, 1].Style.Fill.BackgroundColor.Rgb =

"FFFF00" ;

Mar 10, 2011 at 7:31 AM

Download the sample project, you have several examples how to do it there.

Jul 4, 2014 at 2:37 AM
Edited Jul 4, 2014 at 2:37 AM
myWs.Cells[1, 1].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
myWs.Cells[1, 1].Style.Fill.BackgroundColor.SetColor(Color.LightGray);