MNB PHPExcelDeveloper Guide
v2.0.5
Large files

Choose a Large-File Strategy

Select normal reads, streaming sessions, the large reader, or a direct database import based on workload.

Updated

LevelIntermediateReading time8 minPackagemnb/mnb-phpexcel
MnbExcel::analyzeXlsxForImport()recommendImportMethod()autoImportPlan()largeRead()

What you will learn

  • Choose an API based on row count, row width, formulas, and memory.
  • Run preflight analysis before expensive imports.
  • Know when direct database import is preferable to a row array.

Use the method advisor#

PHP
$analysis = MnbExcel::analyzeXlsxForImport('orders.xlsx');
$recommendation = MnbExcel::recommendImportMethod('orders.xlsx');
$plan = MnbExcel::autoImportPlan('orders.xlsx');

print_r($analysis);
print_r($recommendation);
print_r($plan);

Use this decision table#

WorkloadRecommended path
Small lookup/configuration workbookMnbExcel::read()->toArray()
Interactive metadata and random cellsNormal ReadSession
One-pass transformationStreaming ReadSession::rows()
Large XLSX importMnbExcel::largeRead()
Large XLSX directly to SQLlargeImportToSql()
Database-sized exportlargeExport() or largeExportFromSql()

Do not use row count alone#

A workbook with 50,000 narrow numeric rows may be cheaper than 5,000 rows containing long shared strings, rich formatting, comments, formulas, or images. Measure row width, shared-string size, sheet count, and the work performed per row.