Struct spreadsheet_ods::format::ValueStyleMap
source · pub struct ValueStyleMap { /* private fields */ }Expand description
A style-map is one way for conditional formatting of value formats.
Implementations§
source§impl ValueStyleMap
impl ValueStyleMap
sourcepub fn new<T: Into<String>>(condition: ValueCondition, applied_style: T) -> Self
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 30)
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(())
}sourcepub fn set_condition(&mut self, cond: ValueCondition)
pub fn set_condition(&mut self, cond: ValueCondition)
Condition
sourcepub fn applied_style(&self) -> &String
pub fn applied_style(&self) -> &String
The applied style.
sourcepub fn set_applied_style<S: Into<String>>(&mut self, style: S)
pub fn set_applied_style<S: Into<String>>(&mut self, style: S)
Sets the applied style.
Trait Implementations§
source§impl Clone for ValueStyleMap
impl Clone for ValueStyleMap
source§fn clone(&self) -> ValueStyleMap
fn clone(&self) -> ValueStyleMap
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for ValueStyleMap
impl Debug for ValueStyleMap
source§impl Default for ValueStyleMap
impl Default for ValueStyleMap
source§fn default() -> ValueStyleMap
fn default() -> ValueStyleMap
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl RefUnwindSafe for ValueStyleMap
impl Send for ValueStyleMap
impl Sync for ValueStyleMap
impl Unpin for ValueStyleMap
impl UnwindSafe for ValueStyleMap
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
Mutably borrows from an owned value. Read more