2017-11-21 5 views
0

私は27列のテーブルを持っており、私はfpdfを使ってPDFファイルを作成しています。最初の2文字以外のすべての列を右揃えにする方法は?

第1の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(); 
      } 
     } 
    } 

更新コード(ワーキング)

#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(); 
    } 
     } 
    } 

答えて

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) { 
     $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(); 
    } 
} 

をCOL値をチェックする必要があり、私はまた、あなたの関数で "}" の余分ました。

#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(); 
    } 
     } 
    } 
+0

SIR以上のポストに基づいて更新されたコードのplsのは –

+0

が用事私はそれを修正私のために働いていない更新されたコードを参照してください。ご連絡先 –

+0

それは機能していますか?他の人に役立つように修正プログラムを共有してください。 – Saurabh

関連する問題