MNB PHPExcelDeveloper Guide

Excel example library

Excel patterns you can put into production.

Browse focused PHP examples for reading, structured output, large files, imports, web workflows, testing, workbook generation, formulas, charts, pivots, and security.

92focused examples
21supported categories
5implementation paths
Reading11 examples
Open category →
Read XLSX rows

Read one worksheet into associative PHP rows while skipping empty records and enforcing a safe row limit.

List and select worksheets

Discover worksheet names first, then select a sheet by name instead of relying on workbook order.

Detect the header row automatically

Inspect a messy worksheet, report the likely header row and confidence, then read using semantic header detection.

Read selected rows and columns

Limit the source range and project only required worksheet columns before converting rows to PHP arrays.

Read cells, formulas, dates, and metadata

Read direct cell values, ranges, calculated formulas, typed cell details, comments, hyperlinks, and worksheet metadata.

Inspect an XLSX workbook without materializing rows

Inspect file size, encryption state, worksheet metadata, package warnings, and validation errors without converting worksheet cells into a complete PHP array.

List worksheets and inspect their dimensions

List worksheet names directly, then inspect visibility, dimensions, declared last rows and columns, and physical row-tag counts.

Find inspection metadata for one worksheet

Select one worksheet from the inspection result and read its dimensions, hidden rows and columns, merges, filters, and drawing flags.

Count rows without building a complete array

Stream normalized rows through the regular reader and count them without collecting the complete workbook result in memory.

Select an optional sheet or use the active sheet

Accept a nullable worksheet input without hiding non-empty typos, then continue with the workbook active sheet when no value was supplied.

Check for data rows before collecting an array

Evaluate normalized rows after header and empty-row options, then materialize the result only when data exists.

Structured output6 examples
Open category →
Convert a workbook with toStructuredArray()

Return workbook-level source information, every sheet, normalized columns, rows, summaries, warnings, and errors in one PHP array.

Return selected-sheet structured output

Return the structured representation for one selected worksheet without wrapping it in a workbook sheets collection.

Create flat structured rows

Flatten each structured record while retaining the original physical source row number for validation and error reporting.

Return structured JSON from an API

Serialize the full structured workbook directly to compact JSON for a controller or API endpoint without creating a temporary file.

Return structured XML from an API

Serialize structured workbook data to XML with a custom root element for integrations that do not consume JSON.

Explain total, empty, skipped, and returned row counts

Read structured sheet counts that distinguish logical row positions, physically stored records, sparse gaps, skipped empty records, the header, and final data rows.

Large files5 examples
Open category →
Imports6 examples
Open category →
Preview import quality

Inspect missing columns, unexpected columns, duplicate candidates, empty values, and sample rows before validation or database writes.

Suggest a column map

Build an import-screen mapping proposal from source headings, canonical database fields, and known aliases with confidence scores.

Validate rows and export failures

Validate imported rows with reusable rules and create a filterable XLSX containing source row numbers and human-readable errors.

Detect duplicate records

Find repeated records using one or more business-key columns and report the source row positions involved.

Import products and update by SKU

Use the built-in product schema to map aliases, normalize values, validate rows, and update existing records by SKU.

Generate a validated import template

Create a product import workbook from the same canonical field metadata used by preview and import validation.

Web workflows4 examples
Open category →
Testing3 examples
Open category →
Security4 examples
Open category →
Basic9 examples
Open category →
Create a workbook

Create an XLSX workbook from associative PHP rows and use the array keys as the header row.

Format cells (font, color, borders)

Apply header styles, range borders, alignment, fills, and number formats without converting numeric values to text.

Adjust row height and column width

Set fixed dimensions for predictable layouts and combine them with bounded automatic width calculation.

Freeze Panes

Keep headers and identifying columns visible while users scroll through a large worksheet.

Sort data

Sort the PHP rows before writing. This produces a workbook whose stored row order already matches the required business order.

Apply Filters

Add an AutoFilter range and optionally preconfigure allowed values for a column.

Find & Replace

Apply replacements to selected fields in PHP, then export the transformed rows.

Conditional Formatting

Add value rules, color scales, data bars, or icon sets to make exceptions visible in Excel.

Data Validation (Dropdown Lists)

Create a validated dropdown list for a worksheet range and provide useful input and error messages.

Formulas6 examples
Open category →
Lookup4 examples
Open category →
Text4 examples
Open category →
Date4 examples
Open category →
Math4 examples
Open category →
Tables2 examples
Open category →
Pivot2 examples
Open category →
Charts4 examples
Open category →
Data4 examples
Open category →
Dashboard3 examples
Open category →
Automation3 examples
Open category →
Printing2 examples
Open category →
Collaboration2 examples
Open category →