Skip to main content

ColumnDef

Struct ColumnDef 

Source
pub struct ColumnDef {
    pub header: String,
    pub aliases: Vec<String>,
    pub required: bool,
    pub kind: ColumnKind,
    pub width: Option<f64>,
    pub format: Option<String>,
    pub text_format: bool,
    pub image: bool,
    pub ignore: bool,
    pub default: Option<String>,
    pub note: Option<String>,
    pub dropdown: Vec<String>,
}
Expand description

列定义

Fields§

§header: String

标准表头(模板/导出使用)

§aliases: Vec<String>

别名(动态表头适配:历史模板改过列名的场景)

§required: bool

必填

§kind: ColumnKind

语义类型

§width: Option<f64>

导出列宽

§format: Option<String>

导出数值格式(如 #,##0.00、yyyy-mm-dd)

§text_format: bool

导出是否按文本格式写(@)

§image: bool

是否图片列

§ignore: bool

导入时忽略(仅参与模板/导出展示)

§default: Option<String>

空值默认值(模板示例行与导入兜底)

§note: Option<String>

模板备注(写入说明 sheet)

§dropdown: Vec<String>

模板下拉选项(数据验证)

Implementations§

Source§

impl ColumnDef

Source

pub fn new(header: impl Into<String>) -> Self

Source

pub fn alias(self, alias: impl Into<String>) -> Self

Source

pub fn aliases<I, S>(self, list: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Source

pub fn required(self) -> Self

Source

pub fn optional(self) -> Self

Source

pub fn kind(self, kind: ColumnKind) -> Self

Source

pub fn width(self, width: f64) -> Self

Source

pub fn format(self, format: impl Into<String>) -> Self

Source

pub fn as_text(self) -> Self

文本格式(长数字、手机号、编码类字段)

Source

pub fn image(self) -> Self

Source

pub fn ignore(self) -> Self

Source

pub fn default_value(self, value: impl Into<String>) -> Self

Source

pub fn note(self, note: impl Into<String>) -> Self

Source

pub fn dropdown<I, S>(self, list: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Source

pub fn names(&self) -> impl Iterator<Item = &str>

表头 + 别名(动态匹配用)

Source

pub fn is_importable(&self) -> bool

是否参与导入解析

Source

pub fn mark_required(&self) -> bool

该列是否需要在模板里标红(必填)

Trait Implementations§

Source§

impl Clone for ColumnDef

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 ColumnDef

Source§

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

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

impl From<&str> for ColumnDef

Source§

fn from(header: &str) -> Self

Converts to this type from the input type.
Source§

impl From<(&str, ColumnKind)> for ColumnDef

Source§

fn from((header, kind): (&str, ColumnKind)) -> Self

Converts to this type from the input type.
Source§

impl From<String> for ColumnDef

Source§

fn from(header: String) -> Self

Converts to this type from the input type.

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.