-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm1.vb
More file actions
76 lines (66 loc) · 4.13 KB
/
Form1.vb
File metadata and controls
76 lines (66 loc) · 4.13 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Imports System
Imports System.Windows.Forms
Imports DevExpress.Spreadsheet
Imports System.Diagnostics
Namespace ConditionalFormatting_Example
Public Partial Class Form1
Inherits Form
Private workbook As Workbook = New Workbook()
Public Sub New()
InitializeComponent()
InitTreeListControl()
End Sub
Private Sub InitTreeListControl()
Dim examples As GroupsOfSpreadsheetExamples = New GroupsOfSpreadsheetExamples()
InitData(examples)
DataBinding(examples)
End Sub
Private Sub InitData(ByVal examples As GroupsOfSpreadsheetExamples)
#Region "GroupNodes"
examples.Add(New SpreadsheetNode("Conditional Formatting"))
#End Region
#Region "ExampleNodes"
' Add nodes to the "Conditional Formatting" group of examples.
examples(0).Groups.Add(New SpreadsheetExample("Format values that are above or below average", ConditionalFormatting.AddAverageConditionalFormattingAction))
examples(0).Groups.Add(New SpreadsheetExample("Format cells that are not between two specified values", ConditionalFormatting.AddRangeConditionalFormattingAction))
examples(0).Groups.Add(New SpreadsheetExample("Format top ranked values", ConditionalFormatting.AddRankConditionalFormattingAction))
examples(0).Groups.Add(New SpreadsheetExample("Format cells that contain the specific text string", ConditionalFormatting.AddTextConditionalFormattingAction))
examples(0).Groups.Add(New SpreadsheetExample("Format only unique values", ConditionalFormatting.AddSpecialConditionalFormattingAction))
examples(0).Groups.Add(New SpreadsheetExample("Format today's date", ConditionalFormatting.AddTimePeriodConditionalFormattingAction))
examples(0).Groups.Add(New SpreadsheetExample("Format values that are greater than a specified value", ConditionalFormatting.AddExpressionConditionalFormattingAction))
examples(0).Groups.Add(New SpreadsheetExample("Use a formula to determine which cells to format", ConditionalFormatting.AddFormulaExpressionConditionalFormattingAction))
examples(0).Groups.Add(New SpreadsheetExample("Format cells by using a two-color scale", ConditionalFormatting.AddColorScale2ConditionalFormattingAction))
examples(0).Groups.Add(New SpreadsheetExample("Format cells by using a three-color scale", ConditionalFormatting.AddColorScale3ConditionalFormattingAction))
examples(0).Groups.Add(New SpreadsheetExample("Format cells by using data bars", ConditionalFormatting.AddDataBarConditionalFormattingAction))
examples(0).Groups.Add(New SpreadsheetExample("Format cells by using a custom icon set", ConditionalFormatting.AddIconSetConditionalFormattingAction))
#End Region
End Sub
Private Sub DataBinding(ByVal examples As GroupsOfSpreadsheetExamples)
treeList1.DataSource = examples
treeList1.ExpandAll()
treeList1.BestFitColumns()
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
LoadDocumentFromFile()
Dim example As SpreadsheetExample = TryCast(treeList1.GetDataRecordByNode(treeList1.FocusedNode), SpreadsheetExample)
If example Is Nothing Then Return
Dim action As Action(Of IWorkbook) = example.Action
action(workbook)
SaveDocumentToFile()
End Sub
' ------------------- Load and Save a Document -------------------
Private Sub LoadDocumentFromFile()
#Region "#LoadDocumentFromFile"
' Load a workbook from a file.
workbook.LoadDocument("..\..\..\Documents\Document.xlsx", DocumentFormat.OpenXml)
#End Region
End Sub
Private Sub SaveDocumentToFile()
#Region "#SaveDocumentToFile"
' Save the modified document to a file.
workbook.SaveDocument("..\..\..\Documents\SavedDocument.xlsx", DocumentFormat.OpenXml)
#End Region
Call Process.Start(New ProcessStartInfo("..\..\..\Documents\SavedDocument.xlsx") With {.UseShellExecute = True})
End Sub
End Class
End Namespace