2017-07-03 38 views
0

我想將HTML表生成爲PDF。Table griding HTML2PDF

但我在網格表中遇到了麻煩。我想產生這樣的表:

enter image description here

我從數據庫中的表:

enter image description here

這是必須填寫此欄:

enter image description here

和我有這樣的數據庫第二張表:

enter image description here

這是應該充滿列的其餘部分除了keterangan柱。

我試過這段代碼:

<table class="tbl" border="1" style="margin: 0 auto;"> 
<tr style="height: 50px;"> 
    <th rowspan="2" style="width: 50%">Nomor</th> 
    <th colspan="4">Pemberian entertaiment dan sejenisnya</th> 
    <th colspan="4">Relasi usaha yang diberikan entertainment dan sejenisnya</th> 
    <th rowspan="2">Keterangan</th> 
</tr> 
<tr> 
    <th>Tanggal</th> 
    <th>Alamat</th> 
    <th>Jenis</th> 
    <th>Jumlah</th> 
    <th>Nama</th> 
    <th>Posisi</th> 
    <th>Nama Perusahaan</th> 
    <th>Jenis Usaha</th> 
</tr> 
<tr> 
    <td> 
     <?PHP echo $row->nomor?> 
    </td> 
    <td> 
     <?PHP echo $row->tanggal?> 
    </td> 
    <td> 
     <?php echo $row->alamat?> 
    </td> 
    <td> 
     <?PHP echo $row->jenis?> 
    </td> 
    <td> 
     <?PHP echo $row->jumlah?> 
    </td> 
    <?php 
      foreach ($list->result() as $data){ 
     ?> 
     <tr> 
      <td> 
       <?PHP echo $data->nama?> 
      </td> 
      <td> 
       <?PHP echo $data->posisi?> 
      </td> 
      <td> 
       <?PHP echo $data->nama_perusahan?> 
      </td> 
      <td> 
       <?PHP echo $data->jenis_usaha?> 
      </td> 
     </tr> 
     <?php 
      } 
     ?> 
     <td> 
      <?PHP echo $row->keterangan?> 
     </td> 
</tr> 

但這是結果:

enter image description here

回答

1

試試這個:

<table class="tbl" border="1" style="margin: 0 auto;"> 
<tr style="height: 50px;"> 
    <th rowspan="2" style="width: 50%">Nomor</th> 
    <th colspan="4">Pemberian entertaiment dan sejenisnya</th> 
    <th colspan="4">Relasi usaha yang diberikan entertainment dan sejenisnya</th> 
    <th rowspan="2">Keterangan</th> 
</tr> 
<tr> 
    <th>Tanggal</th> 
    <th>Alamat</th> 
    <th>Jenis</th> 
    <th>Jumlah</th> 
    <th>Nama</th> 
    <th>Posisi</th> 
    <th>Nama Perusahaan</th> 
    <th>Jenis Usaha</th> 
</tr> 
<tr> 
    <td> 
     <?PHP echo $row->nomor?> 
    </td> 
    <td> 
     <?PHP echo $row->tanggal?> 
    </td> 
    <td> 
     <?php echo $row->alamat?> 
    </td> 
    <td> 
     <?PHP echo $row->jenis?> 
    </td> 
    <td> 
     <?PHP echo $row->jumlah?> 
    </td> 
    <?php 
      foreach ($list->result() as $data){ 
     ?> 
     <tr> 
      <td>&nbsp;</td> 
      <td>&nbsp;</td> 
      <td>&nbsp;</td> 
      <td>&nbsp;</td> 
      <td>&nbsp;</td> 
      <td> 
       <?PHP echo $data->nama?> 
      </td> 
      <td> 
       <?PHP echo $data->posisi?> 
      </td> 
      <td> 
       <?PHP echo $data->nama_perusahan?> 
      </td> 
      <td> 
       <?PHP echo $data->jenis_usaha?> 
      </td> 
     </tr> 
     <?php 
      } 
     ?> 
     <td> 
      <?PHP echo $row->keterangan?> 
     </td> 
</tr> 

無額外的列被添加到循環內部,以使其與您的標題對齊。

+0

差不多先生,我編輯結果圖像從你給的結果, 謝謝, 在表中的最後一行它有'keterangan' coloumn數據,它的顯示,但沒有在這個地方。 –

+0

那麼,你想要在哪裏出現這一列,以及多少次? – TBowman

+0

我將色標移動到第二排,感謝您的幫助。 –