gpt4 book ai didi

pdf - fpdf 表 : Cell Splitting/Merging

转载 作者:行者123 更新时间:2023-12-04 07:04:28 25 4
gpt4 key购买 nike

我正在尝试生成一个 PDF,其中包含一个带有拆分/合并单元格的表格,如下所示:

细胞 |细胞 |细胞
细胞 | C1 | C2 |细胞
| C1 | C2 |细胞

我正在使用 fpdf 并被称为多单元表脚本,我以前在类似的 pdf 中使用过。我看着代码,想不出一种方法来根据我的需要拆分或合并单元格。有谁知道如何做到这一点?

最佳答案

只需手动执行,以便单元格宽度成为两个合并单元格的总和。

根据你的例子:

$column_widths = ["50","50","50","50"];

// First row.
$pdf->Cell($column_widths[0], 5, "Cell", "", 0, "C", false);
$pdf->Cell($column_widths[1] + $column_widths[2], 5, "Cell", "", 0, "C", false);
$pdf->Cell($column_widths[3], 5, "Cell", "", 0, "C", false);

// Second row.
$pdf->Cell($column_widths[0], 5, "Cell", "", 0, "C", false);
$pdf->Cell($column_widths[1], 5, "C1", "", 0, "C", false);
$pdf->Cell($column_widths[2], 5, "C2", "", 0, "C", false);
$pdf->Cell($column_widths[3], 5, "Cell", "", 0, "C", false);

// Third row.
$pdf->Cell($column_widths[0], 5, "", "", 0, "C", false);
$pdf->Cell($column_widths[1], 5, "C1", "", 0, "C", false);
$pdf->Cell($column_widths[2], 5, "C2", "", 0, "C", false);
$pdf->Cell($column_widths[3], 5, "Cell", "", 0, "C", false);

或类似的东西。

关于pdf - fpdf 表 : Cell Splitting/Merging,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1330478/

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