PHPackages                             agoussec/phpdbtabletoexcel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. agoussec/phpdbtabletoexcel

ActiveLibrary[File &amp; Storage](/categories/file-storage)

agoussec/phpdbtabletoexcel
==========================

Create Excel sheet directly from database table rows

1.12(5y ago)410GPL-3.0-onlyPHP

Since Mar 27Pushed 5y ago2 watchersCompare

[ Source](https://github.com/agoussec/PHPDBTabletoExcel)[ Packagist](https://packagist.org/packages/agoussec/phpdbtabletoexcel)[ RSS](/packages/agoussec-phpdbtabletoexcel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

PHPDBTabletoExcel
=================

[](#phpdbtabletoexcel)

Create Excel sheet directly from database table's rows

Getting Started
---------------

[](#getting-started)

PHPDBTabletoExcel is a very simple and easy to use PHP package for generating Excel file from database table SQL query.

It can connect to a database using PDO and executes a given SQL database table query.

The class executes the query and then outputs the results to a file in HTML table based format that is served for download and can be read and imported correctly by Microsoft Excel.

### Prerequisites

[](#prerequisites)

No requirements for now!

### Installing

[](#installing)

Install using composer

```
composer require agoussec/phpdbtabletoexcel

```

Create Object of Class and start using it directly by adding in your project files if autoload is enabled, if not then include class file in your project.

```
use agoussec\class\Export;
$export = new Export();

```

Usage Example
-------------

[](#usage-example)

#### *Way 1 for initializing database connection*

[](#way-1-for-initializing-database-connection)

You can pass database credentials while creating object of class.

```
$exportObject = new Export('localhost', 'dbuser', 'password', 'database');

```

#### *Way 2 for initializing database connection*

[](#way-2-for-initializing-database-connection)

Create PDO connection and pass PDO object to `setConnection()` method

```
$Conn = new PDO('mysql:host=localhost;dbname=dbname', 'dbuser', "dbpassword");
$export->setConnection($Conn);

```

#### Set SQL Query

[](#set-sql-query)

```
$sql = "SELECT
           table2.column1 as `Column 1`,
           table3.column2 as `Column 2`,
           table1.column3 as `Column 3`,
        FROM `table1`
           left JOIN table2 ON table2.id = table1.table2id
           left JOIN table3 ON table3.id = table1.table3id
        WHERE table1.status = 1";

 $export->setQuery($sql);

```

#### Set table rows (optional)

[](#set-table-rows-optional)

```
$export->setData($PDOFETCHEDARRAY);

```

#### Exported File Name (optional)

[](#exported-file-name-optional)

```
$export->setFilename('setFilename');

```

#### Header row in exported excel sheet (optional)

[](#header-row-in-exported-excel-sheet-optional)

```
$export->setHeaderRow(true);

```

#### Time Stamp (optional)

[](#time-stamp-optional)

```
$export->setTimestamp(true);

```

#### And at last get the Excel file -

[](#and-at-last-get-the-excel-file--)

```
$export->getFile();

```

Authors
-------

[](#authors)

- **Shamsh Pravez** - *Initial work* - [agoussec](https://github.com/agoussec)

License
-------

[](#license)

This project is licensed under the GNU General Public License v3.0 - see the LICENCE file for details

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

1869d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/44767182af477decbc52e69a70c631585d6fe1772cb02e551e55bd64a5eb242a?d=identicon)[agoussec](/maintainers/agoussec)

---

Top Contributors

[![agoussec](https://avatars.githubusercontent.com/u/16516713?v=4)](https://github.com/agoussec "agoussec (13 commits)")

### Embed Badge

![Health badge](/badges/agoussec-phpdbtabletoexcel/health.svg)

```
[![Health](https://phpackages.com/badges/agoussec-phpdbtabletoexcel/health.svg)](https://phpackages.com/packages/agoussec-phpdbtabletoexcel)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M123](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M61](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
