TCPDF。 MultiCell高度不自动延伸

时间:2016-06-02 15:44:41

标签: tcpdf

我被困了......试图整天解决这个问题,没有快乐。我正在显示一个包含6列的表(使用foreach())。第3列可以有多行文本,因此我尝试使用MultiCell选项与其他列使用单元格选项。

多单元不会自动扩展以显示所有文本,并且在一行上重叠所有文本。我在功能上尝试了所有不同的参数但没有成功。我确信我已经忘记了一些简单的事情。

public function ColoredTable($header,$data) {
    // Colors, line width and bold font
    $this->SetFillColor(0, 0, 0);
    $this->SetTextColor(255);
    $this->SetDrawColor(0, 0, 0);
    //$this->SetLineWidth(0);
    $this->SetFont('', 'B');
    // Header
    $w = array(40, 15, 150, 20, 20, 20 );
    $num_headers = count($header);
    for($i = 0; $i < $num_headers; ++$i) 
{
if ($i==0)
{$this->Cell($w[$i], 7, $header[$i], 1, 0, 'L', 1);}
else if ($i==1)
{$this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1);}
else if ($i==2)
{$this->Cell($w[$i], 7, $header[$i], 1, 0, 'L', 1);}
else  
{$this->Cell($w[$i], 7, $header[$i], 1, 0, 'R', 1);}
    }
    $this->Ln();
    // Color and font restoration
    $this->SetFillColor(255);
    $this->SetTextColor(0);
    $this->SetFont('');
    // Data
    $fill = 0;
$h = 5 ;

    foreach($data as $row) {        
        $this->Cell($w[0], $h, $row[0], 'L', 0, 'L', $fill, $link = '', $stretch = 0, $ignore_min_height = false, $calign = 'T', $valign = 'T');
        $this->Cell($w[1], 0, $row[1], '', 0, 'C', $fill, $link = '', $stretch = 0, $ignore_min_height = false, $calign = 'T', $valign = 'T');
  $this->MultiCell($w[2], 0, $row[2], $border=0, $align='L', $fill=false, 0, $x='', $y='', $reseth=false, $stretch=0, $ishtml=false, $autopadding=false, $maxh=0 , 'T', $fitcell=false);
        $this->Cell($w[3], $h, number_format($row[3]), 'L', 0, 'R', $fill, $link = '', $stretch = 0, $ignore_min_height = false, $calign = 'T', $valign = 'T');
  $this->Cell($w[4], $h, number_format($row[4]), 'L', 0, 'R', $fill, $link = '', $stretch = 0, $ignore_min_height = false, $calign = 'T', $valign = 'T');
        $this->Cell($w[5], $h, number_format($row[5]), 'LR', 0, 'R', $fill, $link = '', $stretch = 0, $ignore_min_height = false, $calign = 'T', $valign = 'T');
        $this->Ln();
        $fill=!$fill;
    }
    $this->Cell(array_sum($w), 0, '', 'T');
}

0 个答案:

没有答案