Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsJun 1, 2026·2 min de lectura

PhpSpreadsheet — Read and Write Spreadsheet Files in Pure PHP

PhpSpreadsheet is a library for reading, creating, and writing spreadsheet documents in PHP, supporting formats including Excel (XLSX/XLS), LibreOffice Calc (ODS), CSV, and PDF export.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
PhpSpreadsheet Overview
Comando de instalación directa
npx -y tokrepo@latest install f8a8f77f-5d4f-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

Introduction

PhpSpreadsheet is the successor to PHPExcel and provides a comprehensive set of classes for working with spreadsheet files in PHP. It handles reading existing files, creating new spreadsheets programmatically, and writing output in multiple formats without requiring any external office software.

What PhpSpreadsheet Does

  • Reads and writes XLSX, XLS, ODS, CSV, HTML, and SYLK file formats
  • Supports cell formatting including fonts, colors, borders, and number formats
  • Handles formulas with a built-in calculation engine
  • Generates charts embedded in spreadsheet files
  • Exports spreadsheets to PDF via multiple rendering backends

Architecture Overview

The library follows an object-oriented design with a central Spreadsheet object containing Worksheet objects, each holding Cell objects. Readers and Writers are format-specific implementations that serialize and deserialize this object model. The calculation engine evaluates cell formulas using a recursive descent parser.

Self-Hosting & Configuration

  • Install via Composer as a project dependency
  • Requires PHP 8.1 or higher with ext-xml and ext-zip extensions
  • Optional ext-gd or ext-imagick for image handling in spreadsheets
  • Configure memory limits in php.ini for large spreadsheets
  • Use chunk reading for processing files that exceed available memory

Key Features

  • Full formula support with 400+ built-in functions
  • Cell merging, conditional formatting, and data validation
  • Auto-filter, freeze panes, and print area configuration
  • Reading and writing password-protected XLSX files
  • Streaming writer for generating large files with low memory usage

Comparison with Similar Tools

  • Laravel Excel (Maatwebsite) — Wrapper around PhpSpreadsheet with Laravel integration
  • box/spout (OpenSpout) — Faster streaming reader/writer but fewer features
  • PhpExcel — Predecessor library, now deprecated in favor of PhpSpreadsheet
  • Python openpyxl — Similar capabilities but for the Python ecosystem
  • Apache POI — Java equivalent with broader format support

FAQ

Q: How does PhpSpreadsheet handle large files? A: Use the chunk reading filter to process files in segments, or use the streaming Xlsx writer (Xlsxwriter) for low-memory output generation.

Q: Can I use it without Laravel? A: Yes. PhpSpreadsheet is framework-agnostic and works in any PHP project via Composer.

Q: Does it support Excel macros? A: It can preserve macros in XLSM files but cannot execute or create VBA code.

Q: What is the maximum file size it can handle? A: There is no hard limit, but practical limits depend on available PHP memory. The streaming writer can generate files of any size.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados