Skip to main content

TableWriteBuilder

Struct TableWriteBuilder 

Source
pub struct TableWriteBuilder<'a, T>
where T: DocxRow,
{ /* private fields */ }
Expand description

将类型化 Vec<T> 写入 DOCX 表格的 Fluent 构建器。

通过门面 EasyDoc::write_table() 方法创建。

对应 Java: EasyExcel.write(path).head(RowClass.class).sheet().doWrite(data)

§示例

EasyDoc::write_table("users.docx", &users)
    .title("User List")
    .header_style(TableStyle::header())
    .do_write()?;

Implementations§

Source§

impl<'a, T> TableWriteBuilder<'a, T>
where T: DocxRow,

Source

pub fn new(path: impl Into<PathBuf>, data: &'a [T]) -> TableWriteBuilder<'a, T>

Creates a new table write builder.

Source

pub fn title(self, title: impl Into<String>) -> TableWriteBuilder<'a, T>

Sets a document title (heading above the table).

Source

pub fn need_header(self, need: bool) -> TableWriteBuilder<'a, T>

Controls whether the header row is emitted.

Source

pub fn header_style(self, style: TableStyle) -> TableWriteBuilder<'a, T>

Sets the table style.

Source

pub fn banded_rows(self, enabled: bool) -> TableWriteBuilder<'a, T>

Enables zebra striping on the table.

Source

pub fn do_write(self) -> Result<(), DocError>

Executes the write and saves the document to disk.

§Errors

Returns I/O or conversion errors.

Source

pub fn do_write_to_bytes(self) -> Result<Vec<u8>, DocError>

Executes the write and returns the document as bytes.

Useful for in-memory generation without touching the filesystem. Corresponds to Hutool’s pattern of writing to a ByteArrayOutputStream.

§Errors

Returns ZIP or conversion errors.

Source

pub fn do_write_to_writer<W>(self, writer: W) -> Result<(), DocError>
where W: Write + Seek,

Executes the write to a generic writer implementing Write + Seek.

Corresponds to Hutool’s flush(OutputStream).

§Errors

Returns I/O, ZIP, or conversion errors.

Auto Trait Implementations§

§

impl<'a, T> Freeze for TableWriteBuilder<'a, T>
where &'a [T]: Freeze,

§

impl<'a, T> RefUnwindSafe for TableWriteBuilder<'a, T>
where &'a [T]: RefUnwindSafe,

§

impl<'a, T> Send for TableWriteBuilder<'a, T>
where &'a [T]: Send,

§

impl<'a, T> Sync for TableWriteBuilder<'a, T>
where &'a [T]: Sync,

§

impl<'a, T> Unpin for TableWriteBuilder<'a, T>
where &'a [T]: Unpin,

§

impl<'a, T> UnsafeUnpin for TableWriteBuilder<'a, T>
where &'a [T]: UnsafeUnpin,

§

impl<'a, T> UnwindSafe for TableWriteBuilder<'a, T>
where &'a [T]: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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, <T as TryFrom<U>>::Error>

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.