Skip to main content

ExcelReader

Struct ExcelReader 

Source
pub struct ExcelReader { /* private fields */ }
Expand description

xlsx 读取器(可同时解析多个工作表;每次 stream 都是独立的流式读取)

Implementations§

Source§

impl ExcelReader

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

打开磁盘文件(推荐:不把整个文件读进内存)

Source

pub fn from_bytes(bytes: Vec<u8>) -> Result<Self>

以内存字节打开(HTTP 上传的 multipart 场景)

Source

pub fn from_source(source: ZipSource) -> Result<Self>

复用已有数据源

Source

pub fn source(&self) -> &ZipSource

Source

pub fn sheets(&self) -> &[SheetInfo]

Source

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

Source

pub fn date_1904(&self) -> bool

Source

pub fn shared_strings(&self) -> &SharedStrings

Source

pub fn styles(&self) -> &Styles

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

Source

pub fn select(&self, selector: &SheetSelector) -> Result<Vec<&SheetInfo>>

解析选择器 → 工作表列表

Source

pub fn stream( &self, selector: SheetSelector, defs: &[ColumnDef], options: ReadOptions, ) -> Result<SheetStream>

打开一个工作表的行流(单个 sheet)

Source

pub fn stream_sheet( &self, sheet: &SheetInfo, defs: &[ColumnDef], options: ReadOptions, ) -> Result<SheetStream>

打开指定工作表的行流

Source

pub fn analyze_header( &self, selector: &SheetSelector, defs: &[ColumnDef], options: ReadOptions, ) -> Result<HeaderAnalysis>

只做表头自适应分析(不消费数据,供“导入预检“接口使用)

Source

pub fn analyze_all_headers( &self, defs: &[ColumnDef], options: ReadOptions, ) -> Result<Vec<(String, HeaderAnalysis)>>

读取所有工作表的表头分析(多 sheet 预检)

Source

pub fn merge_ranges(&self, selector: &SheetSelector) -> Result<Vec<MergeRange>>

读取指定(可多个)工作表的合并区域(只查询,不做值回填)

需要值回填时改用 ReadOptions::with_merges 走 ExcelReader::stream。

读取指定(可多个)工作表的超链接

Source

pub fn validations( &self, selector: &SheetSelector, ) -> Result<Vec<DataValidation>>

读取指定(可多个)工作表的数据验证(下拉 / 数值区间)

Source

pub fn conditional_formats( &self, selector: &SheetSelector, ) -> Result<Vec<ConditionalFormat>>

读取指定(可多个)工作表的条件格式

Source

pub fn read_dynamic( &self, selector: &SheetSelector, options: ReadOptions, ) -> Result<(Vec<String>, Vec<DynamicRow>)>

动态读取整表(无实体):返回 (表头, 每行 表头→值)

等价于 stream(selector, &[], options) + DynamicRow::from_row, 用于「没有实体、前端直接拿表头与内容」的场景。

Source

pub fn comments(&self, selector: &SheetSelector) -> Result<Vec<Comment>>

读取指定(可多个)工作表的批注(经典批注 comments*.xml + 线程批注 threadedComments)

线程批注只收根批注(带 ref 的条目),回复暂不展开。

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