Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
Cell Background Color
posted

I'm creating an Excel workbook from scratch in a web application. I'm using the Workbook and Worksheet classes. My goal is to make every other row with an alternating background color so that the spreadsheet can be read.

I've tried using the following code:

...

Worksheet pipelineWorksheet = workbook.Worksheets[0];
 if (rowIndex % 2 == 0)
{
    pipelineWorksheet.GetCell("A" + rowIndex).CellFormat.FillPatternBackgroundColor = System.Drawing.Color.Cornsilk;

This gives me alternating rows, but all of the background colors are black! I want to accomplish the same effect as if I opened Excel, selected a cell, and used the fill command on the background color. How should I be doing this?

Parents Reply Children
No Data