Skip to main content

RowData

Struct RowData 

Source
pub struct RowData<'a> {
    pub row_index: u32,
    pub sheet: &'a str,
    pub header: &'a HeaderMap,
    pub cells: &'a [Cell],
    pub images: &'a [RowImage],
    pub merges: &'a [MergeRange],
    pub styles: &'a Styles,
    pub hyperlinks: &'a [Hyperlink],
    pub comments: &'a [Comment],
    pub validations: &'a [DataValidation],
    pub conditional_formats: &'a [ConditionalFormat],
}
Expand description

一行原始数据(解析后、映射前)

Fields§

§row_index: u32

Excel 行号(1 基)

§sheet: &'a str

工作表名

§header: &'a HeaderMap

表头解析结果(含列序对应关系)

§cells: &'a [Cell]

本行单元格(可能稀疏:空单元格不出现)

§images: &'a [RowImage]

本行图片(仅当开启读图)

§merges: &'a [MergeRange]

与本行相交的合并区域(仅当开启合并读取;见 crate::ReadOptions::with_merges)

§styles: &'a Styles

单元格样式表(判断字体颜色 / 底色 / 加粗 / 斜体)

§hyperlinks: &'a [Hyperlink]

本工作表的超链接(仅当 crate::ReadOptions::with_hyperlinks 开启时非空)

§comments: &'a [Comment]

本工作表的批注(仅当 crate::ReadOptions::with_comments 开启时非空)

§validations: &'a [DataValidation]

本工作表的数据验证(仅当 crate::ReadOptions::with_validations 开启时非空)

§conditional_formats: &'a [ConditionalFormat]

本工作表的条件格式(仅当 crate::ReadOptions::with_conditional_formats 开启时非空)

Implementations§

Source§

impl<'a> RowData<'a>

Source

pub fn cell_at(&self, col: u16) -> Option<&Cell>

按列索引取单元格

Source

pub fn cell_of(&self, header: &str) -> Option<&Cell>

按模型列名(或别名)取单元格

Source

pub fn value_of(&self, header: &str) -> Option<&CellValue>

Source

pub fn text_of(&self, header: &str) -> String

Source

pub fn get<T: FromCell>(&self, header: &str) -> Result<T, String>

取强类型值(列缺失或空值都会报错,用于必填字段)

Source

pub fn opt<T: FromCell>(&self, header: &str) -> Result<Option<T>, String>

取可选值(列缺失或空值都返回 None)

Source

pub fn string(&self, header: &str) -> Option<String>

取字符串(保持“列缺失“与“空值“都为空串)

Source

pub fn images_of(&self, header: &str) -> Vec<&RowImage>

该列对应的行内图片(按列筛)

Source

pub fn image_at(&self, n: usize) -> Option<&RowImage>

第 n 张图片(图片列:图片1/图片2… 按列升序)

Source

pub fn merged_at(&self, col: u16) -> Option<&MergeRange>

本行是否落在某个合并区域内(返回该区域)

Source

pub fn cell_style(&self, header: &str) -> Option<CellStyle>

某列的样式(底色 / 字体颜色 / 加粗 / 斜体);列不存在返回 None

Source

pub fn style_at(&self, col: u16) -> Option<CellStyle>

按文件列索引取样式

某列的超链接

Source

pub fn comment_at(&self, col: u16) -> Option<&Comment>

某列的批注

Source

pub fn validation_at(&self, col: u16) -> Option<&DataValidation>

某列命中的数据验证(下拉 / 数值区间)

Source

pub fn conditional_format_at(&self, col: u16) -> Option<&ConditionalFormat>

某列命中的条件格式

某列的超链接地址(取不到返回 None)

Source

pub fn comment_of(&self, header: &str) -> Option<&str>

某列的批注文本

Source

pub fn is_empty(&self) -> bool

整行是否为空(含图片)

Source

pub fn to_text_row(&self) -> Vec<String>

把本行的单元格按文件列序转换为文本(错误报告 / 预览用)

Source

pub fn missing_columns(&self) -> Vec<String>

未在表头出现但模型声明过的列(用于区分“缺列“与“空值“)

Auto Trait Implementations§

§

impl<'a> Freeze for RowData<'a>

§

impl<'a> RefUnwindSafe for RowData<'a>

§

impl<'a> Send for RowData<'a>

§

impl<'a> Sync for RowData<'a>

§

impl<'a> Unpin for RowData<'a>

§

impl<'a> UnsafeUnpin for RowData<'a>

§

impl<'a> UnwindSafe for RowData<'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, 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.