Search code examples
c#excelgembox-spreadsheet

Gembox, colorify Excel row


As stated in the title i would like to use Gembox to colorify an entire row in a Excell document with a color selected at runtime.

I have tried the following code :

      ef.LoadXls("path"), XlsOptions.PreserveAll);
      ef.Worksheets[0].Rows[myRowIndex].Style.FillPattern.SetPattern ( FillPatternStyle.None , Color.Black , selectedColor );

but seem not work (i have no exception but row remain white), any suggestion to do what i need ?


Solution

  • Instead of FillPatternStyle.None use FillPatternStyle.Solid, try the following:

    // When solid is specified, the PatternForegroundColor is the only color that's rendered.
    ef.Worksheets[0].Rows[myRowIndex].Style
        .FillPattern
        .SetPattern(FillPatternStyle.Solid, selectedColor, Color.Empty);