pub struct StreamWriter { /* private fields */ }Expand description
A streaming worksheet writer that writes rows directly to a temp file.
Rows must be written in ascending order. Each row is serialized to XML and written to a temporary file immediately, keeping memory usage constant regardless of the number of rows.
Implementations§
Source§impl StreamWriter
impl StreamWriter
Sourcepub fn new(sheet_name: &str) -> StreamWriter
pub fn new(sheet_name: &str) -> StreamWriter
Create a new StreamWriter for the given sheet name.
Sourcepub fn sheet_name(&self) -> &str
pub fn sheet_name(&self) -> &str
Get the sheet name.
Sourcepub fn set_col_width(&mut self, col: u32, width: f64) -> Result<(), Error>
pub fn set_col_width(&mut self, col: u32, width: f64) -> Result<(), Error>
Set column width for a single column (1-based). Must be called before any write_row() calls.
Sourcepub fn set_col_width_range(
&mut self,
min_col: u32,
max_col: u32,
width: f64,
) -> Result<(), Error>
pub fn set_col_width_range( &mut self, min_col: u32, max_col: u32, width: f64, ) -> Result<(), Error>
Set column width for a range (min_col..=max_col), both 1-based. Must be called before any write_row() calls.
Sourcepub fn set_col_style(&mut self, col: u32, style_id: u32) -> Result<(), Error>
pub fn set_col_style(&mut self, col: u32, style_id: u32) -> Result<(), Error>
Set column style for a single column (1-based). Must be called before any write_row() calls.
Sourcepub fn set_col_visible(&mut self, col: u32, visible: bool) -> Result<(), Error>
pub fn set_col_visible(&mut self, col: u32, visible: bool) -> Result<(), Error>
Set column visibility for a single column (1-based). Must be called before any write_row() calls.
Sourcepub fn set_col_outline_level(
&mut self,
col: u32,
level: u8,
) -> Result<(), Error>
pub fn set_col_outline_level( &mut self, col: u32, level: u8, ) -> Result<(), Error>
Set column outline level for a single column (1-based). Must be called before any write_row() calls. Level must be 0-7.
Sourcepub fn set_freeze_panes(&mut self, top_left_cell: &str) -> Result<(), Error>
pub fn set_freeze_panes(&mut self, top_left_cell: &str) -> Result<(), Error>
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.
Sourcepub fn write_row_with_options(
&mut self,
row: u32,
values: &[CellValue],
options: &StreamRowOptions,
) -> Result<(), Error>
pub fn write_row_with_options( &mut self, row: u32, values: &[CellValue], options: &StreamRowOptions, ) -> Result<(), Error>
Write a row of values with row-level options.
Sourcepub fn write_row(&mut self, row: u32, values: &[CellValue]) -> Result<(), Error>
pub fn write_row(&mut self, row: u32, values: &[CellValue]) -> Result<(), Error>
Write a row of values. Rows must be written in ascending order. Row numbers are 1-based.
Sourcepub fn write_rows(
&mut self,
start_row: u32,
rows: &[Vec<CellValue>],
) -> Result<(), Error>
pub fn write_rows( &mut self, start_row: u32, rows: &[Vec<CellValue>], ) -> Result<(), Error>
Write multiple rows of values starting at the given row number.
Each element in the slice becomes a row. Rows are numbered consecutively
from start_row. All rows must be in ascending order relative to any
previously written row.
Sourcepub fn write_row_with_style(
&mut self,
row: u32,
values: &[CellValue],
style_id: u32,
) -> Result<(), Error>
pub fn write_row_with_style( &mut self, row: u32, values: &[CellValue], style_id: u32, ) -> Result<(), Error>
Write a row with a specific style ID applied to all cells.
Sourcepub fn add_merge_cell(&mut self, reference: &str) -> Result<(), Error>
pub fn add_merge_cell(&mut self, reference: &str) -> Result<(), Error>
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”.
Sourcepub fn into_streamed_data(self) -> Result<(String, StreamedSheetData), Error>
pub fn into_streamed_data(self) -> Result<(String, StreamedSheetData), Error>
Consume the writer and return a StreamedSheetData containing the
temp file and pre-built XML fragments for the worksheet header/footer.