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
| /
/Reading the LKVMM table
$__LKVReq = "SELECT * FROM $LKVTable" ;
// Labels retrieval
try
{
$recordset = $bdd->query("SHOW COLUMNS FROM LKVMM");
$fields = $recordset->fetchAll(PDO::FETCH_ASSOC);
}
catch (PDOException $e){
$e ->getMessage();
$message .= $e." for ". $MemberFirstName." ".$MemberLastName;
}
foreach ($fields as $field)
{
$fieldNames[] = $field['Field'];
}
// Data retrieval
try
{
$Stmt = $bdd->prepare($__LKVReq);
$__LKVData = $Stmt->execute();
$__LKVData = $Stmt->fetchall();
}
catch (PDOException $e){
$e ->getMessage();
$message .= $e." for ". $MemberFirstName." ".$MemberLastName;
}
$__LKVLine = count($__LKVData);
// lkvmm.xls file creation
if(!empty($__LKVData))
{
$message .= $__LKVLine."Factures générées";
$workbook = new PHPExcel(); // instanciation of the object PHPExcel
$sheet = $workbook -> getActiveSheet(); // Activation de la feuille
for ($__i = 0;$__i <= 132;$__i++)
{
$sheet -> setCellValueByColumnAndRow($__i,1,$fieldNames[$__i]); // filling line 1 with the labels : $fieldNames[$__i]
}
$__line=2;
foreach ($__LKVData as $__LKVRow)
{
for ($__col =0; $__col<=132;$__col++) // scroll through the 133 columns of the line
{
$sheet -> setCellValueByColumnAndRow($__col,$__line,$__LKVRow[$__col]); // filling with the values
}
$__line++;
}
$writer = new PHPExcel_Writer_Excel2007($workbook); // instanciation of the object PHPExcel_Writer_Excel2007
$writer->save($filename);
$message .= "file lkv".$__mm.".xls saved";
}
else
{
$message .= "No record in the table LKV";
}
return ($message); |
Partager