2012-03-06 111 views
0

我試圖用fpdf 創建一個表格,但是我的表格的輸入非常大,所以它不適合在一個單元格中,我不知道如何將該數據推入下一行而不會扭曲表結構。php-pdf -table創建

我嘗試使用多點到..這並沒有工作。

我用這個代碼

function table_2($header,$data) 

{ 
    // Colors, line width and bold font 
    $this->SetFillColor(255,0,0); 
    $this->SetTextColor(255); 
    $this->SetDrawColor(128,0,0); 
    $this->SetLineWidth(.3); 
    $this->SetFont('','B',5); 
    // Header 
    $w = array(8, 90, 90); 
    for($i=0;$i<count($header);$i++) 
     $this->Cell($w[$i],7,$header[$i],1,0,'C',true); 
    $this->Ln(); 
    // Color and font restoration 
    $this->SetFillColor(224,235,255); 
    $this->SetTextColor(0); 
    $this->SetFont(''); 
    // Data 
    $fill = false; 
    foreach($data as $row) 
    { 
     $this->Cell($w[0],6,$row[0],1,0,'L',$fill); 
     $this->Cell($w[1],6,$row[1],1,0,'J',$fill); 
     $this->Cell($w[1],6,$row[2],1,0,'J',$fill); 
     //$this->Cell($w[2],6,number_format($row[2]),'LR',0,'R',$fill); 
     //$this->Cell($w[3],6,number_format($row[3]),'LR',0,'R',$fill); 
     $this->Ln(); 
     $fill = !$fill; 
    } 
    // Closing line 
    $this->Cell(array_sum($w),0,'','T'); 
} 

誰能幫助我?

回答

1

我建議你使用這個lib http://www.mpdf1.com/mpdf/。它允許將html + css轉換爲pdf文件。它基於fpdf。我用它來生成約1000頁的pdf文件。太棒了。

我希望它會有幫助。我沒有 - 對不起。

相關問題