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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
<?php
set_include_path(get_include_path() . ";e:EasyPHP 2.0b1\php5\PEARDIR");
//Variables de connexion
@$dsn = DB2_*****; /* Nom du lien ODBC mis dans le fichier de configuration odbc.ini */
@$user = *****; /* Votre nom dutilisateur AS400 */
@$passwd = *****; /* Mot de passé AS400 */
//Connexion
$conn = odbc_connect($dsn,$user,$passwd );
//Verification de connexion
if ($conn <= 0) {
echo "Error in connection<BR>";
exit;
}
$sql="SELECT PRODUIP.prcart as Code, PRODUIP.prlpro as Designation, PRODUIP.prcstk as Code_Stock FROM STOKVIS.ADELFIC.PRODUIP PRODUIP WHERE PRODUIP.prcstk='I'";
//$resultat = mysql_query($sql) or die;
$resultat = odbc_Exec($conn, $sql);
$total = odbc_num_rows($resultat);
set_time_limit(300);
require_once 'Spreadsheet/Excel/Writer.php';
ob_start();
$workbook = new Spreadsheet_Excel_Writer();
$workbook->setTempDir('./tempdoc');
$filename ='report_'.date('dmyHi').'.xls';
$workbook->send($filename);
$worksheet = $workbook->addWorksheet();
$format_titre = $workbook->addFormat(
array(
'Size' => 10,//taille du texte
'Align' => 'center',//alignement du texte
'Color' => 'white',//couleur du texte
'FgColor' => '32',
'Bold' => 1,
'bordercolor'=>'white',
'left' => 1));//couleur du fond de cellule
$format_celule = $workbook->addFormat(
array(
'Size' => 10,//taille du texte
'Align' => 'left',//alignement du texte
'Color' => 'black',//couleur du texte
'FgColor' => 'white',
'bordercolor'=>'32',
'left' => 1));//couleur du fond de cellule
$worksheet->SetColumn(1,3,30);
$worksheet->write(2,0, 'Matricule',$format_titre);
$worksheet->write(2,1, utf8_decode('Nom & prénom'),$format_titre);
$worksheet->write(2,2, 'Fonction',$format_titre);
//$worksheet->write(2,3, 'Structure',$format_titre);
//$worksheet->write(2,4, 'Date fin',$format_titre);
$i=3;
while ($row = odbc_fetch_array($resultat))
{
$worksheet->write($i,0, $row["Code"],$format_celule );
$worksheet->write($i,1, $row["Designation"],$format_celule );
$worksheet->write($i,2, $row["Code_Stock"],$format_celule );
//$worksheet->write($i,3, $row["structure"],$format_celule );
//$worksheet->write($i,4, $row["date_ech"],$format_celule );
$i=$i+1;
}
$workbook->close();
$workbook->sendFile();
ob_end_flush();
?> |
Partager