MNB PHPExcelDeveloper Guide
Large files

Progress, Checkpoints, and Failed Rows

Expose reliable progress, choose row-error behavior, and make long imports resumable.

Updated

Full packageIndividual XLSXProgressResume
LevelAdvancedReading time12 minPackagemnb/mnb-phpexcel
withProgress()onRowError()rowStates()rowErrors()resumeImport()

What you will learn

  • Report progress without counting the entire workbook twice.
  • Choose between throw, skip, collect, and callback policies.
  • Persist enough state to resume database imports.

Use progress as observed work, not a promise#

PHP
$options = ReaderOptions::defaults()->withProgress(
    function ($progress): void {
        printf(
            "Sheet %s: %d rows read\n",
            $progress->sheet,
            $progress->rowsRead
        );
    },
    everyRows: 1000
);

A precise percentage requires a trustworthy total. For streaming uploads, report rows processed and phase information when a total is unknown.

Choose a row-error policy#

PolicyBehavior
throwStop immediately; best for strict pipelines.
skipContinue without retaining failed-row details.
collectContinue and retain structured row errors.
CallbackInspect the exception and optionally replace the row.

Persist failed rows and manifests#

PHP
$result = MnbExcel::largeImportToSql($path, $pdo, 'products', [
    'batch_size' => 1000,
    'failed_rows_csv' => __DIR__ . '/storage/imports/failed-products.csv',
    'manifest_path' => __DIR__ . '/storage/imports/products.manifest.json',
]);

Resume an interrupted import#

PHP
$result = MnbExcel::resumeImport(
    __DIR__ . '/storage/imports/products.manifest.json',
    $pdo
);