Normal vs Streaming Reads
Choose the correct read mode for memory, random access, metadata, and throughput.
Updated
ReadSession::normal()ReadSession::streaming()ReadSession::rows()ReadSession::chunks()What you will learn
- Choose mode by access pattern rather than file extension.
- Understand what “streaming” guarantees with and without native extensions.
- Avoid accidental full-workbook materialization.
Choose by the operation you need#
| Requirement | Recommended mode |
|---|---|
| Random cell access, styles, images, metadata | Normal |
| One-pass database import | Streaming |
| Preview first 25 records | Normal or streaming with limit |
| Millions of rows | Large reader / native streaming |
| Read a small configuration workbook | Normal |
Normal mode favors convenience#
$sheet = MnbExcel::read('report.xlsx')
->sheet('Summary')
->normal();
$value = $sheet->cell('D12');
$style = $sheet->cellStyle('D12');
$images = $sheet->images();Streaming mode favors one-pass processing#
$sheet = MnbExcel::read('orders.xlsx')
->sheet('Orders')
->withHeaderRow(1)
->streaming();
foreach ($sheet->chunks(1000) as $rows) {
// Validate, transform, and insert this batch.
}Watch for materializing terminal methods#
Methods such as toArray() intentionally collect rows. Prefer rows(), chunks(), eachRow(), or chunk() when the result does not need to live in memory at once.
Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue