Skip to main content

StreamWriter

Struct StreamWriter 

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

A streaming worksheet writer that writes rows sequentially.

Rows must be written in ascending order. The StreamWriter builds Row structs directly, then assembles them into a WorksheetXml on finish.

Implementations§

Source§

impl StreamWriter

Source

pub fn new(sheet_name: &str) -> Self

Create a new StreamWriter for the given sheet name.

Source

pub fn sheet_name(&self) -> &str

Get the sheet name.

Source

pub fn set_col_width(&mut self, col: u32, width: f64) -> Result<()>

Set column width for a single column (1-based). Must be called before any write_row() calls.

Source

pub fn set_col_width_range( &mut self, min_col: u32, max_col: u32, width: f64, ) -> Result<()>

Set column width for a range (min_col..=max_col), both 1-based. Must be called before any write_row() calls.

Source

pub fn set_col_style(&mut self, col: u32, style_id: u32) -> Result<()>

Set column style for a single column (1-based). Must be called before any write_row() calls.

Source

pub fn set_col_visible(&mut self, col: u32, visible: bool) -> Result<()>

Set column visibility for a single column (1-based). Must be called before any write_row() calls.

Source

pub fn set_col_outline_level(&mut self, col: u32, level: u8) -> Result<()>

Set column outline level for a single column (1-based). Must be called before any write_row() calls. Level must be 0-7.

Source

pub fn set_freeze_panes(&mut self, top_left_cell: &str) -> Result<()>

Set freeze panes for the streamed sheet. Must be called before any write_row() calls. top_left_cell is the cell below and to the right of the frozen area, e.g., “A2” freezes row 1, “B1” freezes column A, “C3” freezes rows 1-2 and columns A-B.

Source

pub fn write_row_with_options( &mut self, row: u32, values: &[CellValue], options: &StreamRowOptions, ) -> Result<()>

Write a row of values with row-level options.

Source

pub fn write_row(&mut self, row: u32, values: &[CellValue]) -> Result<()>

Write a row of values. Rows must be written in ascending order. Row numbers are 1-based.

Source

pub fn write_row_with_style( &mut self, row: u32, values: &[CellValue], style_id: u32, ) -> Result<()>

Write a row with a specific style ID applied to all cells.

Source

pub fn add_merge_cell(&mut self, reference: &str) -> Result<()>

Add a merge cell reference (e.g., “A1:B2”). Must be called before finish(). The reference must be a valid range in the form “A1:B2”.

Source

pub fn finish(&mut self) -> Result<Vec<u8>>

Finish writing and return the complete worksheet XML bytes.

Source

pub fn sst(&self) -> &SharedStringTable

Get a reference to the shared string table.

Source

pub fn into_parts(self) -> Result<(Vec<u8>, SharedStringTable)>

Consume the writer and return (xml_bytes, shared_string_table).

Source

pub fn into_worksheet_parts(self) -> Result<(WorksheetXml, SharedStringTable)>

Consume the writer and return the worksheet XML struct and shared string table. This is the optimized path that avoids XML serialization/deserialization.

Trait Implementations§

Source§

impl Debug for StreamWriter

Source§

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

Formats the value using the given formatter. Read more

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 = Infallible

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.