Skip to content
MNB PHPExcelDeveloper Guide
AI

DB + XLSX library

Resume, Progress, and Failed Rows

Persist large XLSX import checkpoints, resume safely, report invalid source rows, and design idempotent replay behavior.

Level
Advanced
Reading time
10 min
Package
mnb/mnb-phpexcel-database-xlsx
Updated
LargeImportManifestLargeFailedRowsCsvWriterprogress

Make replay safe#

  • Create a stable database unique index for the business key.
  • Use duplicate_strategy=skip or update when replay is possible.
  • Keep the source workbook unchanged while its manifest remains active.
  • Store the manifest and failed-row CSV outside the public web root.
  • Delete or archive the manifest only after the import is conclusively complete.

Use progress as observability#

PHP
$result = $engine->importToSql($path, $pdo, 'orders', [
    'progress' => static function (array $state): void {
        printf(
            "Rows: %d | Inserted: %d | Failed: %d\n",
            $state['rows_scanned'] ?? 0,
            $state['inserted_rows'] ?? 0,
            $state['failed_rows'] ?? 0,
        );
    },
]);

Preserve original row numbers#

The integration keeps physical worksheet row numbers in validation and failed-row output so uploaders can correct the exact row in the source workbook.