Imports
Stream Large XLSX Files into a Database
Use the optional database-XLSX integration package for bounded-memory worksheet chunks, PDO batches, resume manifests, and failed rows.
LargeExcelDatabaseImportEngine::importToSql()importWorkbookToSql()MnbExcel::largeImportToSql()Use the direct integration API#
use Mnb\PHPExcel\Large\LargeExcelDatabaseImportEngine;
$result = (new LargeExcelDatabaseImportEngine())->importToSql(
'products.xlsx',
$pdo,
'products',
[
'sheet' => 'Products',
'with_header' => true,
'chunk_size' => 2000,
'batch_size' => 500,
'duplicate_strategy' => 'update',
'unique_by' => ['sku'],
'resume' => true,
'manifest_path' => __DIR__ . '/storage/products-import.json',
'failed_rows_csv' => __DIR__ . '/storage/products-failed.csv',
]
);Use the application facade when installed#
$result = MnbExcel::largeImportToSql(
'products.xlsx',
$pdo,
'products',
[
'sheet' => 'Products',
'chunk_size' => 2000,
'batch_size' => 500,
'resume' => true,
]
);MnbExcel belongs to mnb/mnb-phpexcel; it is not available from an isolated XLSX or Database installation.
Keep the generic package independent#
Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue