Search code examples
c#excelepplus

Font color returns Color.Empty instead of Color.White using Epplus


enter image description here

This is my test setup, as can be seen the font color is white with some characters in red. When I read it with C# Epplus, I get resulting color as Color.Empty. Code as under:

    ExcelWorksheet ws = ep.Workbook.Worksheets[1];

    int colCount = ws.Dimension.End.Column;  //get Column Count
    int rowCount = ws.Dimension.End.Row;     //get row coun

    // per line
    for (int row = 2; row <= rowCount; row++) {
        for (int col = 1; col <= colCount; col++) {
            ExcelRange cell = ws.Cells[row, col];

            // get rich text section info
            for (int r = 0; r < cell.RichText.Count; r++) {
                ExcelRichText richText = cell.RichText[r];

                Color rColor = richText.Color; // This shows Color.Empty

            }   
        }
    }

Solution

  • On further checks it was found that the issue is with Theme Color. Excel has 2 sets of colors in its picker, Theme and Standard, if we only work with Standard colors EPPlus doesn't have a problem and correctly detects it.