Stream Large Exports
Write database-sized XLSX or partitioned CSV ZIP exports without building a complete workbook in memory.
Updated
MnbExcel::largeExport()largeExportFromSql()LargeXlsxWriteSession::save()saveCsvZip()What you will learn
- Export from generators or PDO cursors.
- Split sheets before Excel row limits.
- Use CSV ZIP when table volume is more important than workbook formatting.
Export a generator#
MnbExcel::largeExport($rowGenerator)
->sheetName('Orders')
->withHeader()
->freezeHeader()
->autoFilter()
->formatColumn('Amount', 'currency')
->autoSplitSheets(true)
->progress($progressCallback, 5000)
->save('orders.xlsx');Export directly from SQL#
MnbExcel::largeExportFromSql(
$pdo,
'SELECT id, customer, amount, created_at FROM orders ORDER BY id'
)
->formatColumn('amount', 'decimal')
->save('orders.xlsx');Use partitioned CSV ZIP for extreme table exports#
MnbExcel::largeExport($rowGenerator)
->withHeader()
->csvRowsPerFile(500000)
->saveCsvZip('orders-parts.zip');CSV ZIP sacrifices styles, images, formulas, and workbook objects in exchange for simple, scalable table delivery.
Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue