EasyXLS

Conditional formatting

EasyXLS™ library provides the methods to read or set conditional formatting to a cell or range of cells, including rows or columns, for an Excel file. If a specified condition is met then the defined format is applied to the cell.

The conditional formatting can have one or more condition set, and for each condition a special format is applied.

The supported formatted options are:
- Cell font settings: foreground, bold ant italic options, underline style, strikethrough
- Cell border: border line style and color
- Cell fill settings: background color

Source code sample

The below example shows how to export an Excel file and set conditional formatting to a range. The first step is to set the range where the conditional formatting will be applied, then set the formatting options.

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

The screen shot below represents the exported Excel file with conditional formatting applied to two ranges:
     - A1:C3 - the cells data will turn red if the value of the operator is between 9 and 11
     - A6:C6 - the background color of the range will turn bisque if the condition is met.


Exported Excel file with conditional formatting

 

Available for: Professional, Excel Writer, Excel Reader
Go to top

EasyXLS Excel libraries:

.NET
.NET Excel Library
full .NET version to import, export or convert Excel files
COM+ Excel Library
full COM+ version to import, export or convert Excel files
-
Java
Java Excel Library
full Java version to import, export or convert Excel files
Download EasyXLS™ Excel Library for .NET and Java

File formats:

Office 365
MS Excel 2021 - 2024
MS Excel 2007 - 2019
MS Excel 97 - 2003
XLSXXLSMXLSBXLS
XMLHTMLCSVTXT