Skip to content

Table with CSV export in WordPress

A filterable table whose visible rows export in one click to a CSV file that opens cleanly in Excel or LibreOffice.

Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in WordPress

pattern.html
<!-- wp:html -->
<section class="tec" data-tec aria-labelledby="tec-titre">
        <p class="tec-eyebrow">Plomberie Garnier · octobre 2026</p>
        <h2 class="tec-title" id="tec-titre">Interventions du mois</h2>
        <div class="tec-bar">
          <label class="tec-field">
            <span class="tec-label">Statut</span>
            <select class="tec-select" data-tec-filter>
              <option value="all">Toutes</option>
              <option value="paid">Payées</option>
              <option value="wait">En attente</option>
              <option value="late">En retard</option>
script.js
(() => {
  if (!document.querySelector(".tec")) return;
  document.querySelectorAll("[data-tec]").forEach((root) => {
    const on = (el, type, fn) => el.addEventListener(type, fn);
    const filter = root.querySelector("[data-tec-filter]");
    const status = root.querySelector("[data-tec-status]");
    const rows = Array.from(root.querySelectorAll("[data-tec-row]"));
    const header = ["Date", "Client", "Intervention", "Montant (€)", "Statut"];
    const plural = (n) => `${n} intervention${n > 1 ? "s" : ""}`;
    // Excel en français attend le point-virgule ; les guillemets sont doublés, une valeur à risque est entourée de guillemets
    const quote = (value) => (/[";\n]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value);
style.css
:root {
  --tec-card: #ffffff;
  --tec-text: #0f1f2e;
  --tec-muted: #46586a;
  --tec-line: #d6e0ea;
  --tec-accent: #1d4ed8;
  --tec-on-accent: #ffffff;
  --tec-paid-bg: #dcfce7;
  --tec-paid: #166534;
  --tec-wait-bg: #fef3c7;
  --tec-wait: #854d0e;
  --tec-late-bg: #fee2e2;
tableau-export-csv.php
<?php
/**
 * Plugin Name: Forge, Tableau avec export CSV
 * Description: Un tableau filtrable dont les lignes affichées s’exportent en un clic dans un fichier CSV qui s’ouvre proprement dans Excel ou LibreOffice. Ajoute la composition « Tableau avec export CSV » à l'éditeur de blocs.
 * Version: 1.0.0
 * Requires at least: 6.6
 * Requires PHP: 8.1
 * Author: Forge
 * License: GPL-2.0-or-later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: forge-tableau-export-csv
 *

Free component: copy it freely, including for commercial projects.

Data tables components in WordPress
  • A documentation table showing where a kit or component has been tested (static HTML, WordPress, Elementor, Webflow, v0…), with status, last test date and a remark, filterable by status.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A table of the towns and postcodes a tradesperson covers, with response time and travel fee, filtered by search and by zone.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A timetable table sorted by column and filtered with level and free-place chips, whose rows each become a card on phones.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A price table by service: one package to pick, options to tick, and the total with the estimated time recalculated on every click.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A product spec sheet as two-column tables in native collapsible sections, with a button to open or close them all.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • The results of a race or competition, sortable by place, name or category, with the podium highlighted, the gap to the winner and the sort order announced.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component