Reputation: 2045
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.
Upvotes: 0
Views: 4116
Reputation: 633
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!
Upvotes: 3
Reputation: 237
I recommend you use the component Epplus, it is quite complete and need not be installed on production server.
http://epplus.codeplex.com/releases/view/42439
Upvotes: 3