pub enum Value {
Empty,
Number(f64),
Percentage(f64),
Currency(f64, Option<String>),
Date(String),
Time(String),
Boolean(bool),
Text(String),
}Expand description
What a cell holds, as ODF types it.
The type is the cell’s own declaration and is independent of how it is shown: a date is a date whatever format it is displayed in, which is what makes a spreadsheet sortable.
Variants§
Empty
Nothing. A cell that exists to carry a style, or to be spanned over.
Number(f64)
A number.
Percentage(f64)
A number that means a proportion: 0.15 shown as 15%.
Currency(f64, Option<String>)
An amount of money, with the currency code where the cell names one.
Date(String)
A date, as written: an ISO 8601 date or date and time.
Time(String)
A duration, as written: an ISO 8601 duration.
Boolean(bool)
True or false.
Text(String)
Text.
Implementations§
Source§impl Value
impl Value
Sourcepub fn from_input(input: &str) -> Self
pub fn from_input(input: &str) -> Self
What a person typed into a cell, read the way a spreadsheet reads it: a
number is a number, true and false are booleans, nothing is empty,
and anything else is text.
A formula is not recognised here, because nothing in this version
evaluates one; text beginning with = is text. Percentages, currencies
and dates need the document’s number formats to read and are text too.
Sourcepub fn input_text(&self) -> String
pub fn input_text(&self) -> String
The text a person edits for the value: a number’s plain spelling, a
date’s or a duration’s ISO form, TRUE and FALSE, the text itself.
What Self::from_input reads back into the same value where it can,
which is not everywhere: a percentage, a currency or a date typed again
comes back as the number or the text it reads as, because reading it as
what it was needs the number format the cell carries.
Sourcepub fn cached_text(&self) -> String
pub fn cached_text(&self) -> String
The text a cell shows for the value, as this crate formats it: the
shortest spelling of a number, TRUE and FALSE, the text itself. A
document’s own number format is not applied; a spreadsheet application
reformats the cell from the value when it next opens the file.
Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Whether the value is one a spreadsheet puts against the right edge of its cell: every type but text, which is ODF’s own rule and every application’s default.