pub trait DocxRow {
// Required methods
fn schema() -> &'static [TableColumn]
where Self: Sized;
fn from_row(row: &RowData) -> Result<Self, DocError>
where Self: Sized;
fn from_row_with_converters(
row: &RowData,
registry: &ConverterRegistry,
) -> Result<Self, DocError>
where Self: Sized;
fn to_row(&self) -> Result<Vec<CellData>, DocError>;
fn to_row_with_converters(
&self,
registry: &ConverterRegistry,
) -> Result<Vec<CellData>, DocError>;
}Expand description
Required Methods§
Sourcefn schema() -> &'static [TableColumn]where
Self: Sized,
fn schema() -> &'static [TableColumn]where
Self: Sized,
返回列 schema:表头名称、索引和格式提示。
对应 Java: ExcelProperty 注解的 value() / order() / format() 等属性
Sourcefn from_row(row: &RowData) -> Result<Self, DocError>where
Self: Sized,
fn from_row(row: &RowData) -> Result<Self, DocError>where
Self: Sized,
从原始单元格值反序列化为结构体(使用默认转换器)。
对应 Java: EasyExcel 内部通过反射将 ReadCellData 映射到字段
Sourcefn from_row_with_converters(
row: &RowData,
registry: &ConverterRegistry,
) -> Result<Self, DocError>where
Self: Sized,
fn from_row_with_converters(
row: &RowData,
registry: &ConverterRegistry,
) -> Result<Self, DocError>where
Self: Sized,
使用自定义转换器注册表从原始单元格值反序列化为结构体。
对应 Java: ConverterRegistry + ExcelProperty(converter = ...)
Sourcefn to_row(&self) -> Result<Vec<CellData>, DocError>
fn to_row(&self) -> Result<Vec<CellData>, DocError>
将自身序列化为单元格值列表(使用默认转换器)。
对应 Java: EasyExcel 内部通过反射将字段值转为 WriteCellData
Sourcefn to_row_with_converters(
&self,
registry: &ConverterRegistry,
) -> Result<Vec<CellData>, DocError>
fn to_row_with_converters( &self, registry: &ConverterRegistry, ) -> Result<Vec<CellData>, DocError>
使用自定义转换器注册表将自身序列化为单元格值列表。
对应 Java: ConverterRegistry + ExcelProperty(converter = ...)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".