-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTitlesActions.vb
More file actions
143 lines (114 loc) · 6.11 KB
/
TitlesActions.vb
File metadata and controls
143 lines (114 loc) · 6.11 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
Imports DevExpress.Spreadsheet
Imports DevExpress.Spreadsheet.Charts
Namespace SpreadsheetChartAPISamples
Public NotInheritable Class TitlesActions
Private Sub New()
End Sub
Public Shared ShowChartTitleAction As Action(Of Workbook) = AddressOf ShowChartTitle
Public Shared SetChartTitleTextAction As Action(Of Workbook) = AddressOf SetChartTitleText
Public Shared LinkChartTitleToCellRangeAction As Action(Of Workbook) = AddressOf LinkChartTitleToCellRange
Public Shared ShowAxisTitleAction As Action(Of Workbook) = AddressOf ShowAxisTitle
Public Shared SetAxisTitleTextAction As Action(Of Workbook) = AddressOf SetAxisTitleText
Public Shared LinkAxisTitleToCellRangeAction As Action(Of Workbook) = AddressOf LinkAxisTitleToCellRange
Private Shared Sub ShowChartTitle(ByVal workbook As Workbook)
#Region "#ShowChartTitle"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask2")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.BarClustered, worksheet("B4:C7"))
chart.TopLeftCell = worksheet.Cells("E3")
chart.BottomRightCell = worksheet.Cells("K14")
' Display default chart title.
chart.Title.Visible = True
' Display the chart legend.
chart.Legend.Visible = False
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True
#End Region ' #ShowChartTitle
End Sub
Private Shared Sub SetChartTitleText(ByVal workbook As Workbook)
#Region "#SetChartTitleText"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask2")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.BarClustered, worksheet("B4:C7"))
chart.TopLeftCell = worksheet.Cells("E3")
chart.BottomRightCell = worksheet.Cells("K14")
' Display the chart title and specify the title text.
chart.Title.Visible = True
chart.Title.SetValue("Market share Q3'13")
' Hide the chart legend.
chart.Legend.Visible = False
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True
#End Region ' #SetChartTitleText
End Sub
Private Shared Sub LinkChartTitleToCellRange(ByVal workbook As Workbook)
#Region "#LinkChartTitleToCellRange"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask2")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.BarClustered, worksheet("B4:C7"))
chart.TopLeftCell = worksheet.Cells("E3")
chart.BottomRightCell = worksheet.Cells("K14")
' Display the chart title and set the source cell for the title text.
chart.Title.Visible = True
chart.Title.SetReference(worksheet("B1"))
' Hide the legend.
chart.Legend.Visible = False
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True
#End Region ' #LinkChartTitleToCellRange
End Sub
Private Shared Sub ShowAxisTitle(ByVal workbook As Workbook)
#Region "#ShowAxisTitle"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask2")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.BarClustered, worksheet("B4:C7"))
chart.TopLeftCell = worksheet.Cells("E3")
chart.BottomRightCell = worksheet.Cells("K14")
' Show the axis title.
chart.PrimaryAxes(1).Title.Visible = True
' Hide the legend.
chart.Legend.Visible = False
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True
#End Region ' #ShowAxisTitle
End Sub
Private Shared Sub SetAxisTitleText(ByVal workbook As Workbook)
#Region "#SetAxisTitleText"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask2")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.BarClustered, worksheet("B4:C7"))
chart.TopLeftCell = worksheet.Cells("E3")
chart.BottomRightCell = worksheet.Cells("K14")
' Specify the axis title text.
chart.PrimaryAxes(1).Title.Visible = True
chart.PrimaryAxes(1).Title.SetValue("Shipment in millions of units")
' Hide the legend.
chart.Legend.Visible = False
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True
#End Region ' #SetAxisTitleText
End Sub
Private Shared Sub LinkAxisTitleToCellRange(ByVal workbook As Workbook)
#Region "#LinkAxisTitleToCellRange"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask2")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.BarClustered, worksheet("B4:C7"))
chart.TopLeftCell = worksheet.Cells("E3")
chart.BottomRightCell = worksheet.Cells("K14")
' Bind the axis title text to a worksheet cell.
chart.PrimaryAxes(1).Title.Visible = True
chart.PrimaryAxes(1).Title.SetReference(worksheet("C3"))
' Hide the legend.
chart.Legend.Visible = False
' Specify that each data point in the series has a different color.
chart.Views(0).VaryColors = True
#End Region ' #LinkAxisTitleToCellRange
End Sub
End Class
End Namespace