-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLegendActions.vb
More file actions
63 lines (48 loc) · 2.46 KB
/
LegendActions.vb
File metadata and controls
63 lines (48 loc) · 2.46 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
Imports DevExpress.Spreadsheet
Imports DevExpress.Spreadsheet.Charts
Namespace SpreadsheetChartAPISamples
Public NotInheritable Class LegendActions
Private Sub New()
End Sub
Public Shared HideLegendAction As Action(Of Workbook) = AddressOf HideLegend
Public Shared SetLegendPositionAction As Action(Of Workbook) = AddressOf SetLegendPosition
Public Shared ExcludeLegendEntryAction As Action(Of Workbook) = AddressOf ExcludeLegendEntry
Private Shared Sub HideLegend(ByVal workbook As Workbook)
#Region "#HideLegend"
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:F6"))
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")
' Hide the legend.
chart.Legend.Visible = False
#End Region ' #HideLegend
End Sub
Private Shared Sub SetLegendPosition(ByVal workbook As Workbook)
#Region "#SetLegendPosition"
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:F6"))
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")
' Specify the position of the legend.
chart.Legend.Position = LegendPosition.Bottom
#End Region ' #SetLegendPosition
End Sub
Private Shared Sub ExcludeLegendEntry(ByVal workbook As Workbook)
#Region "#ExcludeLegendEntry"
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:F6"))
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")
' Exclude entries from the legend.
chart.Legend.CustomEntries.Add(2).Hidden = True
chart.Legend.CustomEntries.Add(3).Hidden = True
#End Region ' #ExcludeLegendEntry
End Sub
End Class
End Namespace