Enum xlsx_batch_reader::CellValue

source ·
pub enum CellValue<'a> {
    Blank,
    Bool(bool),
    Number(f64),
    Date(f64),
    Time(f64),
    Datetime(f64),
    Shared(&'a String),
    String(String),
    Error(String),
}
Expand description

Cell Value Type

Variants§

§

Blank

§

Bool(bool)

§

Number(f64)

§

Date(f64)

§

Time(f64)

§

Datetime(f64)

§

Shared(&'a String)

§

String(String)

§

Error(String)

Implementations§

source§

impl<'a> CellValue<'a>

source

pub fn get<T: FromCellValue>(&'a self) -> Result<Option<T>>

Examples found in repository?
examples/simple_reader.rs (line 16)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut book = XlsxBook::new("xlsx/test.xlsx", true)?;
    for shname in book.get_visible_sheets().clone() {
        // left_ncol should not be 0
        // the tail empty rows will be ignored, if you want the length of cells in each row is fixed, you can set right_ncol to a number not MAX_COL_NUM
        let sheet = book.get_sheet_by_name(&shname, 100, 0, 1, MAX_COL_NUM, false)?;

        for batch in sheet {
            let (rows_nums, rows_data) = batch?;
            // empty rows will be skiped
            for (row, cells) in rows_nums.into_iter().zip(rows_data) {
                for (col, cel) in cells.into_iter().enumerate() {
                    let val: String = cel.get()?.unwrap();   // supprted types: String, i64, f64, bool, NaiveDate
                    println!("the value of {} is {val}", get_ord_from_tuple(row, (col+1) as u16)?);  
                }
            }
        };
    }
    Ok(())
}

Trait Implementations§

source§

impl<'a> Clone for CellValue<'a>

source§

fn clone(&self) -> CellValue<'a>

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<'a> Debug for CellValue<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for CellValue<'a>

§

impl<'a> RefUnwindSafe for CellValue<'a>

§

impl<'a> Send for CellValue<'a>

§

impl<'a> Sync for CellValue<'a>

§

impl<'a> Unpin for CellValue<'a>

§

impl<'a> UnwindSafe for CellValue<'a>

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> Same for T

§

type Output = T

Should always be Self
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.