-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSearchActions.cs
47 lines (41 loc) · 1.67 KB
/
SearchActions.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
using DevExpress.Spreadsheet;
using System;
using System.Collections.Generic;
using System.Drawing;
namespace SpreadsheetDocServerAPIPart2
{
public static class SearchActions
{
static void SimpleSearchValue(Workbook workbook)
{
#region #SimpleSearch
workbook.Calculate();
Worksheet worksheet = workbook.Worksheets["ExpenseReport"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Find and highlight cells that contain the word "holiday".
IEnumerable<Cell> searchResult = worksheet.Search("holiday");
foreach (Cell cell in searchResult)
cell.Fill.BackgroundColor = Color.LightGreen;
#endregion #SimpleSearch
}
static void AdvancedSearchValue(Workbook workbook)
{
#region #AdvancedSearch
workbook.Calculate();
Worksheet worksheet = workbook.Worksheets["ExpenseReport"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Specify the search term.
string searchString = DateTime.Today.ToString("d");
// Specify search options.
SearchOptions options = new SearchOptions();
options.SearchBy = SearchBy.Columns;
options.SearchIn = SearchIn.Values;
options.MatchEntireCellContents = true;
// Find and highlight all cells that contain today's date.
IEnumerable<Cell> searchResult = worksheet.Search(searchString, options);
foreach (Cell cell in searchResult)
cell.Fill.BackgroundColor = Color.LightGreen;
#endregion #AdvancedSearch
}
}
}