Php 如何右对齐除前2列以外的所有列?
我有一个有27列的表,我正在使用Php 如何右对齐除前2列以外的所有列?,php,fpdf,Php,Fpdf,我有一个有27列的表,我正在使用fpdf创建pdf文件 我想知道如何才能使除前2列之外的所有列都对齐 这是我的密码 #Create the table function BasicTable($header,$data) { #Create the header. foreach ($header as $col) $this->Cell(18,5,$col,1); $this->Ln();
fpdf
创建pdf文件
我想知道如何才能使除前2列之外的所有列都对齐
这是我的密码
#Create the table
function BasicTable($header,$data) {
#Create the header.
foreach ($header as $col)
$this->Cell(18,5,$col,1);
$this->Ln();
#Get the data
foreach ($data as $row) {
foreach ($row as $col)
#$this->Cell(18,5,$col,1,'R');
$this->Cell(18,5, $col, 1, 0);
$this->Ln();
}
}
}
更新代码(工作)
#创建表格
函数基本表($header,$data){
#创建标题。
foreach($标题为$col)
$this->Cell(18,5,$col,1);
$this->Ln();
#获取数据
foreach($行数据){
$cnt=0;
foreach(行作为$col){
如果($cnt<2){
$this->Cell(18,5,$col,1);
}
否则{
$this->Cell(18,5,$col,1,0,'R');
}
$cnt++;
}
$this->Ln();
}
}
}
您应该检查每行的列值
#Create the table
function BasicTable($header,$data) {
#Create the header.
foreach ($header as $col)
$this->Cell(18,5,$col,1);
$this->Ln();
#Get the data
foreach ($data as $row) {
$cnt = 0;
foreach ($row as $col) {
if($cnt < 2){
$this->Cell(18,5,$col,1,'R');
}
else {
$this->Cell(18,5, $col, 1, 0);
}
$cnt++;
}
$this->Ln();
}
}
#创建表格
函数基本表($header,$data){
#创建标题。
foreach($标题为$col)
$this->Cell(18,5,$col,1);
$this->Ln();
#获取数据
foreach($行数据){
$cnt=0;
foreach(行作为$col){
如果($cnt<2){
$this->Cell(18,5,$col,1,'R');
}
否则{
$this->Cell(18,5,$col,1,0);
}
$cnt++;
}
$this->Ln();
}
}
我还在函数中发现了额外的“}”
根据上面的帖子更新了代码
#Create the table
function BasicTable($header,$data) {
#Create the header.
foreach ($header as $col)
$this->Cell(18,5,$col,1);
$this->Ln();
#Get the data
foreach ($data as $row) {
$cnt = 0;
foreach ($row as $col) {
if($cnt < 2){
$this->Cell(18,5,$col,1);
}
else {
$this->Cell(18,5, $col, 1, 0,'R');
}
$cnt++;
}
$this->Ln();
}
}
}
#创建表格
函数基本表($header,$data){
#创建标题。
foreach($标题为$col)
$this->Cell(18,5,$col,1);
$this->Ln();
#获取数据
foreach($行数据){
$cnt=0;
foreach(行作为$col){
如果($cnt<2){
$this->Cell(18,5,$col,1);
}
否则{
$this->Cell(18,5,$col,1,0,'R');
}
$cnt++;
}
$this->Ln();
}
}
}
您应该检查每行的列值
#Create the table
function BasicTable($header,$data) {
#Create the header.
foreach ($header as $col)
$this->Cell(18,5,$col,1);
$this->Ln();
#Get the data
foreach ($data as $row) {
$cnt = 0;
foreach ($row as $col) {
if($cnt < 2){
$this->Cell(18,5,$col,1,'R');
}
else {
$this->Cell(18,5, $col, 1, 0);
}
$cnt++;
}
$this->Ln();
}
}
#创建表格
函数基本表($header,$data){
#创建标题。
foreach($标题为$col)
$this->Cell(18,5,$col,1);
$this->Ln();
#获取数据
foreach($行数据){
$cnt=0;
foreach(行作为$col){
如果($cnt<2){
$this->Cell(18,5,$col,1,'R');
}
否则{
$this->Cell(18,5,$col,1,0);
}
$cnt++;
}
$this->Ln();
}
}
我还在函数中发现了额外的“}”
根据上面的帖子更新了代码
#Create the table
function BasicTable($header,$data) {
#Create the header.
foreach ($header as $col)
$this->Cell(18,5,$col,1);
$this->Ln();
#Get the data
foreach ($data as $row) {
$cnt = 0;
foreach ($row as $col) {
if($cnt < 2){
$this->Cell(18,5,$col,1);
}
else {
$this->Cell(18,5, $col, 1, 0,'R');
}
$cnt++;
}
$this->Ln();
}
}
}
#创建表格
函数基本表($header,$data){
#创建标题。
foreach($标题为$col)
$this->Cell(18,5,$col,1);
$this->Ln();
#获取数据
foreach($行数据){
$cnt=0;
foreach(行作为$col){
如果($cnt<2){
$this->Cell(18,5,$col,1);
}
否则{
$this->Cell(18,5,$col,1,0,'R');
}
$cnt++;
}
$this->Ln();
}
}
}
它是否正常工作?请共享您的修复程序,以便对其他人有所帮助。它是否正常工作?请共享您的修复程序,以便对其他人有所帮助。