MNB PHPExcelDeveloper Guide

Web workflows examples

Web workflows 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.

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

Web workflows 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.

4
examples
9
documented methods
Example 01

Validate a spreadsheet upload

MnbExcel::validateUpload()MnbExcel::safeFileName()
validate-a-spreadsheet-upload.php
<?php

declare(strict_types=1);

/*
Summary:
    Validate the real uploaded file size, extension, MIME information, filename, XLSX ZIP safety,
    macros, links, and encryption policy.

Implementation note:
    Validation does not move the file. Store it under a generated server-side name only after the
    upload passes policy checks.
*/

use Mnb\PHPExcel\MnbExcel;

$upload = MnbExcel::validateUpload($_FILES['spreadsheet'] ?? [], [
    'allowed_extensions' => ['xlsx', 'csv', 'tsv'],
    'max_size_mb' => 100,
    'reject_macros' => true,
    'reject_external_links' => true,
    'reject_encrypted' => true,
]);

if (!$upload['valid']) {
    http_response_code(422);
    header('Content-Type: application/json');
    echo json_encode($upload, JSON_THROW_ON_ERROR);
    exit;
}