-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRemovalAndCasting.vb
More file actions
51 lines (40 loc) · 2.41 KB
/
RemovalAndCasting.vb
File metadata and controls
51 lines (40 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Imports OfficeOpenXml
Imports OfficeOpenXml.ConditionalFormatting
Imports System.Drawing
Namespace EPPlusSamples.ConditionalFormatting
Friend Class RemovalAndCasting
Public Shared Sub Run(ByVal package As ExcelPackage)
Dim worksheet = package.Workbook.Worksheets.Add("RemovalAndCasting")
worksheet.Cells("A1:A5").Formula = "ROW()"
Dim signs = worksheet.ConditionalFormatting.AddThreeIconSet("A1:A5", eExcelconditionalFormatting3IconsSetType.Signs)
worksheet.ConditionalFormatting.AddDatabar("A1:A5", Color.Green)
' -----------------------------------------------------------
' Removing Conditional Formatting rules
' -----------------------------------------------------------
' Remove one Rule by its object
'worksheet.ConditionalFormatting.Remove(signs);
' Remove one Rule by index
'worksheet.ConditionalFormatting.RemoveAt(1);
' Remove one Rule by its Priority
'worksheet.ConditionalFormatting.RemoveByPriority(2);
' Remove all the Rules
'worksheet.ConditionalFormatting.RemoveAll();
' set some document properties
package.Workbook.Properties.Title = "Conditional Formatting"
package.Workbook.Properties.Author = "Eyal Seagull"
package.Workbook.Properties.Comments = "This sample demonstrates how to add Conditional Formatting to an Excel 2007 worksheet using EPPlus"
' set some custom property values
package.Workbook.Properties.SetCustomPropertyValue("Checked by", "Eyal Seagull")
package.Workbook.Properties.SetCustomPropertyValue("AssemblyName", "EPPlus")
'Getting a rule from the collection as a typed rule
If worksheet.ConditionalFormatting(0).Type = eExcelConditionalFormattingRuleType.ThreeIconSet Then
Dim iconRule = worksheet.ConditionalFormatting(0).As.ThreeIconSet 'Type cast the rule as an iconset rule.
'Do something with the iconRule...
End If
If worksheet.ConditionalFormatting(1).Type = eExcelConditionalFormattingRuleType.DataBar Then
Dim dataBarRule = worksheet.ConditionalFormatting(1).As.DataBar 'Type cast the rule as an iconset rule.
'Do something with the databarRule...
End If
End Sub
End Class
End Namespace