-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGroupAndOutlineActions.cs
91 lines (76 loc) · 3.18 KB
/
GroupAndOutlineActions.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
using DevExpress.Spreadsheet;
using System.Collections.Generic;
namespace SpreadsheetDocServerAPIPart2
{
public static class GroupAndOutlineActions
{
static void GroupRows(Workbook workbook)
{
#region #GroupRows
Worksheet worksheet = workbook.Worksheets["Grouping"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Group rows 3 through 6 and collapse the group.
worksheet.Rows.Group(2, 5, true);
// Group rows 9 through 12 and expand the group.
worksheet.Rows.Group(8, 11, false);
// Group rows 2 through 13 to create the outer group.
worksheet.Rows.Group(1, 12, false);
#endregion #GroupRows
}
static void GroupColumns(Workbook workbook)
{
#region #GroupColumns
Worksheet worksheet = workbook.Worksheets["Grouping"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Group columns "C" through "F" and expand the group.
worksheet.Columns.Group(2, 5, false);
#endregion #GroupColumns
}
static void UngroupRows(Workbook workbook)
{
#region #UngroupRows
Worksheet worksheet = workbook.Worksheets["Grouping and Outline"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Ungroup rows 3 through 6 and display collapsed data.
worksheet.Rows.UnGroup(2, 5, true);
// Ungroup rows 9 through 12.
worksheet.Rows.UnGroup(8, 11, false);
// Remove the outer row group.
worksheet.Rows.UnGroup(1, 12, false);
#endregion #UngroupRows
}
static void UngroupColumns(Workbook workbook)
{
#region #UngroupColumns
Worksheet worksheet = workbook.Worksheets["Grouping and Outline"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Ungroup columns "C" through "F".
worksheet.Columns.UnGroup(2, 5, false);
#endregion #UngroupColumns
}
static void AutoOutline(Workbook workbook)
{
#region #AutoOutline
Worksheet worksheet = workbook.Worksheets["Grouping"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Outline data automatically based on the summary formulas.
worksheet.AutoOutline();
#endregion #AutoOutline
}
static void Subtotal(Workbook workbook)
{
#region #Subtotal
Worksheet worksheet = workbook.Worksheets["Regional Sales"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Obtain the target cell range.
CellRange dataRange = worksheet["B3:E23"];
// Calculate subtotals for column "D".
List<int> subtotalColumnsList = new List<int>();
subtotalColumnsList.Add(3);
// Insert subtotals by each change in column "B"
// and calculate the SUM fuction for the related rows in column "D".
worksheet.Subtotal(dataRange, 1, subtotalColumnsList, 9, "Total");
#endregion #Subtotal
}
}
}