Skip to content

Commit 98861ce

Browse files
committed
Conditional Formatting
1 parent ee17705 commit 98861ce

File tree

1 file changed

+12
-0
lines changed
  • Conditional Formatting/Create Conditional Format/.NET/Create Conditional Format/Create Conditional Format

1 file changed

+12
-0
lines changed

Conditional Formatting/Create Conditional Format/.NET/Create Conditional Format/Create Conditional Format/Program.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ static void Main(string[] args)
5757
//Setting back color to target range
5858
condition3.BackColor = ExcelKnownColors.Light_green;
5959

60+
//Applying conditional formatting to "A7"
61+
condition = worksheet.Range["A7"].ConditionalFormats;
62+
IConditionalFormat condition4 = condition.AddCondition();
63+
64+
//Set conditional format rule that the cell value is a date in the next week
65+
condition4.FormatType = ExcelCFType.TimePeriod;
66+
condition4.TimePeriodType = CFTimePeriods.NextWeek;
67+
worksheet.Range["A7"].Text = "Enter a date of next week";
68+
69+
//Setting back color to target range
70+
condition4.BackColor = ExcelKnownColors.Light_blue;
71+
6072
#region Save
6173
//Saving the workbook
6274
FileStream outputStream = new FileStream(Path.GetFullPath("Output/ConditionalFormat.xlsx"), FileMode.Create, FileAccess.Write);

0 commit comments

Comments
 (0)