Skip to main content

CellValue

Enum CellValue 

Source
pub enum CellValue {
    Empty,
    Text(String),
    Number(f64),
    Bool(bool),
    Date(NaiveDate),
    DateTime(NaiveDateTime),
    Formula(String),
    Error(String),
    Image(CellImage),
}
Expand description

单元格值

Variants§

§

Empty

空单元格

§

Text(String)

文本

§

Number(f64)

数值

§

Bool(bool)

布尔

§

Date(NaiveDate)

日期

§

DateTime(NaiveDateTime)

日期时间(无时区,Excel 语义)

§

Formula(String)

公式(写出时按公式写;读入时保留原始公式文本)

§

Error(String)

Excel 错误值(#DIV/0! 等)

§

Image(CellImage)

图片(写出时嵌入单元格;读入来自内嵌图片)

Implementations§

Source§

impl CellValue

Source

pub fn is_empty(&self) -> bool

是否为空(空白文本视为空)

Source

pub fn type_name(&self) -> &'static str

Source

pub fn to_text(&self) -> String

显示文本(导入预览 / 错误提示 / 导出兜底都用它)

Source

pub fn trimmed(&self) -> String

去空白后的显示文本

Source

pub fn to_f64(&self) -> Option<f64>

Source

pub fn to_i64(&self) -> Option<i64>

Source

pub fn to_bool(&self) -> Option<bool>

Source

pub fn to_decimal(&self) -> Option<Decimal>

Source

pub fn to_date(&self) -> Option<NaiveDate>

Source

pub fn to_datetime(&self) -> Option<NaiveDateTime>

Trait Implementations§

Source§

impl Clone for CellValue

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CellValue

Source§

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

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

impl Default for CellValue

Source§

fn default() -> Self

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

impl From<&str> for CellValue

Source§

fn from(v: &str) -> Self

Converts to this type from the input type.
Source§

impl From<CellValue> for String

Source§

fn from(v: CellValue) -> Self

Converts to this type from the input type.
Source§

impl From<String> for CellValue

Source§

fn from(v: String) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for CellValue

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for CellValue

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for CellValue

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for CellValue

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl FromCell for CellValue

Source§

fn from_cell(cell: &Cell) -> Result<Self, String>

Source§

fn type_name() -> &'static str

类型名(错误提示用)
Source§

fn from_missing_column() -> Result<Self, String>

该列在文件里完全缺失时的取值:普通类型报错,Option<T> 返回 None
Source§

impl IntoCell for CellValue

Source§

impl PartialEq for CellValue

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CellValue

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.