MNB PHPExcelDeveloper Guide

Database + XLSX · Imports

Database + XLSX imports examples.

Package-local, copy-ready examples organized like the classes and methods reference. Open one example at a time, search by method, and jump from the right-side index.

Packagemnb/mnb-phpexcel-database-xlsx:^2.0Reference2 examples · 2 methods
Database + XLSX individual library

Imports examples with copy-ready, production-minded PHP.

Every snippet uses mnb/mnb-phpexcel-database-xlsx or its declared Core dependency. Each copied snippet includes strict typing, a concise summary, implementation guidance, readable limits, and a safe fixture check.

2
examples
2
documented methods
Example 01

Stream one XLSX sheet into PDO

Open related guide
LargeExcelDatabaseImportEngine::importToSql()
stream-one-xlsx-sheet-into-pdo.php
<?php

declare(strict_types=1);

/*
Summary:
    Import one named worksheet with mapping, transactions, duplicate handling, and durable failure
    output.

Implementation note:
    chunk_size controls worksheet delivery; batch_size controls prepared SQL statements. Tune them
    independently.
*/

use Mnb\PHPExcel\Large\LargeExcelDatabaseImportEngine;

$engine = new LargeExcelDatabaseImportEngine();
$result = $engine->importToSql(
    __DIR__ . '/orders.xlsx',
    $pdo,
    'orders',
    [
        'sheet' => 'Orders',
        'with_header' => true,
        'chunk_size' => 2_000,
        'batch_size' => 500,
        'transaction_per_chunk' => true,
        'duplicate_strategy' => 'update',
        'unique_by' => ['order_id'],
        'failed_rows_csv' => __DIR__ . '/storage/orders-failed.csv',
    ]
);