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
21focused categories
5implementation paths
01Validate a spreadsheet uploadValidate the real uploaded file size, extension, MIME information, filename, XLSX ZIP safety, macros, links, and encryption policy.
MediumDirect API+
Validate the real uploaded file size, extension, MIME information, filename, XLSX ZIP safety, macros, links, and encryption policy.
MnbExcel::validateUpload()MnbExcel::safeFileName()<?php
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;
}02Store an AJAX spreadsheet uploadValidate and atomically store an AJAX upload, then return a safe HTTP-oriented result containing the stored path and digest.
MediumDirect API+
Validate and atomically store an AJAX upload, then return a safe HTTP-oriented result containing the stored path and digest.
MnbExcel::handleAjaxUpload()MnbExcel::storagePath()<?php
use Mnb\PHPExcel\MnbExcel;
header('Content-Type: application/json; charset=UTF-8');
$response = MnbExcel::handleAjaxUpload(
$_FILES['spreadsheet'] ?? [],
[
'directory' => __DIR__ . '/storage/uploads',
'allowed_extensions' => ['xlsx', 'xls', 'ods', 'csv', 'tsv'],
'max_size_mb' => 250,
]
);
http_response_code((int) ($response['http_status'] ?? 200));
echo json_encode($response, JSON_THROW_ON_ERROR);03Import multiple uploaded product filesProcess several uploaded product workbooks with one domain schema, shared duplicate rules, and aggregate progress reporting.
AdvancedDirect API+
Process several uploaded product workbooks with one domain schema, shared duplicate rules, and aggregate progress reporting.
MnbExcel::importDomainFiles()MnbExcel::validateUpload()<?php
use Mnb\PHPExcel\MnbExcel;
$files = [
__DIR__ . '/storage/uploads/products-east.xlsx',
__DIR__ . '/storage/uploads/products-west.xlsx',
];
$result = MnbExcel::importDomainFiles(
'products',
$files,
__DIR__ . '/config/database.php',
'products',
[
'stop_on_error' => false,
'import_options' => [
'duplicate_strategy' => 'update',
'unique_by' => ['sku'],
],
'progress' => static function (array $state): void {
printf(
"%d/%d files completed\n",
$state['files_completed'],
$state['files_total']
);
},
]
);04Queue a product importMove a long-running domain import out of the request cycle using the built-in durable filesystem queue and worker.
AdvancedDirect API+
Move a long-running domain import out of the request cycle using the built-in durable filesystem queue and worker.
MnbExcel::queue()enqueueDomainImport()work()MnbExcel::pdoQueue()<?php
use Mnb\PHPExcel\MnbExcel;
$queueDirectory = __DIR__ . '/storage/queue';
$databaseConfig = __DIR__ . '/config/database.php';
$queue = MnbExcel::queue($queueDirectory);
$job = $queue->enqueueDomainImport(
'products',
__DIR__ . '/storage/uploads/products.xlsx',
$databaseConfig,
'products',
[
'duplicate_strategy' => 'update',
'unique_by' => ['sku'],
]
);
printf("Queued job: %s\n", $job->id);
// Run this part from CLI, cron, or a process manager.
$result = $queue->work([
'max_jobs' => 20,
'max_attempts' => 3,
'retry_delay_seconds' => 30,
]);Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue