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.
Read one worksheet into associative PHP rows while skipping empty records and enforcing a safe row limit.
Discover worksheet names first, then select a sheet by name instead of relying on workbook order.
Inspect a messy worksheet, report the likely header row and confidence, then read using semantic header detection.
Limit the source range and project only required worksheet columns before converting rows to PHP arrays.
Read direct cell values, ranges, calculated formulas, typed cell details, comments, hyperlinks, and worksheet metadata.
Inspect file size, encryption state, worksheet metadata, package warnings, and validation errors without converting worksheet cells into a complete PHP array.
List worksheet names directly, then inspect visibility, dimensions, declared last rows and columns, and physical row-tag counts.
Select one worksheet from the inspection result and read its dimensions, hidden rows and columns, merges, filters, and drawing flags.
Stream normalized rows through the regular reader and count them without collecting the complete workbook result in memory.
Accept a nullable worksheet input without hiding non-empty typos, then continue with the workbook active sheet when no value was supplied.
Evaluate normalized rows after header and empty-row options, then materialize the result only when data exists.
Return workbook-level source information, every sheet, normalized columns, rows, summaries, warnings, and errors in one PHP array.
Return the structured representation for one selected worksheet without wrapping it in a workbook sheets collection.
Flatten each structured record while retaining the original physical source row number for validation and error reporting.
Serialize the full structured workbook directly to compact JSON for a controller or API endpoint without creating a temporary file.
Serialize structured workbook data to XML with a custom root element for integrations that do not consume JSON.
Read structured sheet counts that distinguish logical row positions, physically stored records, sparse gaps, skipped empty records, the header, and final data rows.
Inspect workbook size, rows, columns, risk, server limits, and the recommended normal or streaming import path before processing.
Process a large worksheet in bounded-memory chunks and persist each chunk immediately instead of collecting the workbook in one array.
Reduce parsing and downstream work by projecting worksheet columns while preserving identifiers and converting Excel dates.
Generate a database-sized XLSX from an iterable while reporting progress and avoiding a full in-memory workbook model.
Stream, validate, batch-insert, record failed rows, checkpoint progress, and resume an interrupted large database import.
Inspect missing columns, unexpected columns, duplicate candidates, empty values, and sample rows before validation or database writes.
Build an import-screen mapping proposal from source headings, canonical database fields, and known aliases with confidence scores.
Validate imported rows with reusable rules and create a filterable XLSX containing source row numbers and human-readable errors.
Find repeated records using one or more business-key columns and report the source row positions involved.
Use the built-in product schema to map aliases, normalize values, validate rows, and update existing records by SKU.
Create a product import workbook from the same canonical field metadata used by preview and import validation.
Validate the real uploaded file size, extension, MIME information, filename, XLSX ZIP safety, macros, links, and encryption policy.
Validate and atomically store an AJAX upload, then return a safe HTTP-oriented result containing the stored path and digest.
Process several uploaded product workbooks with one domain schema, shared duplicate rules, and aggregate progress reporting.
Move a long-running domain import out of the request cycle using the built-in durable filesystem queue and worker.
Validate package relationships, required parts, content types, and XML after generating a workbook.
Write a fixture workbook, read it back through the public reader, and assert that identifiers and values survive the complete XLSX path.
Report whether the PHP runtime has the extensions and optional capabilities required by the application workflow.
Scan untrusted rows for formula-like text, escape dangerous CSV cells, and block risky explicit formulas before writing.
Detect encrypted Office containers and protect or recover an XLSX package with an application-supplied password.
Apply worksheet editing restrictions while keeping the file readable.
Protect workbook structure and optionally encrypt the entire file with a password to open.
Create an XLSX workbook from associative PHP rows and use the array keys as the header row.
Apply header styles, range borders, alignment, fills, and number formats without converting numeric values to text.
Set fixed dimensions for predictable layouts and combine them with bounded automatic width calculation.
Keep headers and identifying columns visible while users scroll through a large worksheet.
Sort the PHP rows before writing. This produces a workbook whose stored row order already matches the required business order.
Add an AutoFilter range and optionally preconfigure allowed values for a column.
Apply replacements to selected fields in PHP, then export the transformed rows.
Add value rules, color scales, data bars, or icon sets to make exceptions visible in Excel.
Create a validated dropdown list for a worksheet range and provide useful input and error messages.
Write a SUM formula as a typed cell value. A cached result keeps previews useful before Excel recalculates.
Calculate the average of a numeric range and store a cached result for non-calculating viewers.
Use COUNT for numeric cells and COUNTA for all non-empty cells.
Generate row-level status values from a condition.
Combine several business conditions in a single formula.
Return a friendly fallback when a lookup or calculation produces an Excel error.
Look up a key in the first column of a vertical table and return a value from another column.
Look up a value in the first row of a horizontal table.
Use a modern exact lookup that separates the lookup range from the return range and supports a not-found value.
Combine MATCH to find a row and INDEX to return a value from a separate column.
Extract fixed portions of identifiers and codes with Excel text formulas.
Combine cell values with or without a delimiter.
Remove leading, trailing, and repeated internal spaces from imported text.
Replace matching text or replace characters at a known position.
Insert the current date as a volatile Excel formula and apply a date number format.
Insert the current date and time as a volatile Excel formula.
Calculate elapsed years, months, or days between two dates.
Return the last day of a month before or after a supplied date.
Use a trusted XLSX template when a native Excel table object, table style, totals row, or filtering behavior must be retained.
Keep a named Excel table in a template and write formulas that use its structured references.
Create a native column chart from category and value ranges.
Plot a sequence over time as a native line chart.
Create a pie chart for a small set of mutually exclusive categories.
Preserve a trusted template when one chart must combine different chart types or use a secondary axis.
Deduplicate rows by a stable business key before generating the workbook.
Split a delimited source field into independent workbook columns.
Reproduce a predictable Flash Fill transformation in PHP so the rule is explicit and testable.
Build a repeatable PHP ETL pipeline that reads source data, transforms it, and writes a clean XLSX output.
Build a dashboard worksheet from summary rows, KPI formulas, styles, and several native charts.
Preserve slicers from a trusted pivot-table template and replace the source data safely.
Preserve an existing pivot timeline from a trusted template and rebind its pivot source range.
Use Excel to record the macro in a trusted .xlsm template; PHP supplies fresh data without running the macro.
Edit VBA in Excel or a dedicated VBA tool, then preserve the approved macro project while refreshing workbook data.
Create the VBA UserForm in a trusted macro-enabled template and preserve it while replacing worksheet data.