Skip to content

Three color scale example

Mats Alm edited this page May 20, 2022 · 5 revisions

Here is another example where we add a ThreeColorScale rule. Let's start with how the result will look like:

Here is how this rule will look like when edited in Excel:

And here is the code to achieve it with EPPlus:

// Add TwoColorScale conditional formatting to visualize temperatures
// ColorTranslator is a utility from System.Drawing.Primitives.
var cfRule = sheet.ConditionalFormatting.AddThreeColorScale(sheet.Cells["B2:G11"]);
cfRule.LowValue.Color = ColorTranslator.FromHtml("#FF63BE7B");
cfRule.MiddleValue.Color = ColorTranslator.FromHtml("#FFFFEB84");
cfRule.MiddleValue.Type = eExcelConditionalFormattingValueObjectType.Percentile;
cfRule.MiddleValue.Value = 50;
cfRule.HighValue.Color = ColorTranslator.FromHtml("#FFF8696B");

Back to Conditional Formatting

EPPlus wiki

Versions

Worksheet & Ranges

Styling

Import/Export data

Formulas and filters

Charts & Drawing objects

Tables & Pivot Tables

VBA & Protection

Clone this wiki locally