-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTitlesActions.cs
More file actions
150 lines (121 loc) · 6.01 KB
/
TitlesActions.cs
File metadata and controls
150 lines (121 loc) · 6.01 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
144
145
146
147
148
149
150
using DevExpress.Spreadsheet;
using DevExpress.Spreadsheet.Charts;
using System;
namespace SpreadsheetChartAPIActions
{
public static class TitlesActions
{
public static Action<Workbook> ShowChartTitleAction = ShowChartTitle;
public static Action<Workbook> SetChartTitleTextAction = SetChartTitleText;
public static Action<Workbook> LinkChartTitleToCellRangeAction = LinkChartTitleToCellRange;
public static Action<Workbook> ShowAxisTitleAction = ShowAxisTitle;
public static Action<Workbook> SetAxisTitleTextAction = SetAxisTitleText;
public static Action<Workbook> LinkAxisTitleToCellRangeAction = LinkAxisTitleToCellRange;
static void ShowChartTitle(Workbook workbook)
{
#region #ShowChartTitle
Worksheet worksheet = workbook.Worksheets["chartTask2"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Create a chart and specify its location.
Chart 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;
#endregion #ShowChartTitle
}
static void SetChartTitleText(Workbook workbook)
{
#region #SetChartTitleText
Worksheet worksheet = workbook.Worksheets["chartTask2"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Create a chart and specify its location.
Chart 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;
#endregion #SetChartTitleText
}
static void LinkChartTitleToCellRange(Workbook workbook)
{
#region #LinkChartTitleToCellRange
Worksheet worksheet = workbook.Worksheets["chartTask2"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Create a chart and specify its location.
Chart 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;
#endregion #LinkChartTitleToCellRange
}
static void ShowAxisTitle(Workbook workbook)
{
#region #ShowAxisTitle
Worksheet worksheet = workbook.Worksheets["chartTask2"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Create a chart and specify its location.
Chart 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;
#endregion #ShowAxisTitle
}
static void SetAxisTitleText(Workbook workbook)
{
#region #SetAxisTitleText
Worksheet worksheet = workbook.Worksheets["chartTask2"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Create a chart and specify its location.
Chart 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;
#endregion #SetAxisTitleText
}
static void LinkAxisTitleToCellRange(Workbook workbook)
{
#region #LinkAxisTitleToCellRange
Worksheet worksheet = workbook.Worksheets["chartTask2"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Create a chart and specify its location.
Chart 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;
#endregion #LinkAxisTitleToCellRange
}
}
}