Progress, Checkpoints, and Failed Rows
Expose reliable progress, choose row-error behavior, and make long imports resumable.
Updated
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#
$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#
| Policy | Behavior |
|---|---|
throw | Stop immediately; best for strict pipelines. |
skip | Continue without retaining failed-row details. |
collect | Continue and retain structured row errors. |
| Callback | Inspect the exception and optionally replace the row. |
Persist failed rows and manifests#
$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#
$result = MnbExcel::resumeImport(
__DIR__ . '/storage/imports/products.manifest.json',
$pdo
);Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue