I am using vb.net and I have an asp.net application where I use ExcelPackage. I wanted to know how to set the background color of a particular cell or a row of cells.
Asked
Active
Viewed 3,960 times
2 Answers
3
I know this question is old but here is the answer:
ExcelPackage pck = new ExcelPackage();
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Example");
string index= "A1";
ws.Cells[index].Style.Fill.PatternType = ExcelFillStyle.Solid;
ws.Cells[index].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Orange);
Please note that you must set the PatternType before you can set a background color or an exception is thrown.
Sorry but my example is c#, you will need to convert to VB.Net to be 100% correct for the question!

Ravendarksky
- 573
- 5
- 13
-
1It seems you can also use a range: `ws.Cells["A1:B7"]`. Also see http://stackoverflow.com/questions/17156118/how-to-set-color-or-background-with-excelpackage#17157666. – SharpC Jan 25 '16 at 18:18
3
I recommend you use the component Epplus, it is quite complete and need not be installed on production server.

Vicente Jr
- 237
- 1
- 3