/
TitlesActions.cs
138 lines (111 loc) · 5.57 KB
/
TitlesActions.cs
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
using System;
using System.Drawing;
using System.Globalization;
using DevExpress.Spreadsheet;
using DevExpress.Spreadsheet.Charts;
using DevExpress.Spreadsheet.Drawings;
using DevExpress.Utils;
namespace SpreadsheetChartAPIActions {
public static class TitlesActions {
static void ShowChartTitle(IWorkbook 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(IWorkbook 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(IWorkbook 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(IWorkbook 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(IWorkbook 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(IWorkbook 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
}
}
}