PHP Classes

PHP ODT Template SQL Reports: Generate report from MySQL data using ODT template

Recommend this page to a friend!
  Info   Documentation   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2026-01-03 (Less than 1 hour ago) RSS 2.0 feedStarStarStarStar 61%Total: 444 All time: 6,227 This week: 67Up
Version License PHP version Categories
odtreportsql 1.6GNU Lesser Genera...5PHP 5, Databases, Printing, Templates
Description 

Author

This package can generate report from MySQL data using ODT template.

It can process document templates in the ODT format used by OpenOffice and replaces the template placeholder values with data from MySQL database query results.

The template engine supports variable substitution by text or even pictures, blocks to iterate over data, nested blocks, picture substitution.

Innovation Award
PHP Programming Innovation award nominee
April 2017
Number 2
Many applications need to generate reports from data retrieved from a database.

This class can generate reports from MySQL database query results using templates in the ODT format used by OpenOffice.

This allows creating report documents formatted with user defined templates and replacing placeholders with data from a database.

Manuel Lemos
Picture of Marco Sillano
  Performance   Level  
Name: Marco Sillano <contact>
Classes: 4 packages by
Country: Italy Italy
Age: ???
All time rank: 201079 in Italy Italy
Week rank: 195 Up8 in Italy Italy Up
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

Recommendations

generate pdf with php
i need to generate a pdf from php and mysql

Adding excel object in docx
Adding excel in docx and edit the excel content using php

What is the best PHP mysql report class?
Build a nice report

Generate Report
I need a php class that will output a pdf or excel document r

Documentation

Pre-requisites: A WAMP installed. Install: 1) Download all files. 2) Create a web dir (e.g. www/odtdocument/ ). 3) Copy all files in www/odtdocument/, www/odtdocument/lib, www/odtdocument/templates. 4) Using phpMyAdmin, create a database (e.g. odtdbase). 5) Import the SQL files: odt_queries.sql. odt_reports.sql in odtdbase to create tables. (In production, you must add it to your application: 'www/odtdocument' is the application web dir, and DB 'odtdbase' is the application main DB) Setup: 6) Copy language_xx.php to language.php. 7) Edit and updates: config.php, language.php and odtphpsql.php (see TODO in files). Demo: 1) download demo.zip (from https://github.com/msillano/odtReportSQL/tree/master/demo ) 2) Unzip demo.zip in www/odtdocument/ 3) Import the SQL file: odtphp.sql on odtdbase to create and populate all tables for demo. 4) Run demo starting fom odtdocument/index.php 5) You can see demo screenshot here: https://github.com/msillano/odtReportSQL or here: https://www.phpclasses.org/package/10276-PHP-Generate-report-from-MySQL-data-using-ODT-template.html#view_files/files/demo/img

Details

# odtReportSQL This scalable library defines a complete reports/documents system for php-mySQL applications. ![demo screenshot](./demo/img/2017-04-19.210908.shot.png) Features: - Based on templates created using OpenOffice (.odt files) - Templates can be of any size (A4, A3...) and multipage. - On templates this system can do: * Simple substitution based on couples #field#/value. * Blocks and nested blocks duplication (any deep) or deletion. * Pictures substitution. - The HTML User Inteface is build by System and can be easy added at an existing php application. Add 2 lines ( see odtReportSQL-test.php) * <?php include('odtReportSQL.php'); ?> * <?php echo getReportMenu('this_page'); ?> - This system is DB driven, using 2 tables to define all templates substitutions and UI - Scalable: * odtphp.php defines template substitution engine * odtphpsql.php adds substitution queries definitions in DB * odtReportSQL.php adds an UI defined in DB - Any document as an URL definition. - To add a new document is only required to make the new template and to update the DB. - The resulting documents can be open using OpenOffice and saved in almost any format. This system was developped to be used with a school examinations management software, with more than 25 different documents (letters, certificates, ufficial records, grade tables, notices...) from 1 to 68 pages. ![demo template](./demo/img/2017-04-20.075902.shot.png)![demo document](./demo/img/2017-04-20.080141.shot.png) see install.txt. ### TODO - Templates issue Description: The new document is build, but you get an error openning it: it is inusable. Cause: The Template is sensible to the LibreOffice/OpenOffice version used. - The "OpenOffice/4.1.8$Win32 OpenOffice.org_project/418m3$Build-9803" works without probems - The "LibreOffice/7.3.0.3$Windows_x86 LibreOffice_project/0f246aa12d0eee4a0f7adcefbf7c878fc2238db3" don't works. Workaround: This affect only the template setup, not the user documents creation and use. Use allways same (old) version of OpenOffice to build and update your Templates, e.g. [https://downloads.sourceforge.net/project/openofficeorg.mirror/4.1.8/binaries/it/Apache_OpenOffice_4.1.8_Win_x86_install_it.exe](https://downloads.sourceforge.net/project/openofficeorg.mirror/4.1.8/binaries/it/Apache_OpenOffice_4.1.8_Win_x86_install_it.exe) - More translations (files language_xx.php). - More DB Interfaces (file commonSQL.php). Done: see common_pdo.php. UPDATE - 2020-02-09 the common_pdo.php file replaces the obsolete commonSQL.php file - 2022-02-02 Used this library in the new project: tuyaDaemon.toolokit (https://github.com/msillano/tuyaDAEMON/tree/main/tuyaDAEMON.toolkit): minor bugs correction and update to php 8. - Examples of result pages (pdf) are in the ![wiki](https://github.com/msillano/tuyaDAEMON/blob/main/devices/ACmeter/device_ACmeter.pdf) - Tested on: - Windows 11, php 8.1.2, MariaDB 10.4.22 - Android 11, php 4.1, MySql 5.1 The php 8 use requires also an update of pclzip.lib (here as "lib\pclzip.2.8.4.lib.php").

Screenshots (1)  
  • examples
  Files folder image Files (26)  
File Role Description
Files folder imagedemo (1 file, 1 directory)
Files folder imagelib (2 files)
Files folder imagesql (2 files)
Files folder imagetemplates (1 file)
Accessible without login Plain text file commonSQL.php Aux. mysql base functions
Accessible without login Plain text file common_pdo.php Aux. Update for commonSQL (obsolete)
Accessible without login Plain text file install.txt Doc. install instructions
Accessible without login Plain text file language.php Aux. used messages
Accessible without login Plain text file LICENSE Lic. License text
Plain text file odtphp.php Class replacements engine
Plain text file odtphpsql.php Class mySQL substitutions
Plain text file odtReportSQL.php Class mySQL UI definitions
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Image file update.gif Icon button ico
Accessible without login Plain text file _common_mysql.php Aux. Configuration script
Accessible without login Plain text file _common_PDO.php Example Example script
Accessible without login Plain text file _language-en.php Aux. Configuration script
Accessible without login Plain text file _language-it.php Aux. Configuration script

  Files folder image Files (26)  /  demo  
File Role Description
Files folder imageimg (5 files)
  Accessible without login HTML file demo.readme Doc. demo

  Files folder image Files (26)  /  demo  /  img  
File Role Description
  Accessible without login Image file 2017-04-19.210908.shot.png Output update
  Accessible without login Image file 2017-04-20.075902.shot.png Output update
  Accessible without login Image file 2017-04-20.080141.shot.png Output update
  Accessible without login Plain text file Notice-example_A3.pdf Doc. new
  Accessible without login Plain text file Notice-template_A3.pdf Doc. new

  Files folder image Files (26)  /  lib  
File Role Description
  Plain text file pclzip.2.8.4.lib.php Class Class source
  Plain text file pclzip.lib.php Class required library

  Files folder image Files (26)  /  sql  
File Role Description
  Accessible without login Plain text file odt_queries.sql Aux. SQL to create table odt_queries
  Accessible without login Plain text file odt_reports.sql Aux. SQL to create table odt_reports

  Files folder image Files (26)  /  templates  
File Role Description
  Accessible without login HTML file reportSQL.html Data for UI

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 92%
Total:444
This week:0
All time:6,227
This week:67Up
User Ratings User Comments (3)
 All time
Utility:87%StarStarStarStarStar
Consistency:87%StarStarStarStarStar
Documentation:87%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:61%StarStarStarStar
Rank:1085
 
Thats a very good class !
8 years ago (José Filipe Lopes Santos)
70%StarStarStarStar
Thats a very good class !
8 years ago (José Filipe Lopes Santos)
70%StarStarStarStar
Thats a very good class !
8 years ago (José Filipe Lopes Santos)
70%StarStarStarStar