pub struct ConditionalFormatFormula { /* private fields */ }Expand description
The ConditionalFormatFormula struct represents a Formula style conditional
format.
ConditionalFormatFormula is used to represent a Formula style conditional
format in Excel. A Formula conditional format highlights formula values in a
range based on a user supplied formula.

For more information see Working with Conditional Formats.
§Examples
Example of adding a Formula type conditional formatting to a worksheet. Cells with odd numbered values are in light red while even numbered values are in light green.
// Write a conditional format over a range.
let conditional_format = ConditionalFormatFormula::new()
.set_rule("=ISODD(B3)")
.set_format(format1);
worksheet.add_conditional_format(2, 1, 11, 10, &conditional_format)?;
// Write another conditional format over the same range.
let conditional_format = ConditionalFormatFormula::new()
.set_rule("=ISEVEN(B3)")
.set_format(format2);
worksheet.add_conditional_format(2, 1, 11, 10, &conditional_format)?;
This creates conditional format rules like this:

And the following output file:

Implementations§
Source§impl ConditionalFormatFormula
impl ConditionalFormatFormula
Sourcepub fn new() -> ConditionalFormatFormula
pub fn new() -> ConditionalFormatFormula
Create a new Formula conditional format struct.
Sourcepub fn set_rule(self, rule: impl Into<Formula>) -> ConditionalFormatFormula
pub fn set_rule(self, rule: impl Into<Formula>) -> ConditionalFormatFormula
Set the rule of a Formula conditional format.
Set the formula rule in a Formula style conditional format.
There are some caveats to be aware of when creating the formula:
- The formula must evaluate to a boolean, number, date, time or string.
- Some newer “dynamic range” style functions aren’t supported by Excel in Formula conditional formats.
- The formula should be in English with US style punctuation. See
Formulafor details.
If you encounter any issues you should verify that the formula works in
Excel before transferring it to rust_xlsxwriter.
§Parameters
value: AFormulavalue or type that converts “into” aFormulasuch as a&stror&Formula.
§Examples
Example of adding a Formula type conditional formatting to a worksheet. Cells with odd numbered values are in light red while even numbered values are in light green.
// Write a conditional format over a range.
let conditional_format = ConditionalFormatFormula::new()
.set_rule("=ISODD(B3)")
.set_format(format1);
worksheet.add_conditional_format(2, 1, 11, 10, &conditional_format)?;
// Write another conditional format over the same range.
let conditional_format = ConditionalFormatFormula::new()
.set_rule("=ISEVEN(B3)")
.set_format(format2);
worksheet.add_conditional_format(2, 1, 11, 10, &conditional_format)?;Output file:

Sourcepub fn set_format(self, format: impl Into<Format>) -> ConditionalFormatFormula
pub fn set_format(self, format: impl Into<Format>) -> ConditionalFormatFormula
Set the Format of the conditional format rule.
Set the Format that will be applied to the cell range if the conditional
format rule applies. Not all cell format properties can be set in a
conditional format. See Excel’s limitations on conditional format
properties for
more information.
See the examples above.
§Parameters
format: TheFormatproperty for the conditional format.
Source§impl ConditionalFormatFormula
impl ConditionalFormatFormula
Sourcepub fn set_multi_range(
self,
range: impl Into<String>,
) -> ConditionalFormatFormula
pub fn set_multi_range( self, range: impl Into<String>, ) -> ConditionalFormatFormula
Set an additional multi-cell range for the conditional format.
The set_multi_range() method is used to extend a conditional
format over non-contiguous ranges like "B3:D6 I3:K6 B9:D12 I9:K12".
See Selecting a non-contiguous range for more information.
§Parameters
-
range: A string like type representing an Excel range.Note, you can use an Excel range like
"$B$3:$D$6,$I$3:$K$6"or omit the$anchors and replace the commas with spaces to have a clearer range like"B3:D6 I3:K6". The documentation and examples use the latter format for clarity but it you are copying and pasting from Excel you can use the first format.Note, if the range is invalid then Excel will omit it silently.
Sourcepub fn set_stop_if_true(self, enable: bool) -> ConditionalFormatFormula
pub fn set_stop_if_true(self, enable: bool) -> ConditionalFormatFormula
Set the “Stop if True” option for the conditional format rule.
The set_stop_if_true() method can be used to set the “Stop if true”
feature of a conditional formatting rule when more than one rule is
applied to a cell or a range of cells. When this parameter is set then
subsequent rules are not evaluated if the current rule is true.
§Parameters
enable: Turn the property on/off. It is off by default.
Trait Implementations§
Source§impl Clone for ConditionalFormatFormula
impl Clone for ConditionalFormatFormula
Source§fn clone(&self) -> ConditionalFormatFormula
fn clone(&self) -> ConditionalFormatFormula
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConditionalFormat for ConditionalFormatFormula
impl ConditionalFormat for ConditionalFormatFormula
Source§fn rule(
&self,
dxf_index: Option<u32>,
priority: u32,
range: &str,
guid: &str,
) -> String
fn rule( &self, dxf_index: Option<u32>, priority: u32, range: &str, guid: &str, ) -> String
Source§fn x14_rule(&self, priority: u32, guid: &str) -> String
fn x14_rule(&self, priority: u32, guid: &str) -> String
Source§fn format_as_mut(&mut self) -> Option<&mut Format>
fn format_as_mut(&mut self) -> Option<&mut Format>
Source§fn format_index(&self) -> Option<u32>
fn format_index(&self) -> Option<u32>
Source§fn multi_range(&self) -> String
fn multi_range(&self) -> String
Source§fn has_x14_extensions(&self) -> bool
fn has_x14_extensions(&self) -> bool
Source§fn has_x14_only(&self) -> bool
fn has_x14_only(&self) -> bool
Auto Trait Implementations§
impl Freeze for ConditionalFormatFormula
impl RefUnwindSafe for ConditionalFormatFormula
impl Send for ConditionalFormatFormula
impl Sync for ConditionalFormatFormula
impl Unpin for ConditionalFormatFormula
impl UnsafeUnpin for ConditionalFormatFormula
impl UnwindSafe for ConditionalFormatFormula
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more