https://github.com/91ahmed/dbtoexcel
Convert database table to excel sheet. 🐘
https://github.com/91ahmed/dbtoexcel
database database-tables excel export-to-excel php
Last synced: 16 days ago
JSON representation
Convert database table to excel sheet. 🐘
- Host: GitHub
- URL: https://github.com/91ahmed/dbtoexcel
- Owner: 91ahmed
- License: mit
- Created: 2023-01-27T22:21:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-12T06:15:24.000Z (about 2 years ago)
- Last Synced: 2024-12-05T19:38:28.328Z (6 months ago)
- Topics: database, database-tables, excel, export-to-excel, php
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## DbtoExcel
PHP script to simplify the process of converting database table to excel sheet.### # Requirements
* PHP 7.0 or higher
* Composer for installation### # Install
via composer
```
composer require exceldb/dbtoexcel
```### # Example
``` php
// don't forget to import vendor/autoload.php
require('vendor/autoload.php');// Database information
$extract = new Database\Excel\ExtractExcel([
'driver' => 'mysql',
'host' => '127.0.0.1',
'username' => 'root',
'password' => '',
'database' => 'test',
'port' => '3306',
'charset' => 'utf8',
'sslmode' => 'disable'
]);$extract->table('users'); // Specify the database table.
$extract->columns('*'); // Specify the columns you need to extract.
$extract->execute(); // Execute the script.
```### # Description
The **TableToExcel** class constructor takes one parameter, which is an *(array)* of the database information.
`table()`
This method used to specify the database table you need to extract, it takes one parameter *(string)* which is the name of the table.`columns()`
Used to specify the columns you need to extract from the database table, it takes one parameter *(string)* which is the column's names.To extract all columns just add __asterisk (*)__ or leave the parameter empty while if you want to extract specific columns you can write the columns names following by comma separator.. see the example below.
``` php
use ExtractDatabaseToExcel\TableToExcel;$extract = new TableToExcel([
'driver' => 'mysql',
'host' => '127.0.0.1',
'username' => 'root',
'password' => '',
'database' => 'test',
'port' => '3306',
'charset' => 'utf8'
]);$extract->table('users');
$extract->columns('username, email, age'); // Extract specific columns
$extract->execute();
````execute()`
This is the last method you should invoke to execute the script, the method will convert the data and download the excel file.