pub struct ValueStyleMap { /* private fields */ }
Expand description

A style-map is one way for conditional formatting of value formats.

Implementations§

source§

impl ValueStyleMap

source

pub fn new<T: Into<String>>(condition: ValueCondition, applied_style: T) -> Self

Create a stylemap for a ValueFormat. When the condition is fullfilled the style applied_style is used.

Examples found in repository?
examples/negative_number_red.rs (line 37)
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
pub fn main() -> Result<(), OdsError> {
    let mut wb = WorkBook::new(locale!("de_AT"));

    // positive format
    let mut f_number = ValueFormatNumber::new_localized("num0", locale!("de_AT"));
    f_number
        .part_number()
        .decimal_places(2)
        .min_integer_digits(1)
        .grouping()
        .build();
    let f_number = wb.add_number_format(f_number);

    // negative format
    let mut f_number_red = ValueFormatNumber::new_localized("num0red", locale!("de_AT"));
    f_number_red.part_text("-").build();
    f_number_red
        .part_number()
        .decimal_places(2)
        .min_integer_digits(1)
        .grouping()
        .build();
    f_number_red.set_color(Rgb::new(255, 0, 0));
    f_number_red.push_stylemap(ValueStyleMap::new(ValueCondition::value_ge(0), f_number));
    let f_number_red = wb.add_number_format(f_number_red);

    // cellstyle for this number format
    let s_number = CellStyle::new("num_red", &f_number_red);
    let s_number = wb.add_cellstyle(s_number);

    // ...

    let mut sheet = Sheet::new("sample");

    sheet.set_styled_value(0, 0, 723, &s_number);
    sheet.set_styled_value(1, 0, -723, &s_number);

    wb.push_sheet(sheet);

    write_ods(&mut wb, "examples/neg.ods")?;

    Ok(())
}
source

pub fn condition(&self) -> &String

Condition

source

pub fn set_condition(&mut self, cond: ValueCondition)

Condition

source

pub fn applied_style(&self) -> &String

The applied style.

source

pub fn set_applied_style<S: Into<String>>(&mut self, style: S)

Sets the applied style.

Trait Implementations§

source§

impl Clone for ValueStyleMap

source§

fn clone(&self) -> ValueStyleMap

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ValueStyleMap

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ValueStyleMap

source§

fn default() -> ValueStyleMap

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.