ConditionalFormattingCollection
Содержание
[
Скрывать
]ConditionalFormattingCollection class
Инкапсулирует наборFormatCondition объекты.
public class ConditionalFormattingCollection : CollectionBase<FormatConditionCollection>
Характеристики
| Имя | Описание |
|---|---|
| Capacity { get; set; } | |
| Count { get; } | |
| Item { get; } | Получает элемент FormatConditions по указанному индексу. |
| Item { get; set; } |
Методы
| Имя | Описание |
|---|---|
| Add() | Добавляет FormatConditions в коллекцию. |
| BinarySearch(FormatConditionCollection) | |
| BinarySearch(FormatConditionCollection, IComparer<FormatConditionCollection>) | |
| BinarySearch(int, int, FormatConditionCollection, IComparer<FormatConditionCollection>) | |
| Clear() | |
| Contains(FormatConditionCollection) | |
| Copy(ConditionalFormattingCollection) | Копирует условное форматирование. |
| CopyTo(FormatConditionCollection[]) | |
| CopyTo(FormatConditionCollection[], int) | |
| CopyTo(int, FormatConditionCollection[], int, int) | |
| Exists(Predicate<FormatConditionCollection>) | |
| Find(Predicate<FormatConditionCollection>) | |
| FindAll(Predicate<FormatConditionCollection>) | |
| FindIndex(Predicate<FormatConditionCollection>) | |
| FindIndex(int, Predicate<FormatConditionCollection>) | |
| FindIndex(int, int, Predicate<FormatConditionCollection>) | |
| FindLast(Predicate<FormatConditionCollection>) | |
| FindLastIndex(Predicate<FormatConditionCollection>) | |
| FindLastIndex(int, Predicate<FormatConditionCollection>) | |
| FindLastIndex(int, int, Predicate<FormatConditionCollection>) | |
| GetEnumerator() | |
| IndexOf(FormatConditionCollection) | |
| IndexOf(FormatConditionCollection, int) | |
| IndexOf(FormatConditionCollection, int, int) | |
| LastIndexOf(FormatConditionCollection) | |
| LastIndexOf(FormatConditionCollection, int) | |
| LastIndexOf(FormatConditionCollection, int, int) | |
| RemoveArea(int, int, int, int) | Удалить все условное форматирование в диапазоне. |
| RemoveAt(int) |
Примеры
[C#]
//Создание экземпляра объекта Workbook
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Получить условное форматирование
ConditionalFormattingCollection cformattings = sheet.ConditionalFormattings;
//Добавляет пустое условное форматирование
int index = cformattings.Add();
//Получить недавно добавленное условное форматирование
FormatConditionCollection fcs = cformattings[index];
//Устанавливает диапазон условного формата.
CellArea ca = new CellArea();
ca.StartRow = 0;
ca.EndRow = 0;
ca.StartColumn = 0;
ca.EndColumn = 0;
fcs.AddArea(ca);
ca = new CellArea();
ca.StartRow = 1;
ca.EndRow = 1;
ca.StartColumn = 1;
ca.EndColumn = 1;
fcs.AddArea(ca);
//Добавить условие.
int conditionIndex = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "=A2", "100");
//Добавить условие.
int conditionIndex2 = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100");
//Устанавливаем цвет фона.
FormatCondition fc = fcs[conditionIndex];
fc.Style.BackgroundColor = Color.Red;
//Сохранение файла Excel
workbook.Save("output.xls");
[VB.NET]
'Создание экземпляра объекта Workbook
DDim workbook As Workbook = New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
'Получить условное форматирование
Dim cformattings As ConditionalFormattingCollection = sheet.ConditionalFormattings
'Добавляет пустое условное форматирование
Dim index As Integer = cformattings.Add()
'Получить недавно добавленное условное форматирование
Dim fcs As FormatConditionCollection = cformattings(index)
'Задает диапазон условного формата.
Dim ca As New CellArea()
ca.StartRow = 0
ca.EndRow = 0
ca.StartColumn = 0
ca.EndColumn = 0
fcs.AddArea(ca)
ca = New CellArea()
ca.StartRow = 1
ca.EndRow = 1
ca.StartColumn = 1
ca.EndColumn = 1
fcs.AddArea(ca)
'Добавить условие.
Dim conditionIndex As Integer = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "=A2", "100")
'Добавить условие.
Dim conditionIndex2 As Integer = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100")
'Устанавливает цвет фона.
Dim fc As FormatCondition = fcs(conditionIndex)
fc.Style.BackgroundColor = Color.Red
'Сохранение файла Excel
workbook.Save("output.xls")
Смотрите также
- class CollectionBase<T>
- class FormatConditionCollection
- пространство имен Aspose.Cells
- сборка Aspose.Cells