PHP code example of exceldb / dbtoexcel

1. Go to this page and download the library: Download exceldb/dbtoexcel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

exceldb / dbtoexcel example snippets

 php
// don't forget to import vendor/autoload.php
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.
 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();