Class XlsxConditionalFormats
- Namespace
- DocWright.Spreadsheet
- Assembly
- DocWright.Spreadsheet.dll
The conditional formats of one sheet of an opened workbook (Phase 202): listed as the file holds them, added, changed, reordered and removed as Excel's Conditional Formatting does, and written the way Excel writes its own.
public sealed class XlsxConditionalFormats : IReadOnlyList<XlsxConditionalFormat>, IReadOnlyCollection<XlsxConditionalFormat>, IEnumerable<XlsxConditionalFormat>, IEnumerable
- Inheritance
-
XlsxConditionalFormats
- Implements
- Inherited Members
Remarks
Measured with Excel (tools/Probe-ExcelConditionalFormats.ps1): a rule is a cfRule in a
conditionalFormatting element that names its cells; its look is a differential format (dxf) in
the style part, which holds only what it sets. A data bar keeps its Excel 2010 settings in the sheet's extension.
Priority 1 is applied first; a rule added goes last, as Excel's FormatConditions.Add puts it.
Edits are held in memory and written into the sheet's part, and new formats into the style part, when anything next reads them or the workbook is saved.
Properties
- Count
Gets the number of rules.
- this[int]
Gets a rule by its place in the list (the file's order, the main element's rules first).
Methods
- AddAverage(XlsxCellRange, bool, bool, XlsxDifferentialStyle)
Adds a rule that formats values above or below the range's average.
- AddBlanks(XlsxCellRange, bool, XlsxDifferentialStyle)
Adds a rule that formats blank cells (and text of nothing but spaces), or those that are not.
- AddCellValue(XlsxCellRange, XlsxConditionOperator, string, string?, XlsxDifferentialStyle)
Adds a rule that formats cells whose value compares with one or two formulas (Excel's Cell Value).
- AddColorScale(XlsxCellRange, params XlsxThresholdPoint[])
Adds a colour scale. With no points, Excel's own: two colours from the lowest value to the highest, or three with the 50th percentile between.
- AddDataBar(XlsxCellRange, ColorRgb?)
Adds a data bar from the lowest value to the highest, as Excel's Data Bars do, with Excel 2010's settings (bars from 0 to 100 percent of the cell).
- AddDatesOccurring(XlsxCellRange, XlsxTimePeriod, XlsxDifferentialStyle)
Adds a rule that formats dates in a period around today (Excel's A Date Occurring). Judged against the day Today gives.
- AddDuplicates(XlsxCellRange, bool, XlsxDifferentialStyle)
Adds a rule that formats values occurring more than once, or once only.
- AddErrors(XlsxCellRange, bool, XlsxDifferentialStyle)
Adds a rule that formats cells holding an error, or those that do not.
- AddExpression(XlsxCellRange, string, XlsxDifferentialStyle)
Adds a rule that formats cells for which a formula is true (Excel's "Use a formula"). Excel calculates it; this library does not, so EffectiveStyle(int, int, XlsxConditionalOptions?) leaves it unjudged.
- AddIconSet(XlsxCellRange, string)
Adds an icon set with Excel's thresholds: the icons split the range from its lowest value to its highest in equal percents.
- AddText(XlsxCellRange, XlsxConditionalFormatKind, string, XlsxDifferentialStyle)
Adds a rule on the text of cells: containing, not containing, beginning or ending with a text, case not counting.
- AddTopBottom(XlsxCellRange, int, bool, bool, XlsxDifferentialStyle)
Adds a rule that formats the highest or the lowest values (Excel's Top/Bottom Rules).
- GetEnumerator()
Returns the rules, the main element's first.
- Remove(XlsxCellRange)
Removes the rules of a range, as Excel's Clear Rules from Selected Cells: every rule whose cells are all in the range.
- Remove(XlsxConditionalFormat)
Removes one rule (and, for a data bar, its settings in the extension).
- Reorder(XlsxConditionalFormat, int)
Gives a rule a priority, as Excel's Move Up and Move Down do: the rules between move one place to make room; priorities stay 1 to the number of rules.