How to gete colot of the shape?

Hello,I am generating a small vertical line attached to the cell like this:

    private static void DrawVerticalLine(ExcelCell cell, HorizontalAlignment alignment, DrawingColor color)
    {
        var wks = cell.Worksheet;
        var column = alignment == HorizontalAlignment.Left ? cell.Column : wks.Columns[cell.Column.Index + 1];
        var columnOffset = 0.55 * (alignment == HorizontalAlignment.Left ? 1 : -1);

        var anchorFrom = new AnchorCell(column, cell.Row, columnOffset, 0, LengthUnit.Millimeter);
        var anchorTo = new AnchorCell(column, wks.Rows[cell.Row.Index + 1], columnOffset, 0, LengthUnit.Millimeter);
        var shape = wks.Shapes.Add(ShapeType.Line, anchorFrom, anchorTo);

        shape.Outline.Width = Length.From(1, LengthUnit.Millimeter);
        shape.Outline.Fill.SetSolid(color);
    }

And I would like to check the generated color in my unit test.

I can find a shape, something like this:

cell = sheet.Cells[row, 2];
        
shape = sheet.Shapes.First(x => x.Position.From.Row == cell.Row &&   x.Position.From.Column.Index == 3);  //column 3 because it is attached to next column
shape.Outline.Fill.FillType.Should().Be(FillFormatType.Solid);  //how to check color of it?

and I cannot find a property for color.

Am I overlooking something?

Thanks a lot for help

Ota

Hi Ota,

You need to cast the FillFormat to SolidFillFormat, like this:

var solidFillFormat = shape.Outline.Fill as SolidFillFormat;
var solidColor = solidFillFormat.Color;

Does this solve your issue?

Regards,
Mario

Hi Mario,

That is exactly it.

Thanks a lot

Ota