8

你如何使用 PHP 用 FPDF 制作这样的表格?

我似乎无法弄清楚如何使用$this->Cell.

桌子

4

3 回答 3

17

FPDF 无法识别rowspancolspan. 这是您可以尝试的解决方法,使用空单元格borderCell.

$pdf->Cell(40,5,' ','LTR',0,'L',0);   // empty cell with left,top, and right borders
$pdf->Cell(50,5,'Words Here',1,0,'L',0);
$pdf->Cell(50,5,'Words Here',1,0,'L',0);
$pdf->Cell(40,5,'Words Here','LR',1,'C',0);  // cell with left and right borders
$pdf->Cell(50,5,'[ x ] abc',1,0,'L',0);
$pdf->Cell(50,5,'[ x ] checkbox1',1,0,'L',0);
$pdf->Cell(40,5,'','LBR',1,'L',0);   // empty cell with left,bottom, and right borders
$pdf->Cell(50,5,'[ x ] def',1,0,'L',0);
$pdf->Cell(50,5,'[ x ] checkbox2',1,0,'L',0);

结果将是- fpdf 表格示例

于 2012-11-16T06:12:26.603 回答
5

我想我找到了其他解决方案,这是我不需要空单元格的解决方案。

$pdf->Cell(40,18,'Words Here', 1,0, 'C');
$x = $pdf->GetX();
$pdf->Cell(40,6,'Words Here', 1,0);
$pdf->Cell(40,6,'Words Here', 1,1);
$pdf->SetX($x);
$pdf->Cell(40,6,'[x] abc', 1,0);
$pdf->Cell(40,6,'[x] Checkbox 1', 1,1);
$pdf->SetX($x);
$pdf->Cell(40,6,'[x] def', 1,0);
$pdf->Cell(40,6,'[x] Checkbox 1', 1,1);

结果如下:

结果

于 2020-04-15T20:15:06.200 回答
3

谢谢,这有帮助,这对我有用:

$this->Cell(40,5,' ','LTR',0,'L',0);   // empty cell with left,top, and right borders
$this->Cell(50,5,'111 Here',1,0,'L',0);
$this->Cell(50,5,'222 Here',1,0,'L',0);

                $this->Ln();

$this->Cell(40,5,'Solid Here','LR',0,'C',0);  // cell with left and right borders
$this->Cell(50,5,'[ o ] che1','LR',0,'L',0);
$this->Cell(50,5,'[ x ] che2','LR',0,'L',0);

                $this->Ln();

$this->Cell(40,5,'','LBR',0,'L',0);   // empty cell with left,bottom, and right borders
$this->Cell(50,5,'[ x ] def3','LRB',0,'L',0);
$this->Cell(50,5,'[ o ] def4','LRB',0,'L',0);

                $this->Ln();
                $this->Ln();
                $this->Ln();
于 2012-11-16T14:17:03.983 回答