-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSeriesActions.vb
More file actions
102 lines (81 loc) · 4.2 KB
/
SeriesActions.vb
File metadata and controls
102 lines (81 loc) · 4.2 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
Imports DevExpress.Spreadsheet
Imports DevExpress.Spreadsheet.Charts
Namespace SpreadsheetChartAPISamples
Public NotInheritable Class SeriesActions
Private Sub New()
End Sub
Public Shared RemoveSeriesAction As Action(Of Workbook) = AddressOf RemoveSeries
Public Shared ChangeSeriesOrderAction As Action(Of Workbook) = AddressOf ChangeSeriesOrder
Public Shared UseSecondaryAxesAction As Action(Of Workbook) = AddressOf UseSecondaryAxes
Public Shared ChangeSeriesTypeAction As Action(Of Workbook) = AddressOf ChangeSeriesType
Public Shared ChangeSeriesArgumentsAction As Action(Of Workbook) = AddressOf ChangeSeriesArguments
Private Shared Sub RemoveSeries(ByVal workbook As Workbook)
#Region "#RemoveSeries"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask3")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B2:E6"))
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")
' Remove the series.
chart.Series.RemoveAt(1)
#End Region ' #RemoveSeries
End Sub
Private Shared Sub ChangeSeriesOrder(ByVal workbook As Workbook)
#Region "#ChangeSeriesOrder"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask3")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B2:D6"))
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")
' Change the series order.
chart.Series(1).BringForward()
#End Region ' #ChangeSeriesOrder
End Sub
Private Shared Sub UseSecondaryAxes(ByVal workbook As Workbook)
#Region "#UseSecondaryAxes"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.LineMarker, worksheet("B2:D8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")
' Use the secondary axis.
chart.Series(1).AxisGroup = AxisGroup.Secondary
' Specify the position of the legend.
chart.Legend.Position = LegendPosition.Top
#End Region ' #UseSecondaryAxes
End Sub
Private Shared Sub ChangeSeriesType(ByVal workbook As Workbook)
#Region "#ChangeSeriesType"
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.LineMarker, worksheet("B2:D8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")
' Change the type of the second series.
chart.Series(1).ChangeType(ChartType.ColumnClustered)
' Use the secondary axis.
chart.Series(1).AxisGroup = AxisGroup.Secondary
' Specify the position of the legend.
chart.Legend.Position = LegendPosition.Top
#End Region ' #ChangeSeriesType
End Sub
Private Shared Sub ChangeSeriesArguments(ByVal workbook As Workbook)
#Region "#ChangeSeriesArgumentsAndValues"
Dim worksheet As Worksheet = workbook.Worksheets("Sheet1")
workbook.Worksheets.ActiveWorksheet = worksheet
workbook.BeginUpdate()
' Create a chart.
Dim chart As Chart = worksheet.Charts.Add(ChartType.LineMarker, worksheet(0, 0))
' Specify arguments.
chart.Series(0).Arguments = New CellValue() {1, 2, 3}
' Specify values.
chart.Series(0).Values = New CellValue() {30, 20, 10}
workbook.EndUpdate()
#End Region ' #ChangeSeriesArgumentsAndValues
End Sub
End Class
End Namespace