2013-12-16 70 views
2

如何將填充參數設置爲某一行和列? Anyhelp? $ fill是我使用的變量,有什麼想法?如何在動態創建單元格時設置填充顏色? TCPDF

$row = 10; 
$col = 10; 
$w = 8; 
$h = 8; 

for ($r=1;$r<=$row;$r++) 
{ 
    for ($c=1;$c<=$col;$c++) 
    { 
     $pdf->Cell($w,$h, 'STRING' ,1,0,'C',$fill);    
    } 
    $pdf->Ln(); 
} 
+0

請清潔你的代碼! –

回答

3

您CAND使用您的行數和模塊的操作一樣做到這一點:

$row = 10; 
$col = 10; 
$w =8; 
$h=8; 

for ($r=1;$r<=$row;$r++) 
{ 
    if($r%2==0) { //here you can change your logic 
    $fill = "#F0F0F0"; 
    } else { 
    $fill = "#FFFFFF"; 
    } 
    for ($c=1;$c<=$col;$c++) 
    { 
    $pdf->Cell($w,$h, 'STRING' ,1,0,'C',$fill); 
    } 
$pdf->Ln(); 
} 
相關問題