ConditionalFormattingCollection
Innehåll
[
Dölj
]ConditionalFormattingCollection class
Kapslar in en samling avFormatCondition
objekt.
public class ConditionalFormattingCollection : CollectionBase<FormatConditionCollection>
Egenskaper
namn | Beskrivning |
---|---|
Capacity { get; set; } | |
Count { get; } | |
Item { get; } | Hämtar FormatConditions-elementet vid angivet index. |
Item { get; set; } |
Metoder
namn | Beskrivning |
---|---|
Add() | Lägger till ett Formatvillkor till samlingen. |
BinarySearch(FormatConditionCollection) | |
BinarySearch(FormatConditionCollection, IComparer<FormatConditionCollection>) | |
BinarySearch(int, int, FormatConditionCollection, IComparer<FormatConditionCollection>) | |
Clear() | |
Contains(FormatConditionCollection) | |
Copy(ConditionalFormattingCollection) | Kopierar villkorlig formatering. |
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) | Ta bort all villkorlig formatering i intervallet. |
RemoveAt(int) |
Exempel
[C#]
//Instantiering av ett arbetsboksobjekt
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Hämta villkorlig formatering
ConditionalFormattingCollection cformattings = sheet.ConditionalFormattings;
//Lägger till en tom villkorlig formatering
int index = cformattings.Add();
//Få ny tillagd villkorlig formatering
FormatConditionCollection fcs = cformattings[index];
//Ställer in det villkorliga formatintervallet.
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);
//Lägg till villkor.
int conditionIndex = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "=A2", "100");
//Lägg till villkor.
int conditionIndex2 = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100");
//Ställer in bakgrundsfärgen.
FormatCondition fc = fcs[conditionIndex];
fc.Style.BackgroundColor = Color.Red;
//Spara Excel-filen
workbook.Save("output.xls");
[VB.NET]
'Instantiera ett arbetsboksobjekt
DDim workbook As Workbook = New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
'Skaffa villkorlig formatering
Dim cformattings As ConditionalFormattingCollection = sheet.ConditionalFormattings
'Lägger till en tom villkorlig formatering
Dim index As Integer = cformattings.Add()
'Få ny tillagd villkorlig formatering
Dim fcs As FormatConditionCollection = cformattings(index)
'Ställer in det villkorliga formatintervallet.
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)
'Lägg till villkor.
Dim conditionIndex As Integer = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "=A2", "100")
'Lägg till villkor.
Dim conditionIndex2 As Integer = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100")
'Ställer in bakgrundsfärgen.
Dim fc As FormatCondition = fcs(conditionIndex)
fc.Style.BackgroundColor = Color.Red
'Sparar Excel-filen
workbook.Save("output.xls")
Se även
- class CollectionBase<T>
- class FormatConditionCollection
- namnutrymme Aspose.Cells
- hopsättning Aspose.Cells