简体   繁体   中英

Colorize Entire Row of Cells Having a Text/Value on a Column in Excel using EPPlus

I need to format entire row of cells having a value on a column using EPPlus.

For example, colorize rows having text of "yes" on its 'H' column.

In order to achieve this I used excel conditional formatting rules(EPPlus) but I could only format cells, not entire row. How can I accomplish this?

Given that worksheet is an ExcelWorksheet and rowNumber is... that:

var rangeAddress = $"{rowNumber}:{rowNumber}";
var expression = worksheet.ConditionalFormatting
    .AddExpression(new ExcelAddress(rangeAddress));
expression.Style.NumberFormat.Format = "0.00";

// not trying to be lazy here - you already have your formula.
expression.Formula = "IF(something)"; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM