Core concepts
Normal vs Streaming Reads
Choose the correct read mode for memory, random access, metadata, and throughput.
ReadSession::normal()ReadSession::streaming()ReadSession::rows()ReadSession::chunks()Normal for rich access. Streaming for forward-only row work.
File extension is not the deciding factor. Choose the mode from what the application must retain, revisit, or process incrementally.
Keep workbook convenience available.
Use normal mode when the application needs random cell access or richer workbook structures such as styles, images, and metadata.
normal()cell()cellStyle()images()Move forward through records.
Use streaming when rows can be handled once, in order, and released after validation, transformation, export, or persistence.
streaming()rows()chunks()The important difference is what stays alive while the read continues.
Streaming reduces retained row data only when the underlying reader can advance without materializing the full source structure.
- 01Open the workbook
Build the structures needed for convenient workbook access.
- 02Inspect freely
Revisit cells, styles, images, and metadata as the workflow requires.
- 03Retain more state
Memory use can grow with workbook content and the structures your workflow needs.
- 01Open a forward reader
Prepare the selected worksheet for sequential processing.
- 02Yield rows or chunks
Hand records to the application as they become available.
- 03Release completed data
Keep only the current work set when the native streaming path is available.
The code should reveal whether the workflow needs random access or one-pass processing.
Keep mode selection close to the operation. A reviewer should be able to understand the memory and access intent from the pipeline itself.
$sheet = MnbExcel::read('report.xlsx')
->sheet('Summary')
->normal();
$value = $sheet->cell('D12');
$style = $sheet->cellStyle('D12');
$images = $sheet->images();$sheet = MnbExcel::read('orders.xlsx')
->sheet('Orders')
->withHeaderRow(1)
->streaming();
foreach ($sheet->chunks(1000) as $rows) {
// Validate, transform, and persist this batch.
}A streaming session can still materialize data if the terminal method asks it to.
Choose the terminal method with the same care as the read mode. Also distinguish portable fallback support from a truly bounded-memory native path.
rows()IncrementalYield rows as the application consumes them.chunks()IncrementalYield bounded batches for validation, transformation, or persistence.eachRow() / chunk()IncrementalProcess through callbacks without collecting the full result.toArray()MaterializesCollect the result in PHP memory; use intentionally for smaller outputs.