DB + XLSX library
Stream Large XLSX Rows into PDO
Import one worksheet or a workbook map in bounded-memory chunks with validation, mapping, transactions, progress, and duplicate handling.
LargeExcelDatabaseImportEngine::importToSql()importWorkbookToSql()Stream one sheet into a table#
use Mnb\PHPExcel\Large\LargeExcelDatabaseImportEngine;
$engine = new LargeExcelDatabaseImportEngine();
$result = $engine->importToSql('orders.xlsx', $pdo, 'orders', [
'sheet' => 'Orders',
'with_header' => true,
'chunk_size' => 2000,
'batch_size' => 500,
'transaction_per_chunk' => true,
'duplicate_strategy' => 'update',
'unique_by' => ['order_id'],
'manifest_path' => __DIR__ . '/storage/orders-import.json',
'failed_rows_csv' => __DIR__ . '/storage/orders-failed.csv',
'resume' => true,
]);Import multiple worksheets#
$result = $engine->importWorkbookToSql(
'erp-export.xlsx',
$pdo,
[
'Customers' => 'customers',
'Orders' => 'orders',
'Order Lines' => 'order_lines',
],
[
'chunk_size' => 1000,
'resume' => true,
]
);Separate chunk size from SQL batch size#
chunk_size controls how many worksheet rows are delivered to one orchestration cycle. batch_size controls prepared SQL insertion batches. Tune them independently based on row width, validation cost, transaction duration, and database limits.
Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue