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
| <?PHP
include("../includes/fonctions.php");
include("../classes/PHPExcel.php");
include("../classes/PHPExcel/Writer/Excel5.php");
$workbook = new PHPExcel;
$sheet = $workbook->getActiveSheet();
$col=1;
$lig=2;
$cnx=mysql_connect("","","") or die("Connexion Bdd impossible");
$db=mysql_select_db("xxx") or die('Connexion table campgdv impossible');
$sql="SELECT adresse, commune, prive, public FROM tablea";
$requete=mysql_query($sql,$cnx) or die ('Echec select tablea');
while( $result = mysql_fetch_object( $requete ) )
{
$sheet->setCellValueByColumnAndRow($col,$lig,$result->adresse);
$col=$col+1;
$sheet->setCellValueByColumnAndRow($col,$lig,$result->commune);
$col=$col+1;
$sheet->setCellValueByColumnAndRow($col,$lig,$result->prive);
$col=$col+1;
$sheet->setCellValueByColumnAndRow($col,$lig,$result->public);
$col=$col+1;
$col=1;
$lig=$lig+1;
}
$writer = new PHPExcel_Writer_Excel5($workbook);
mysql_close();
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition:inline;filename=test.xls');
$writer->save('php://output');
?> |
Partager