0
votes

When accessing a cell's style programmatically, as in

ws.Cell(4, 10).Style.Fill.BackgroundColor

the default style is returned. In this case, the cell has conditional formatting applied and contains a value such that the format is applied (gray fill). In an automated test, we would like to READ this applied format to verify it is as expected. Can this be done?

1

1 Answers

0
votes

I found the list of conditional formats stored at the worksheet level.

var ws = workbook.Worksheet("[your sheet]");
var condformatlist = ws.RangeAddress.Worksheet.ConditionalFormats ;

If you know the range the format is applied to, you can find it in the list with linq.

var theconditionalformat = 
    ws.RangeAddress.Worksheet.ConditionalFormatsWhere(
        x => x.Range == ws.Range("COPYRANGE")
    );