pub struct PartTextBuilder<'vf, T: ValueFormatTrait> { /* private fields */ }
Expand description

Adds a format part to this format.

The number:text element contains any fixed text for a data style.

Can be used with ValueTypes:

  • Boolean
  • Currency
  • DateTime
  • Number
  • Percentage
  • Text
  • TimeDuration

Implementations§

source§

impl<'vf, T: ValueFormatTrait> PartTextBuilder<'vf, T>

source

pub fn new<'a>(valueformat: &'a mut T) -> Self
where 'a: 'vf,

New builder for the valueformat.

source

pub fn build(self)

Appends the constructed FormatPart to the original value format.

Examples found in repository?
examples/negative_number_red.rs (line 22)
7
8
9
10
11
12
13
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
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 if_then<F>(self, test: bool, build: F) -> Self
where F: Fn(Self) -> Self,

Only applies the builder if the test is true.

source

pub fn text<S: Into<String>>(self, txt: S) -> Self

Sets the text value.

Trait Implementations§

source§

impl<'vf, T: Debug + ValueFormatTrait> Debug for PartTextBuilder<'vf, T>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'vf, T> RefUnwindSafe for PartTextBuilder<'vf, T>
where T: RefUnwindSafe,

§

impl<'vf, T> Send for PartTextBuilder<'vf, T>
where T: Send,

§

impl<'vf, T> Sync for PartTextBuilder<'vf, T>
where T: Sync,

§

impl<'vf, T> Unpin for PartTextBuilder<'vf, T>

§

impl<'vf, T> !UnwindSafe for PartTextBuilder<'vf, T>

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, 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.