Cell(60, 25, "CH-6ren">
gpt4 book ai didi

php - 如何创建多单元格表格 FPDF

转载 作者:行者123 更新时间:2023-12-04 17:52:46 24 4
gpt4 key购买 nike

我写了下面的代码来创建一个多单元格的表

$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

Bu 不对齐我想从两行中删除空间并使每列的高度相等尝试了很多次但没有解决。

最佳答案

您已经使用过 Multicell。 Multicell 的高度是根据行,而不是框。而Cell 的高度是根据框。因此,文本分两行出现,高度变为 50px (25*2),剩余单元格的高度为 25px。如果内容是静态的,则使用高度为 50px 的单元格(在您的情况下)而不是多单元格,或者如果内容是动态的,则使用多单元格并相应地计算高度。例如:- 你的盒子高度变成 50px。因此,对于剩余的多单元格,将高度设置为 50px。

关于php - 如何创建多单元格表格 FPDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43977978/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com