2012-03-06 115 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文件。太棒了。

我希望它会有帮助。我没有 - 对不起。

相关问题