exports-xlsx

Generate styled Excel .xlsx exports in Laravel using ZipArchive and hand-written OOXML.

Updated May 5, 2025
One-click install
npx skills add https://github.com/sebauvray/toollab-api --skill exports-xlsx-sebauvray
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: exports-xlsx
Source: https://github.com/sebauvray/toollab-api/tree/main/.claude/skills/exports-xlsx
Command: npx skills add https://github.com/sebauvray/toollab-api --skill exports-xlsx-sebauvray

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Creating Excel exports in the Toollab Laravel application without adding composer dependencies, while guaranteeing formula-injection safety, consistent styling, and identical filters between on-screen lists and exported files. ## Core Features & Use Cases - Dependency-free .xlsx generation: ExportService::xlsx() assembles a real OOXML archive with ZipArchive, producing frozen header rows, autofilters, alternating row colors, and auto-sized columns. - Formula injection protection: all text is written as inlineStr and escaped, so values like =cmd|... are never interpreted by Excel; numbers must be cast to int/float to stay numeric. - Full-stack export recipe: backend controller pattern reusing the list query builder, plus Nuxt wiring with ExportButton, blob downloads via apiClient, saveExport date-suffixed filenames, and director/admin role gating. - Use Case: Add a new admin export for payments by mapping Eloquent results to rows, calling ExportService::xlsx('paiements', $headers, $rows), and connecting an ExportButton on the statistics page. ## Quick Start Ask the AI to add a new Excel export endpoint for a Toollab resource and wire the ExportButton on the corresponding Nuxt page.

Frequently Asked Questions about exports-xlsx

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate an Excel .xlsx file in Laravel without composer packages?▼

Use ZipArchive to assemble the OOXML parts manually: [Content_Types].xml, workbook.xml, styles.xml, and sheet1.xml. Write text cells as inlineStr and numbers as plain <v> values, then return the archive via response()->download()->deleteFileAfterSend(true).

How to prevent Excel formula injection in exported spreadsheets?▼

Write all string values as inlineStr cells instead of formula elements, so values starting with = are treated as plain text. Additionally strip control characters and apply htmlspecialchars with ENT_QUOTES and ENT_XML1 flags before embedding values in the XML.

Why does Excel say my generated xlsx file is corrupted?▼

Corruption usually comes from malformed XML: unfiltered control characters, NAN or INF numeric values, decimals written with a locale-dependent comma, or mismatched column counts between headers and rows. Unzip the file and validate sheet1.xml with xmllint to locate the error.

Why are my exported numbers left-aligned and not summable in Excel?▼

Numbers passed as PHP strings are written as inlineStr text cells, which Excel left-aligns and excludes from sums. Cast amounts to int or float before building rows so they are emitted as numeric cells.

How do I download an xlsx export from a Nuxt frontend with authentication?▼

Call the export endpoint with responseType 'blob' through the shared apiClient so auth tokens and school headers are injected automatically. Then pass the blob to a saveExport helper that appends the current date and triggers the browser download.

When should I use openspout instead of hand-written OOXML for Excel files?▼

In this codebase openspout is reserved for reading files during family imports, not writing exports. The hand-written ZipArchive approach is preferred for exports because it is styled, tested, and avoids dependency lock regressions.