如何格式化多单元格fpdf表中的单个单元格


How to format a single cell in a multicell fpdf table

我使用的是带有fpdf的多单元表我想根据条件用粗体字母格式化单元格的值

示例:

$pdf->SetFont('Arial','B',10);
$pdf->Row(array("","IDUSER","NAME","AGE"); //header of the table<BR>
do {
    if($myrow["age"] >30)
         $age=<b>$myrow["age"]; //value in bold letter<br>
    else
        $age=$myrow["age"];
    $pdf->Row(array($n,$myrow["id_user"],$myrow["name"],$age));
} while ($myrow = mysql_fetch_array($result));

在显示文本之前,只需调用带有"B"的SetFont即可获得粗体,而不带"B"即可获得常规:

$pdf->SetFont('Arial','B',10);
$pdf->Row(array("","IDUSER","NAME","AGE"); //header of the table<BR>
do<br>
{<BR>
    if($myrow["age"] >30)<br>
      { $pdf->SetFont('Arial','B',10);  // ◄■■■■■■■■■■■■■ BOLD
        $age=$myrow["age"]; //value in bold letter<br>
      }
    else{ <br>
          $pdf->SetFont('Arial','',10);  // ◄■■■■■■■■■■■■■ REGULAR.
          $age=$myrow["age"];<br>
        } 
    $pdf->Row(array($n,$myrow["id_user"],$myrow["name"],$age));<br>
} while ($myrow = mysql_fetch_array($result);<br>

另一种方法:

$pdf->SetFont('Arial','B',10);
$pdf->Row(array("","IDUSER","NAME","AGE"); //header of the table<BR>
do<br>
{<BR>
    if($myrow["age"] >30)<br>
      { $font = "B"; // ◄■■■ BOLD FONT.
        $age=$myrow["age"]; //value in bold letter<br>
      }
    else{ <br>
          $font = ""; // ◄■■■ REGULAR FONT.
          $age=$myrow["age"];<br>
        } 
    $pdf->SetFont('Arial',$font,10); // ◄■■■ SET FONT.
    $pdf->Row(array($n,$myrow["id_user"],$myrow["name"],$age));<br>
} while ($myrow = mysql_fetch_array($result);<br>