pub struct ConditionalFormatText { /* private fields */ }Expand description
The ConditionalFormatText struct represents a Text conditional format.
ConditionalFormatText is used to represent a Text style conditional format
in Excel. Text conditional formats use simple equalities such as “equal to”
or “greater than” or “between”.

For more information see Working with Conditional Formats.
§Examples
Example of adding a text type conditional formatting to a worksheet.
// Write a text "containing" conditional format over a range.
let conditional_format = ConditionalFormatText::new()
.set_rule(ConditionalFormatTextRule::Contains("rust".to_string()))
.set_format(&format1);
worksheet.add_conditional_format(0, 0, 12, 0, &conditional_format)?;
// Write a text "not containing" conditional format over the same range.
let conditional_format = ConditionalFormatText::new()
.set_rule(ConditionalFormatTextRule::DoesNotContain("rust".to_string()))
.set_format(&format2);
worksheet.add_conditional_format(0, 0, 12, 0, &conditional_format)?;
// Write a text "begins with" conditional format over a range.
let conditional_format = ConditionalFormatText::new()
.set_rule(ConditionalFormatTextRule::BeginsWith("t".to_string()))
.set_format(&format1);
worksheet.add_conditional_format(0, 2, 12, 2, &conditional_format)?;
// Write a text "ends with" conditional format over the same range.
let conditional_format = ConditionalFormatText::new()
.set_rule(ConditionalFormatTextRule::EndsWith("t".to_string()))
.set_format(&format2);
worksheet.add_conditional_format(0, 2, 12, 2, &conditional_format)?;
This creates conditional format rules like this:
And the following output file:
Implementations§
Source§impl ConditionalFormatText
impl ConditionalFormatText
Sourcepub fn new() -> ConditionalFormatText
pub fn new() -> ConditionalFormatText
Create a new Text conditional format struct.
Sourcepub fn set_rule(self, rule: ConditionalFormatTextRule) -> ConditionalFormatText
pub fn set_rule(self, rule: ConditionalFormatTextRule) -> ConditionalFormatText
Set the rule for the Text conditional format rule such “contains” or “starts with”.
See the example above.
§Parameters
rule: AConditionalFormatTextRuleenum value.
Sourcepub fn set_format(self, format: impl Into<Format>) -> ConditionalFormatText
pub fn set_format(self, format: impl Into<Format>) -> ConditionalFormatText
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 ConditionalFormatText
impl ConditionalFormatText
Sourcepub fn set_multi_range(self, range: impl Into<String>) -> ConditionalFormatText
pub fn set_multi_range(self, range: impl Into<String>) -> ConditionalFormatText
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) -> ConditionalFormatText
pub fn set_stop_if_true(self, enable: bool) -> ConditionalFormatText
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 ConditionalFormatText
impl Clone for ConditionalFormatText
Source§fn clone(&self) -> ConditionalFormatText
fn clone(&self) -> ConditionalFormatText
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConditionalFormat for ConditionalFormatText
impl ConditionalFormat for ConditionalFormatText
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 ConditionalFormatText
impl RefUnwindSafe for ConditionalFormatText
impl Send for ConditionalFormatText
impl Sync for ConditionalFormatText
impl Unpin for ConditionalFormatText
impl UnsafeUnpin for ConditionalFormatText
impl UnwindSafe for ConditionalFormatText
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