1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| <?php
session_start();
$conn=mysql_connect('localhost','root','mdp') or die('Probleme lors de la connexion a la BD MYSQL');
mysql_select_db('pharma',$conn) or die('Problčme lors de la sélection de la BD MYSQL');//Sélection de la DB "phpexcel"
$query="SELECT inscrits_en.ID, etudiants.MATRICULE_ET,etudiants.NOM_ET,etudiants.PRENOM_ET, inscrits_en.NOTE FROM `inscrits_en` LEFT JOIN `etudiants` ON ( inscrits_en.MATRICULE_ET = etudiants.MATRICULE_ET ) WHERE MNEMONIC = 'CHIM-J-101' AND TYPE_DE_COURS = 'TH' AND CATEGORIE = 'CI' ORDER BY NOM_ET, PRENOM_ET";
$res=mysql_query($query) or die('Problčme lors de la réception des enregistrements '.$query);//Exécution de la requęte
$NombreLignes = mysql_num_rows($res);
if($NombreLignes>0)
{
set_time_limit(10);
require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "repeat.xls");
$workbook = &new writeexcel_workbook($fname);
$worksheet = &$workbook->addworksheet();
$worksheet->repeat_rows(0, 1);
for ($i=1;$i<=$NombreLignes;$i++)
{
$worksheet->write($i+1, 0, MATRICULE_ET);
}
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example-repeat.xls\"");
header("Content-Disposition: inline; filename=\"example-repeat.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
}
?> |
Partager