PHP Classes

Niger PHP MySQL Excel Export: Export MySQL records to a file to import in Excel

Recommend this page to a friend!
  Info   View files Example   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 118 This week: 1All time: 9,514 This week: 560Up
Version License PHP version Categories
nigerclassphp-export 1.0.0GNU General Publi...5PHP 5, Databases, Files and Folders
Description 

Author

This package can export MySQL records to a file to import in Excel.

It provides classes that can connect to a MySQL database using either the MySQLi or PDO extensions.

The example script can call these classes to execute queries to return results. Then it can export a file with a semi-colon separated data format containing the query result values.

Picture of Hassane Moussa
  Performance   Level  
Name: Hassane Moussa <contact>
Classes: 10 packages by
Country: Niger Niger
Age: 40
All time rank: 21481 in Niger Niger
Week rank: 109 Up1 in Niger Niger Equal
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Recommendations

What is the best PHP MySQL Export to Excel Class?
Want to Export MySQL data to Excel file using PHP

Example

<?php

/***************************************************************************************
                                Using Functions of Niger Class
***************************************************************************************/
require_once('Niger.php');
// ini_set("memory_limit","10500M");
// set_time_limit(600);
 
$limit = 100; // number of rows in the file
 
$extension = ".csv"; // Extension File : ex : .txt ; .xls; .xlsx; ...
 
$filename = "Niger"; // the file name
 
 
$nigerconnect = new Niger ('localhost', 'root', '', 'adventureworks'); // Create a new object Niger
   
   
$Resulats = $nigerconnect->ReqSQL('SELECT * FROM `address` '); // request SQL
   
if ($Resulats){
   
$i =0;
   
$j = 1 ;
    foreach (
$Resulats as $Valeur)
    {
          if (
$nigerconnect->Modulo($i,$limit) ==0){
             
             
$newfile = $nigerconnect->CreatFile($filename,$extension,$j) ; // create new file
             
fputs($newfile, 'AddressID;AddressLine1;City'); // file header
             
fputs($newfile, "\r\n");
             
$j++;
          }
       
$i++;
              
fputs($newfile, '"'.$Valeur[0].'";"'.$Valeur[1].'";"'.$Valeur[3].'"'); // put the data from database in the file
              
fputs($newfile, "\r\n");
               if (
$nigerconnect->Modulo($i,$limit) ==0){fclose($newfile);} // close file
              

   
} // foreach
   
echo "You succeed ! Congratulations.";
    }
// if
   
else {
        echo
"You did not succeed.Check your sql!";
    }
?>


Details

A simple PHP : - class Niger PDO - class Niger MYSQLI

Export mysql data to excel spreadsheet or other formats using PDO or MYSQLI, PHP and MySQL . It creates many files according to number of lines to define.

Before used thoses classes, below the prerequises : The MySQLi or PDO extension is designed to work with MySQL version 4.1.13 or newer. PHP 5 or newer @From Africa / Niamey-Niger @License GPL


  Files folder image Files  
File Role Description
Accessible without login Plain text file LICENSE Lic. License text
Plain text file Niger.php Class Class source
Plain text file nigerPdo.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file readme.txt Doc. Documentation
Accessible without login Plain text file UsingFunctionsOfNigerClass.php Example Example script
Accessible without login Plain text file UsingFunctionsOfNigerPdoClass.php Example Example script
Accessible without login Plain text file _config.yml Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:118
This week:1
All time:9,514
This week:560Up