Skip to main content

StreamingReader

Struct StreamingReader 

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

Streaming reader for XLSX files

Memory Usage:

  • SST (Shared Strings): Loaded fully (typically 3-5 MB)
  • Worksheet XML: Loaded from ZIP (uncompressed size)
  • Total ≈ SST + Uncompressed XML size

Performance:

  • 60K-85K rows/sec depending on file size
  • Faster than calamine (no style/format parsing)
  • Optimized hybrid SST

Best for:

  • Small to medium files (< 100 MB compressed)
  • Files with small SST but many rows
  • Simple data extraction without formatting

Implementations§

Source§

impl StreamingReader

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Open XLSX file for streaming read

§Memory Usage
  • Loads SST (Shared Strings Table) fully into memory
  • Worksheet data loaded as single XML string (uncompressed size)
  • For 86 MB file: May use ~1.2 GB if XML is large
  • For smaller files (< 50 MB): Usually reasonable memory
§Performance
  • Fast: 60K-85K rows/sec
  • No style/format parsing overhead
  • Optimized for simple data extraction
§Example
use excelstream::streaming_reader::StreamingReader;

let reader = StreamingReader::open("large.xlsx")?;
// SST loaded, ready to stream rows
Source

pub fn sheet_names(&self) -> Vec<String>

Get list of sheet names

Returns the names of all worksheets in the workbook.

§Example
use excelstream::ExcelReader;

let reader = ExcelReader::open("workbook.xlsx")?;
for sheet_name in reader.sheet_names() {
    println!("Sheet: {}", sheet_name);
}
Source

pub fn rows_by_index( &mut self, sheet_index: usize, ) -> Result<RowStructIterator<'_>>

Read rows by sheet index (for backward compatibility)

§Arguments
  • sheet_index - Zero-based sheet index (0 = first sheet)
§Returns

Iterator of Row structs

Source

pub fn dimensions(&mut self, sheet_name: &str) -> Result<(usize, usize)>

Get worksheet dimensions (rows, columns) - for backward compatibility

§Note

This is a simplified implementation that reads all rows to count them. Returns (row_count, max_column_count). For large files, this can be slow as it needs to iterate through all rows.

Source

pub fn stream_rows(&mut self, sheet_name: &str) -> Result<RowIterator<'_>>

Stream rows from a worksheet

§Memory Usage
  • Loads worksheet XML fully from ZIP (uncompressed)
  • Processes rows with iterator (appears as streaming)
  • Memory = SST + Full worksheet XML
§Performance
  • Returns iterator for row-by-row processing
  • Fast iteration: 60K-85K rows/sec
  • No style/format overhead
§Example
  • Does NOT load entire worksheet into memory
  • SST already loaded in open()
§Example
use excelstream::streaming_reader::StreamingReader;

let mut reader = StreamingReader::open("large.xlsx")?;
for row in reader.stream_rows("Sheet1")? {
    let row = row?;
    println!("Row: {:?}", row);
}
Source

pub fn rows(&mut self, sheet_name: &str) -> Result<RowStructIterator<'_>>

Alias for stream_rows() for backward compatibility

This method provides the same functionality as stream_rows() but uses the more familiar rows() name that matches the old calamine-based API. Returns an iterator of Row structs for full API compatibility.

§Example
use excelstream::ExcelReader;

let mut reader = ExcelReader::open("large.xlsx")?;
for row_result in reader.rows("Sheet1")? {
    let row = row_result?;
    println!("Row {}: {:?}", row.index, row.to_strings());
}

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.