-
Notifications
You must be signed in to change notification settings - Fork 295
Conditional Formatting ‐ Colors
OssianEPPlus edited this page Sep 15, 2023
·
11 revisions
As of Epplus 7.0 several of the ConditionalFormattings have built in support for themeColors
for example here's how to theme color a AboveAverageRule:
using (var pck = new ExcelPackage())
{
var sheet = pck.Workbook.Worksheets.Add("NewWorksheet");
var cf = sheet.ConditionalFormatting.AddAboveAverage("A1:B5");
cf.Style.Fill.BackgroundColor.Theme = eThemeSchemeColor.Accent4;
}
A databar:
var cfDatabar = sheet.ConditionalFormatting.AddDatabar("A1:B5", Color.Red);
cfDatabar.FillColor.Theme = eThemeSchemeColor.Accent1;
A ThreeColorScale:
var threeColor = sheet.ConditionalFormatting.AddThreeColorScale("A1:B5");
threeColor.LowValue.ColorSettings.Theme = eThemeSchemeColor.Background1;
threeColor.MiddleValue.ColorSettings.Theme = eThemeSchemeColor.Accent2;
threeColor.HighValue.ColorSettings.Theme = eThemeSchemeColor.Accent3;
Note that there are some differences in how to set the colors due to ensuring backwards compatability. And because Databar has multiple options on one whole whereas colorScale has different needs as these two are more complex and diverse types
EPPlus Software AB - https://epplussoftware.com
- What is new in EPPlus 5+
- Breaking Changes in EPPlus 5
- Breaking Changes in EPPlus 6
- Breaking Changes in EPPlus 7
- Breaking Changes in EPPlus 8
- Addressing a worksheet
- Dimension/Used range
- Copying ranges/sheets
- Insert/Delete
- Filling ranges
- Sorting ranges
- Taking and skipping columns/rows
- Data validation
- Comments
- Freeze and Split Panes
- Header and Footer
- Hyperlinks
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- The ExcelRange.Text property
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles