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
impl StreamingReader
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
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 rowsSourcepub fn sheet_names(&self) -> Vec<String>
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);
}Sourcepub fn rows_by_index(
&mut self,
sheet_index: usize,
) -> Result<RowStructIterator<'_>>
pub fn rows_by_index( &mut self, sheet_index: usize, ) -> Result<RowStructIterator<'_>>
Sourcepub fn dimensions(&mut self, sheet_name: &str) -> Result<(usize, usize)>
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.
Sourcepub fn stream_rows(&mut self, sheet_name: &str) -> Result<RowIterator<'_>>
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);
}Sourcepub fn rows(&mut self, sheet_name: &str) -> Result<RowStructIterator<'_>>
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§
impl Freeze for StreamingReader
impl RefUnwindSafe for StreamingReader
impl Send for StreamingReader
impl Sync for StreamingReader
impl Unpin for StreamingReader
impl UnsafeUnpin for StreamingReader
impl UnwindSafe for StreamingReader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more