Excel Export Plugin for Cotonti CMF

"Excel Export" allows you to securely export data from any database table to Excel (XLSX). Field selection, custom headers, row limit, work without Composer, PHP 8.4 support

Excel Export Plugin for Cotonti CMF

Professional Overview, Architecture, and Practical Guide

Introduction

The Excel Export plugin is a controlled solution — a tool for exporting data from any database table in Cotonti directly into Microsoft Excel format (XLSX), convenient for analysis or data sharing, using traditional file formats.

This plugin is designed for administrative use and is intended for developers, site administrators, and technical specialists who need regular or one-time export of structured data without involving external scripts or direct database access.


Purpose of the Plugin

The main purpose of the Excel Export plugin is to export data from a specified Cotonti CMF database table into an Excel file with the ability to:

  • select specific table fields;
  • assign custom column names in Excel;
  • limit the number of exported rows;
  • re-download previously generated files;
  • work without Composer and without dependency on system autoloaders.

The plugin does not handle data import, does not modify table structures, and does not interfere with the business logic of Cotonti modules. It operates strictly in read-only mode.


Compatibility and Requirements

The plugin excel_export has been developed and tested in the following environment:

  • Cotonti CMF version 0.9.26
  • PHP version 8.4 and higher
  • MySQL version 8.0
  • PhpSpreadsheet version 1.23.0, included locally, without Composer

The use of third-party libraries is implemented through custom autoloaders, making the plugin self-contained and independent of the project's global configuration.


Plugin Architecture

The plugin consists of several logically separated components, each responsible for a distinct part of the functionality.

Configuration and Installation Level

The installation file registers the plugin in the Cotonti system, describes its metadata, and declares configuration parameters. The key parameters are:

  • target database table from which the export will be performed;
  • maximum number of rows to export in a single operation.

These parameters are set through the standard Cotonti plugin configuration interface and are used throughout all subsequent stages of operation.


Functional Level: Data Export

The core export logic is concentrated in a separate functional file, following good separation-of-concerns practice.

At this level the following are implemented:

  • initialization of paths to third-party libraries;
  • custom autoloaders for PhpSpreadsheet and its dependencies;
  • centralized logging system;
  • function that performs the complete data export cycle.

Export is implemented as a sequential process: from input data validation to physical saving of the XLSX file on the server.


Library Autoloading

The plugin does not use Composer and does not rely on system autoloaders. Instead, it implements several specialized autoloaders for:

  • PhpSpreadsheet;
  • PSR Simple Cache interfaces;
  • ZipStream;
  • MyCLabs Enum.

This approach guarantees:

  • predictable class loading;
  • absence of conflicts with other plugins;
  • ability to use the plugin in environments with restricted access.

Logging

The plugin includes its own logging system that:

  • records the start and completion of export processes;
  • logs SQL queries;
  • saves database and filesystem error information;
  • allows troubleshooting without enabling Cotonti debug mode.

Logs are stored in a separate file inside the plugin directory, simplifying diagnostics and maintenance.


Security and Restriction Controls

The plugin deliberately restricts export to only one table specified in the configuration. Even if a user attempts to pass a different table name, the operation will be blocked.

This mechanism prevents:

  • unauthorized access to system tables;
  • export of sensitive data;
  • SQL injections through table name substitution.

Access to the export tool is permitted only to users with administrative rights for this plugin.


Administrative Interface

Purpose of the Interface

The administrative part of the plugin is implemented as a Cotonti tool and is intended for interactive export configuration.

Through the interface, an administrator can:

  • view the list of fields in the target table;
  • select which fields will be included in the export;
  • set custom Excel column headers;
  • view the list of previously generated files;
  • download any of the existing XLSX files.

Dynamic Table Structure Detection

The plugin automatically retrieves the list of columns from the database. This means that:

  • no manual field configuration is required;
  • changes to the table structure are automatically reflected in the interface;
  • the plugin is suitable for any custom tables.

Field names are converted to uppercase by default but can be manually modified.


Session Handling

For improved usability, the plugin utilizes PHP sessions. Selected fields and custom column names are preserved between requests, allowing:

  • no need to reconfigure the export every time;
  • repeating exports with the same parameters;
  • working with large tables in stages.

AJAX Export

Data export is performed via an asynchronous HTTP request. This provides several advantages:

  • the interface remains responsive during the operation;
  • the user receives immediate feedback;
  • the file is automatically downloaded after generation.

After the export completes, the page refreshes and the new file appears in the list of available downloads.


Excel File Generation

File Structure Creation

The Excel file is created from scratch for each export operation. It contains:

  • the first row with column headers;
  • each subsequent row corresponding to one database record;
  • column order matching the administrator’s selection.

Data types are passed directly without conversion, preserving the original database content.


Row Limit

The plugin supports limiting the number of exported rows. This is especially important when working with large tables, as it allows:

  • avoiding memory limit exceedance;
  • speeding up file generation;
  • performing test exports.

A value of zero disables the limit completely.


File Storage

Generated files are saved in the plugin directory and are not automatically deleted. This enables:

  • repeated downloading of files;
  • using them as an export archive;
  • sharing file links with other users.

File size and generation date are displayed in the interface.


Typical Use Cases

Site Content Export

An administrator can export data of pages, news, or any custom entities for:

  • editing content outside the CMS;
  • transferring data to editors;
  • preparing reports.

Analytics and Reporting

The plugin allows quick retrieval of structured data for:

  • traffic analysis;
  • user activity evaluation;
  • generating business reports.

Data Migration

Excel files created by the plugin can serve as an intermediate format when transferring data between systems or preparing data for import into other platforms.


Backup

Although the plugin does not replace a full database backup, it can be used to create human-readable backups of individual tables.


Conclusion

The Excel Export plugin for Cotonti CMF is a mature, well-thought-out, and secure solution for exporting data to Excel format. It combines:

  • strict access control;
  • standalone architecture without Composer;
  • flexible administrative interface;
  • reliable handling of large data volumes.

The plugin is suitable for both routine administrative tasks and more complex data analysis and processing scenarios. Its architecture allows safe use in production environments without risking system integrity or data leakage.

 Permanent link to the plugin source code in the public GitHub repository. 

 

Technical part of the plugin guide.

 

Description: Export to Excel of articles, forums, users, products, orders and payments from the Cotonti site database

The "excel_export" plugin for Cotonti CMF is a simple and universal tool that allows exporting data from any database table into an Excel file format (.xlsx). After export, the file is automatically downloaded to the user's computer and saved in the folder plugins/excel_export/uploads/. On the plugin page, a list of previously created export files is displayed with the ability to download them. The plugin uses the PhpSpreadsheet library to generate Excel files and works without Composer.

 

Important to read

  1. To get exact table names if you simply do not have access to them right here and now, you can use a similar tool "DB Structure Viewer" for Cotonti CMF, which also provides flexible tools for viewing and exporting fields from the database, but with two important differences:
  • does not use external libraries;
  • does not export to Excel.
    It displays all tables and fields in the database and can export to sql, csv, json, as well as to php in the form of small arrays, with preview of data in the fields of all tables of your database. "DB Structure Viewer" and "Export to Excel" are similar but different tools for different tasks.
  1. Separate plugins have been developed for data import — visit the Cotonti CMF Extensions Marketplace or check my developments in repositories on GitHub.

Main features

  • Dynamic selection of the required fields from the required table for export.
  • Custom configuration of column names in the first row of the resulting Excel file.
  • Limiting the number of exported rows (configurable in settings).
  • Saving exported files in the uploads/ folder with the ability to download them later and/or simultaneously.
  • Interface in the Cotonti admin panel with a field selection form and a list of previous export operations with links to saved files.

Dependencies and requirements

Cotonti: Version 0.9.26+. PHP: 8.4+. Write permissions to the logs/ and uploads/ folders. Web server access to uploads/.

Used libraries

  • PhpSpreadsheet 1.23.0 — generation of Excel files (.xlsx).
  • ZipStream 2.4.0 — creation of ZIP archives for .xlsx files.
  • myclabs/php-enum 1.8.4 — ZipStream dependency for working with enumerations.
  • psr/simple-cache — caching (PhpSpreadsheet dependency).

Source libraries

  • PhpSpreadsheet 1.23.0:
    • Repository on GitHub file PhpSpreadsheet-1.23.0.zip.
    • Location in plugin structure plugins/excel_export/lib/phpspreadsheet/src/PhpOffice/PhpSpreadsheet/.
  • ZipStream 2.4.0:
    • Repository on GitHub file zipstream-php-2.4.0.zip.
    • Location in plugin structure plugins/excel_export/lib/zipstream/src/.
  • myclabs/php-enum 1.8.4:
    • Repository on GitHub file php-enum-1.8.4.zip.
    • Location in plugin structure plugins/excel_export/lib/php-enum/src/.
  • psr/simple-cache:
    • Repository on GitHub or use the version from PhpSpreadsheet.
    • Location in plugin structure plugins/excel_export/lib/psr/simple-cache/src/Psr/SimpleCache/.

Plugin structure

└──/plugins/excel_export/
├── excel_export.setup.php # Plugin configuration and installation file
├── excel_export.tools.php # Main admin tool file
├── excel_export.global.php # Connect to hook "global" in Cotonti Core. Here is Required!
├── inc/
│ └── excel_export.functions.php # Export functions and library autoloading
├── lib/
│ ├── phpspreadsheet/
│ │ └── src/PhpOffice/PhpSpreadsheet/ # PhpSpreadsheet 1.23.0
│ ├── psr/
│ │ └── simple-cache/src/Psr/SimpleCache/ # PSR Simple Cache
│ ├── zipstream/
│ │ └── src/ # ZipStream 2.4.0
│ └── php-enum/
│ └── src/ # myclabs/php-enum 1.8.4
├── logs/
│ └── export.log # Export log for debugging
├── tpl/
│ └── excel_export.tools.tpl # Form and file list template
└── uploads/ # Folder for storing exported files

Installation procedure

1. Download the plugin:

  • Download the plugin source code and unpack the archive.
  • Copy the excel_export folder to the plugins folder in the root of your site, for example /home/var/public_html/plugins/.
  • It is recommended to copy using FileZilla or another tool that allows control over file loss and skipping. Missed files must be re-uploaded.
  • When uploading files

2. Permissions for required folders:

  • chmod 755 on the folder plugins/excel_export/logs.
  • chmod 755 on the folder plugins/excel_export/uploads.

3. Install the plugin in Cotonti:

 Go to admin panel: "Site Management / Extensions".
Find "Export to Excel via PhpSpreadsheet" in the list.
Click "Install".

**Plugin settings** to change configuration:
    export_table: **The table you will use for export** (default pages, corresponds to cot_pages).
    max_rows: Maximum number of rows for export (default 100, set to 0 to remove the limit).

Clear cache: "Site Management / Cache" → "Clear cache".

4. Check uploads/ accessibility:

 Make sure the uploads/ folder is accessible via web (for example, https://example.com/plugins/excel_export/uploads/).
If access is denied (403), configure your web server (for example, remove the restriction in .htaccess).

Export procedure and settings to Excel

Select the table for export:

First of all, in the plugin configuration settings you need to specify the database table of your Cotonti site that you will use for export. The table name is specified without prefix, for example: pages, forum_posts, users, market or any other single table of your choice that you need for further work in Excel after export.

Access to the tool: "Administration" button

Site Management / Extensions / Export to Excel via PhpSpreadsheet (extension card). The "Administration" link leads to the page: https://example.com/admin.php?m=other&p=excel_export where the export interface and tools are located.

Select fields for export: The page displays a table with all fields, for example, when exporting from cot_pages (e.g. page_id, page_title, page_text, etc.). Check the boxes next to the fields you want to export. (Optional) Enter custom column names in the "Custom Name" field (if empty, the field name in uppercase is used, for example PAGE_ID).

Export data: Click the "Export" button. The .xlsx file (for example, export_2025-03-16_13-XX-XX.xlsx) will be downloaded to your computer. The same file will be saved in the folder plugins/excel_export/uploads/.

View previous exports: Below the field selection form there is a "Previous Exports" block. It lists all .xlsx files from uploads/ with name, size and creation date. Click on the file name to download it again.

Example export log

The log is written to plugins/excel_export/logs/export.log for debugging:

[2026-02-02 12:04:18] Starting export process
[2026-02-02 12:04:18] Target table: 'pages', Expected table: 'cot_pages'
[2026-02-02 12:04:18] Selected fields: page_id, page_title
[2026-02-02 12:04:18] Executing query: SELECT page_id, page_title FROM cot_pages LIMIT 100
[2026-02-02 12:04:18] Data fetched: X rows
[2026-02-02 12:04:18] Creating new Spreadsheet
[2026-02-02 12:04:18] Setting headers
[2026-02-02 12:04:18] Filling data
[2026-02-02 12:04:18] Generating XLSX to file: /home/var/public_html/plugins/excel_export/uploads/export_2026-02-02_12-04-18.xlsx
[2026-02-02 12:04:18] File generated successfully: /home/var/public_html/plugins/excel_export/uploads/export_2026-02-02_12-04-18.xlsx

Name: Export to Excel via PhpSpreadsheet
Version: 2.0.1
Creation date: March 16, 2025 Update date: February 02, 2026 Author: webitproff
package: excel_export copyright: Copyright (c) webitproff 2026 | https://github.com/webitproff license: BSD

Download the data export plugin to Excel (.xlsx) for free

Public open-source repository on GitHub

Plugin support topic on the forum

Suggest a task to me



Rating based on reviews:
Stars received: 0
Total reviews: 0
Average rating: 0
10 minutes read

Reviews to products

No reviews yet


Add to Cart

A downloadable file is attached to this product.

Export_to_Excel_for_Cotonti_CMF_02_02_2026.zip

Number of downloads 5

 

Category Extentions
Import, export, and data exchange, Utilities and tools
Availability
Free

Content author

webitproff

Offline

webitproff

Last logged: 2026-07-11 19:44

  • Чем могу помочь?

    Оказываю весь спектр услуг по CMF Cotonti. Разработка открытых и закрытых корпоративных интернет порталов, небольших социальных сетей, торговые площадки, маркетплейсы, биржи фриланса, каталоги товаров оптовых поставщиков, интернет-магазин под заказ, чтобы делать совместные покупки и групповые совместные продажи от имени нескольких продавцов.

  • Разработки на GitHub бесплатно
  • Featured Products and Services

    Market Products Import CSV/Excel - плагин для Cotonti

    Market Products Import CSV/Excel - плагин для Cotonti

    Плагин marketproductsimport - это инструмент массового импорта товаров в интернет-магазин или

    Recommended forum topics for this product

    "Excel Export" - плагин экспорта из любой таблицы базы данных Cotonti

    "Excel Export" - плагин экспорта из любой таблицы базы данных Cotonti

    Поддержка и обсуждения плагина "Excel Export", который позволяет просто и быстро экспортировать
    #182 | Постов: 1 | Просмотров: 852

    Market PRO Showcase

    CMS, Script and Engine for an online storefront, infoproduct shop and digital goods store. Different prices in different currencies. Online cryptocurrency payments for goods and services.