Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 19572e8

Browse files
Merge pull request #2 from AnnaVekhina/21.2.3+
Update example
2 parents f8396ef + 8b1d6c8 commit 19572e8

17 files changed

+297
-288
lines changed

‎CS/SpreadsheetDocServerAPIPart2/CodeExamples/AutoFilterActions.cs

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static void ApplyFilter(Workbook workbook)
1212
Worksheet worksheet = workbook.Worksheets["Regional sales"];
1313
workbook.Worksheets.ActiveWorksheet = worksheet;
1414

15-
// Enable filtering for the specified cell range.
15+
// Enable filtering for the "B2:E23" cell range.
1616
CellRange range = worksheet["B2:E23"];
1717
worksheet.AutoFilter.Apply(range);
1818
#endregion #ApplyFilter
@@ -24,11 +24,12 @@ static void FilterAndSortBySingleColumn(Workbook workbook)
2424
Worksheet worksheet = workbook.Worksheets["Regional sales"];
2525
workbook.Worksheets.ActiveWorksheet = worksheet;
2626

27-
// Enable filtering for the specified cell range.
27+
// Enable filtering for the "B2:E23" cell range.
2828
CellRange range = worksheet["B2:E23"];
2929
worksheet.AutoFilter.Apply(range);
3030

31-
// Sort the data in descending order by the first column.
31+
// Sort data in the "B2:E23" range
32+
// in descending order by column "A".
3233
worksheet.AutoFilter.SortState.Sort(0, true);
3334
#endregion #FilterAndSortBySingleColumn
3435
}
@@ -39,11 +40,12 @@ static void FilterAndSortByMultipleColumns(Workbook workbook)
3940
Worksheet worksheet = workbook.Worksheets["Regional sales"];
4041
workbook.Worksheets.ActiveWorksheet = worksheet;
4142

42-
// Enable filtering for the specified cell range.
43+
// Enable filtering for the "B2:E23" cell range.
4344
CellRange range = worksheet["B2:E23"];
4445
worksheet.AutoFilter.Apply(range);
4546

46-
// Sort the data in descending order by the first and third columns.
47+
// Sort data in the "B2:E23" range
48+
// in descending order by columns "A" and "C".
4749
List<SortCondition> sortConditions = new List<SortCondition>();
4850
sortConditions.Add(new SortCondition(0, true));
4951
sortConditions.Add(new SortCondition(2, true));
@@ -57,7 +59,7 @@ static void FilterNumericByCondition(Workbook workbook)
5759
Worksheet worksheet = workbook.Worksheets["Regional sales"];
5860
workbook.Worksheets.ActiveWorksheet = worksheet;
5961

60-
// Enable filtering for the specified cell range.
62+
// Enable filtering for the "B2:E23" cell range.
6163
CellRange range = worksheet["B2:E23"];
6264
worksheet.AutoFilter.Apply(range);
6365

@@ -73,7 +75,7 @@ static void FilterTextByCondition(Workbook workbook)
7375
Worksheet worksheet = workbook.Worksheets["Regional sales"];
7476
workbook.Worksheets.ActiveWorksheet = worksheet;
7577

76-
// Enable filtering for the specified cell range.
78+
// Enable filtering for the "B2:E23" cell range.
7779
CellRange range = worksheet["B2:E23"];
7880
worksheet.AutoFilter.Apply(range);
7981

@@ -89,11 +91,11 @@ static void FilterByValue(Workbook workbook)
8991
Worksheet worksheet = workbook.Worksheets["Regional sales"];
9092
workbook.Worksheets.ActiveWorksheet = worksheet;
9193

92-
// Enable filtering for the specified cell range.
94+
// Enable filtering for the "B2:E23" cell range.
9395
CellRange range = worksheet["B2:E23"];
9496
worksheet.AutoFilter.Apply(range);
9597

96-
// Filter the data in the "Product" column by a specific value.
98+
// Filter data in the "Product" column by a specific value.
9799
worksheet.AutoFilter.Columns[1].ApplyFilterCriteria("Mozzarella di Giovanni");
98100
#endregion #FilterBySingleValue
99101
}
@@ -104,11 +106,11 @@ static void FilterByMultipleValues(Workbook workbook)
104106
Worksheet worksheet = workbook.Worksheets["Regional sales"];
105107
workbook.Worksheets.ActiveWorksheet = worksheet;
106108

107-
// Enable filtering for the specified cell range.
109+
// Enable filtering for the "B2:E23" cell range.
108110
CellRange range = worksheet["B2:E23"];
109111
worksheet.AutoFilter.Apply(range);
110112

111-
// Filter the data in the "Product" column by an array of values.
113+
// Filter data in the "Product" column by an array of values.
112114
worksheet.AutoFilter.Columns[1].ApplyFilterCriteria(new CellValue[] { "Mozzarella di Giovanni", "Gorgonzola Telino" });
113115
#endregion #FilterByMultipleValues
114116
}
@@ -119,12 +121,15 @@ static void FilterDatesByCondition(Workbook workbook)
119121
Worksheet worksheet = workbook.Worksheets["Regional sales"];
120122
workbook.Worksheets.ActiveWorksheet = worksheet;
121123

122-
// Enable filtering for the specified cell range.
124+
// Enable filtering for the "B2:E23" cell range.
123125
CellRange range = worksheet["B2:E23"];
124126
worksheet.AutoFilter.Apply(range);
125127

126-
// Filter values in the "Reported Date" column to display dates that are between June 1, 2014 and February 1, 2015.
127-
worksheet.AutoFilter.Columns[3].ApplyCustomFilter(new DateTime(2014, 6, 1), FilterComparisonOperator.GreaterThanOrEqual, new DateTime(2015, 2, 1), FilterComparisonOperator.LessThanOrEqual, true);
128+
// Filter values in the "Reported Date" column
129+
// to display dates that are between June 1, 2014 and February 1, 2015.
130+
worksheet.AutoFilter.Columns[3].ApplyCustomFilter
131+
(new DateTime(2014, 6, 1), FilterComparisonOperator.GreaterThanOrEqual,
132+
new DateTime(2015, 2, 1), FilterComparisonOperator.LessThanOrEqual, true);
128133
#endregion #FilterDatesByCondition
129134
}
130135

@@ -134,7 +139,7 @@ static void FilterMixedDataTypesByValues(Workbook workbook)
134139
Worksheet worksheet = workbook.Worksheets["Regional sales"];
135140
workbook.Worksheets.ActiveWorksheet = worksheet;
136141

137-
// Enable filtering for the specified cell range.
142+
// Enable filtering for the "B2:E23" cell range.
138143
CellRange range = worksheet["B2:E23"];
139144
worksheet.AutoFilter.Apply(range);
140145

@@ -143,7 +148,8 @@ static void FilterMixedDataTypesByValues(Workbook workbook)
143148
DateGrouping dateGroupingJan2015 = new DateGrouping(new DateTime(2015, 1, 1), DateTimeGroupingType.Month);
144149
groupings.Add(dateGroupingJan2015);
145150

146-
// Filter the data in the "Reported Date" column to display values reported in January 2015.
151+
// Filter data in the "Reported Date" column
152+
// to display values reported in January 2015.
147153
worksheet.AutoFilter.Columns[3].ApplyFilterCriteria("gennaio 2015", groupings);
148154
#endregion #FilterMixedDataByValues
149155
}
@@ -154,7 +160,7 @@ static void Top10FilterValue(Workbook workbook)
154160
Worksheet worksheet = workbook.Worksheets["Regional sales"];
155161
workbook.Worksheets.ActiveWorksheet = worksheet;
156162

157-
// Enable filtering for the specified cell range.
163+
// Enable filtering for the "B2:E23" cell range.
158164
CellRange range = worksheet["B2:E23"];
159165
worksheet.AutoFilter.Apply(range);
160166

@@ -169,13 +175,15 @@ static void DynamicFilterValue(Workbook workbook)
169175
Worksheet worksheet = workbook.Worksheets["Regional sales"];
170176
workbook.Worksheets.ActiveWorksheet = worksheet;
171177

172-
// Enable filtering for the specified cell range.
178+
// Enable filtering for the "B2:E23" cell range.
173179
CellRange range = worksheet["B2:E23"];
174180
worksheet.AutoFilter.Apply(range);
175181

176-
// Apply a dynamic filter to the "Sales" column to display only values that are above the average.
182+
// Apply a dynamic filter to the "Sales" column
183+
// to display only values that are above the average.
177184
worksheet.AutoFilter.Columns[2].ApplyDynamicFilter(DynamicFilterType.AboveAverage);
178-
// Apply a dynamic filter to the "Reported Date" column to display values reported this year.
185+
// Apply a dynamic filter to the "Reported Date" column
186+
// to display values reported this year.
179187
worksheet.AutoFilter.Columns[3].ApplyDynamicFilter(DynamicFilterType.ThisYear);
180188
#endregion #DynamicFilter
181189
}
@@ -186,14 +194,14 @@ static void ReapplyFilterValue(Workbook workbook)
186194
Worksheet worksheet = workbook.Worksheets["Regional sales"];
187195
workbook.Worksheets.ActiveWorksheet = worksheet;
188196

189-
// Enable filtering for the specified cell range.
197+
// Enable filtering for the "B2:E23" cell range.
190198
CellRange range = worksheet["B2:E23"];
191199
worksheet.AutoFilter.Apply(range);
192200

193201
// Filter values in the "Sales" column that are greater than 5000$.
194202
worksheet.AutoFilter.Columns[2].ApplyCustomFilter(5000, FilterComparisonOperator.GreaterThan);
195203

196-
// Change the data and reapply the filter.
204+
// Change data and reapply the filter.
197205
worksheet["D3"].Value = 5000;
198206
worksheet.AutoFilter.ReApply();
199207
#endregion #ReapplyFilter
@@ -205,7 +213,7 @@ static void ClearFilter(Workbook workbook)
205213
Worksheet worksheet = workbook.Worksheets["Regional sales"];
206214
workbook.Worksheets.ActiveWorksheet = worksheet;
207215

208-
// Enable filtering for the specified cell range.
216+
// Enable filtering for the "B2:E23" cell range.
209217
CellRange range = worksheet["B2:E23"];
210218
worksheet.AutoFilter.Apply(range);
211219

@@ -223,7 +231,7 @@ static void DisableFilter(Workbook workbook)
223231
Worksheet worksheet = workbook.Worksheets["Regional sales"];
224232
workbook.Worksheets.ActiveWorksheet = worksheet;
225233

226-
// Enable filtering for the specified cell range.
234+
// Enable filtering for the "B2:E23" cell range.
227235
CellRange range = worksheet["B2:E23"];
228236
worksheet.AutoFilter.Apply(range);
229237

‎CS/SpreadsheetDocServerAPIPart2/CodeExamples/ExportActions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ private static void ExportDocToHTML(Workbook workbook)
1414

1515
HtmlDocumentExporterOptions options = new HtmlDocumentExporterOptions();
1616

17-
// Specify the part of the document to be exported to HTML.
17+
// Specify the cell range you want to save as HTML.
1818
options.SheetIndex = worksheet.Index;
1919
options.Range = "B2:G7";
2020

21-
// Export the active worksheet to a stream as HTML with the specified options.
21+
// Export data to HTML format.
2222
using (FileStream htmlStream = new FileStream("OutputWorksheet.html", FileMode.Create))
2323
{
2424
workbook.ExportToHtml(htmlStream, options);

‎CS/SpreadsheetDocServerAPIPart2/CodeExamples/GroupAndOutlineActions.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ static void GroupRows(Workbook workbook)
1111
Worksheet worksheet = workbook.Worksheets["Grouping"];
1212
workbook.Worksheets.ActiveWorksheet = worksheet;
1313

14-
// Group four rows starting from the third row and collapse the group.
14+
// Group rows 3 through 6 and collapse the group.
1515
worksheet.Rows.Group(2, 5, true);
1616

17-
// Group four rows starting from the ninth row and expand the group.
17+
// Group rows 9 through 12 and expand the group.
1818
worksheet.Rows.Group(8, 11, false);
1919

20-
// Create the outer group of rows by grouping rows 2 through 13.
20+
// Group rows 2 through 13 to create the outer group.
2121
worksheet.Rows.Group(1, 12, false);
2222
#endregion #GroupRows
2323
}
@@ -28,7 +28,7 @@ static void GroupColumns(Workbook workbook)
2828
Worksheet worksheet = workbook.Worksheets["Grouping"];
2929
workbook.Worksheets.ActiveWorksheet = worksheet;
3030

31-
// Group four columns starting from the third column "C" and expand the group.
31+
// Group columns "C" through "F" and expand the group.
3232
worksheet.Columns.Group(2, 5, false);
3333
#endregion #GroupColumns
3434
}
@@ -39,13 +39,13 @@ static void UngroupRows(Workbook workbook)
3939
Worksheet worksheet = workbook.Worksheets["Grouping and Outline"];
4040
workbook.Worksheets.ActiveWorksheet = worksheet;
4141

42-
// Ungroup four rows (from the third row to the sixth row) and display collapsed data.
42+
// Ungroup rows 3 through 6 and display collapsed data.
4343
worksheet.Rows.UnGroup(2, 5, true);
4444

45-
// Ungroup four rows (from the ninth row to the twelfth row).
45+
// Ungroup rows 9 through 12.
4646
worksheet.Rows.UnGroup(8, 11, false);
4747

48-
// Remove the outer group of rows.
48+
// Remove the outer row group.
4949
worksheet.Rows.UnGroup(1, 12, false);
5050
#endregion #UngroupRows
5151
}
@@ -56,7 +56,7 @@ static void UngroupColumns(Workbook workbook)
5656
Worksheet worksheet = workbook.Worksheets["Grouping and Outline"];
5757
workbook.Worksheets.ActiveWorksheet = worksheet;
5858

59-
// Ungroup four columns (from the column "C" to the column "F").
59+
// Ungroup columns "C" through "F".
6060
worksheet.Columns.UnGroup(2, 5, false);
6161
#endregion #UngroupColumns
6262
}
@@ -77,12 +77,13 @@ static void Subtotal(Workbook workbook)
7777
#region #Subtotal
7878
Worksheet worksheet = workbook.Worksheets["Regional Sales"];
7979
workbook.Worksheets.ActiveWorksheet = worksheet;
80-
80+
// Obtain the target cell range.
8181
CellRange dataRange = worksheet["B3:E23"];
82-
// Specify that subtotals should be calculated for the column "D".
82+
// Calculate subtotals for column "D".
8383
List<int> subtotalColumnsList = new List<int>();
8484
subtotalColumnsList.Add(3);
85-
// Insert subtotals by each change in the column "B" and calculate the SUM fuction for the related rows in the column "D".
85+
// Insert subtotals by each change in column "B"
86+
// and calculate the SUM fuction for the related rows in column "D".
8687
worksheet.Subtotal(dataRange, 1, subtotalColumnsList, 9, "Total");
8788
#endregion #Subtotal
8889
}

‎CS/SpreadsheetDocServerAPIPart2/CodeExamples/PictureActions.cs

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ static void InsertPicture(Workbook workbook)
1515
try
1616
{
1717
Worksheet worksheet = workbook.Worksheets[0];
18-
// Insert a picture from a file so that its top left corner is in the specified cell.
19-
// By default the picture is named Picture 1.. Picture NN.
18+
// Insert a picture from a file so that its top left corner is in the "A1" cell.
19+
// Default picture names are Picture 1.. Picture NN.
2020
worksheet.Pictures.AddPicture("Pictures\\x-docserver.png", worksheet.Cells["A1"]);
2121
// Insert a picture at 70 mm from the left, 40 mm from the top,
22-
// and resize it to a width of 85 mm and a height of 25 mm, locking the aspect ratio.
22+
// resize it to a width of 85 mm and a height of 25 mm, and lock the aspect ratio.
2323
worksheet.Pictures.AddPicture("Pictures\\x-docserver.png", 70, 40, 85, 25, true);
24-
// Insert the picture to be removed.
24+
// Insert a picture.
2525
worksheet.Pictures.AddPicture("Pictures\\x-docserver.png", 0, 0);
26-
// Remove the last inserted picture.
27-
// Find the shape by its name. The method returns a collection of shapes with the same name.
26+
// Find the last inserted picture by its name.
2827
Picture picShape = worksheet.Pictures.GetPicturesByName("Picture 3")[0];
28+
// Remove the last inserted picture.
2929
picShape.Delete();
3030
}
3131
finally
@@ -35,58 +35,32 @@ static void InsertPicture(Workbook workbook)
3535
#endregion #InsertPicture
3636
}
3737

38-
static void InsertPictureFromUri(Workbook workbook)
39-
{
40-
#region #InsertPictureFromUri
41-
string imageUri = "https://www.devexpress.com/Products/NET/Controls/WinForms/spreadsheet/i/winforms-spreadsheet-control.png";
42-
// Create an image from Uri.
43-
SpreadsheetImageSource imageSource = SpreadsheetImageSource.FromUri(imageUri, workbook);
44-
// Set the measurement unit to point.
45-
workbook.Unit = DevExpress.Office.DocumentUnit.Point;
46-
47-
workbook.BeginUpdate();
48-
try
49-
{
50-
Worksheet worksheet = workbook.Worksheets[0];
51-
// Insert a picture from the SpreadsheetImageSource at 100 pt from the left, 40 pt from the top,
52-
// and resize it to a width of 300 pt and a height of 200 pt.
53-
worksheet.Pictures.AddPicture(imageSource, 100, 40, 300, 200);
54-
}
55-
finally
56-
{
57-
workbook.EndUpdate();
58-
}
59-
#endregion #InsertPictureFromUri
60-
61-
}
62-
6338
static void ModifyPicture(Workbook workbook)
6439
{
65-
6640
#region #ModifyPicture
6741
// Set the measurement unit to Millimeter.
6842
workbook.Unit = DevExpress.Office.DocumentUnit.Millimeter;
6943
workbook.BeginUpdate();
7044
try
7145
{
7246
Worksheet worksheet = workbook.Worksheets[0];
73-
// Insert pictures from the file.
47+
// Insert a picture from a file.
7448
Picture pic = worksheet.Pictures.AddPicture("Pictures\\x-docserver.png", worksheet.Cells["A1"]);
75-
// Specify picture name and draw a border.
49+
// Specify the picture name and draw a border.
7650
pic.Name = "Logo";
7751
pic.AlternativeText = "Spreadsheet Logo";
7852
pic.BorderWidth = 1;
7953
pic.BorderColor = DevExpress.Utils.DXColor.Black;
8054
// Move a picture.
8155
pic.Move(20, 30);
82-
// Change picture behavior so it will move and size with underlying cells.
56+
// Specify picture behavior.
8357
pic.Placement = Placement.MoveAndSize;
8458
worksheet.Rows[5].Height += 10;
8559
worksheet.Columns["D"].Width += 10;
86-
// Specify rotation angle.
60+
// Specify the rotation angle.
8761
pic.Rotation = 30;
8862
// Add a hyperlink.
89-
pic.InsertHyperlink("http://www.devexpress.com/Products/NET/Document-Server/", true);
63+
pic.InsertHyperlink("https://www.devexpress.com/products/net/office-file-api/", true);
9064
}
9165
finally
9266
{

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /