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
| //Tableau coloré
function FancyTable($header,$data,$taille_col)
{
$this->y=50;
//Couleurs, épaisseur du trait et police grasse
$this->SetFillColor('rgb',0.5,0.5,0.5);
$this->SetTextColor('rgb',1,1,1);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//En-tête
for($i=0;$i<count($header);$i++)
$this->Cell($taille_col,7,$header[$i],1,0,'C',1);
$this->Ln(7);
//Restauration des couleurs et de la police
$this->SetFillColor('rgb',0.88,0.92,1);
$this->SetTextColor('rgb',0,0);
$this->SetFont('');
//Données
$fill=0;
$i=0;
foreach($data as $row)
{
if ($i == count($header)){
$this->Ln(6);
$i=0;
$fill=!$fill;
}
$this->Cell($taille_col,6,$row,'LR',0,'L',$fill);
$i++;
}
}
function Ln($h='')
{
//Line feed; default value is last cell height
$this->x=$this->_left_margin;
if(is_string($h))
$this->y+=$this->lasth;
else
$this->y+=$h;
} |
Partager