MNB PHPExcelDeveloper Guide

Large files examples

Large files Excel examples, explained clearly.

Open a focused example to see the implementation path, copy-ready PHP, expected workbook behavior, and the production boundary that matters.

5examples in this category
21supported categories
5implementation paths
Monolithic library

Large files examples with copy-ready, production-minded PHP.

Each example identifies the exact methods it uses and can be opened independently from the right-side index.

5
examples
15
documented methods
Example 01

Analyze an XLSX before importing

MnbExcel::analyzeXlsxForImport()MnbExcel::recommendImportMethod()MnbExcel::autoImportPlan()
analyze-an-xlsx-before-importing.php
<?php

declare(strict_types=1);

/*
Summary:
    Inspect workbook size, rows, columns, risk, server limits, and the recommended normal or
    streaming import path before processing.

Implementation note:
    Preflight unknown uploads instead of guessing from file size alone. The recommendation accounts
    for workbook dimensions, feature complexity, and the current server profile.
*/

use Mnb\PHPExcel\MnbExcel;

$workbookPath = __DIR__ . '/fixtures/large-orders.xlsx';

if (!is_file($workbookPath)) {
    throw new RuntimeException(sprintf('Workbook not found: %s', $workbookPath));
}

$plan = MnbExcel::autoImportPlan(
    $workbookPath,
    [
        'server' => 'shared',
        'memory_limit' => '256M',
        'max_execution_time' => 30,
    ],
    [
        'accurate_row_count' => true,
        'scan_features' => true,
        'time_budget_seconds' => 20,
    ]
);

print_r([
    'method' => $plan['selected_method'],
    'chunk_size' => $plan['chunk_size'],
    'route' => $plan['route'],
    'rows' => $plan['profile']['total_rows'],
    'risk' => $plan['profile']['risk'],
]);