2017-05-15 48 views
3

我寫了下面的代碼創建一個表,多單元如何創建多節表FPDF

$this->Cell(25, 25, "SR.No.", 'LTRB', 0, 'L', true); 
    $this->Cell(60, 25, "CHALLAN", 'LTRB', 0, 'L', true); 
    $this->Cell(300, 25, "JOB NAME", 'LTRB', 0, 'L', true); 
    $this->Cell(60, 25, "QTY.", 'LTRB', 0, 'L', true); 
    $this->Cell(60, 25, "RATE", 'LTRB', 0, 'L', true); 
    $this->Cell(90, 25, "AMOUNT", 'LTRB', 1, 'C', true); 
    $i=1; 
    while($row = mysql_fetch_array($result)) 
    { 
    $x = $this->x; 
    $y = $this->y; 
    $push_right = 0; 
    $this->MultiCell($w = 25,25,$i,1,'C',0); 
    $push_right += $w; 
    $this->SetXY($x + $push_right, $y); 
    $this->MultiCell($w = 60,25,$row[3],1,'C',0); 
    $push_right += $w; 
    $this->SetXY($x + $push_right, $y); 
    $this->MultiCell($w = 300,25,$row[2],1,'L',0); 
    $push_right += $w; 
    $this->SetXY($x + $push_right, $y); 
    $this->MultiCell($w = 60,25,$row[4],1,'L',0); 
    $push_right += $w; 
    $this->SetXY($x + $push_right, $y); 
    $this->MultiCell($w = 60,25,$row[5],1,'L',0); 
    $push_right += $w; 
    $this->SetXY($x + $push_right, $y); 
    $this->MultiCell($w=90,25,$row[6],1,'C',1); 
    $this->Ln(); 
    $i++; 
    } 

我的代碼生成此輸出 enter image description here

卜我想從兩個行刪除空間不對齊並且每列的相同高度嘗試了很多次,但沒有解決。

回答

0

您已使用Multicell。 Multicell的高度是按照線,而不是box.And Cell的高度是根據框。因此,文本出現在2行,高度變爲50px(25 * 2),剩餘單元格的高度爲25px。如果內容是靜態的,請使用高度爲50px的單元格(在您的情況下)而不是多單元格;如果內容是動態的,則使用單元格,並相應地計算高度。例如: - 你的盒子高度變成50px。所以對於剩下的多單元,請將高度設置爲50px。