Gembox,为 Excel 行着色

Gembox, colorify Excel row

如标题所述,我想使用 Gembox 为 Excell 文档中的整行着色,并在运行时选择颜色。

我试过以下代码:

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

但似乎不起作用(我也不例外,但行仍然是白色),有什么建议可以做我需要的吗?

而不是 FillPatternStyle.None 使用 FillPatternStyle.Solid,尝试以下操作:

// 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);