Export to word from php doesn't seem to work for me...

Posted by chandru_cp on Stack Overflow See other posts from Stack Overflow or by chandru_cp
Published on 2010-03-29T13:23:58Z Indexed on 2010/04/01 6:03 UTC
Read the original article Hit count: 212

Filed under:
|
|

I exported data from php page to word document but the problem is the header is not available in all pages....

Header is present in the first page but not in the next pages of the word document.....

Here is my code,

 function changeDetails()
 {
             $bType = $this->input->post('textvalue');
if($bType == "word")
   {
    $this->load->library('table');
    $data['countrytoword'] = $this->AddEditmodel1->export();
    $this->table->set_heading('Name','Country','State','Town');
    $out =  $this->table->generate($data['countrytoword']); 
    header("Content-Type: application/vnd.ms-word");
    header("Expires: 0");
    header("Cache-Control:  must-revalidate, post-check=0, pre-check=0");
    header("Content-disposition: attachment; filename=$cur_date.doc");
    echo '<br><br>';
    echo '<strong>CountryList</strong><br><br>';
    print_r($out);
   }
}
<? if(isset($countrytoword)) {
?>
 <table align="center" border="0">
 <tr>
  <td>
   Name
  </td>
  <td>
   Country
  </td>
  <td>
   State
  </td>
  <td>
   Town
  </td>

 </tr>

<?   foreach($countrytoword as $dsasffd)
{
?>
 <tr>
  <td><?= $dsasffd['dbName'] ?></td>
  <td><?= $dsasffd['dbCountry']; ?></td>
  <td><?= $dsasffd['dbState']; ?></td>
  <td><?= $dsasffd['dbTown']; ?></td>

<? } } ?>
</tr>
 </table>

© Stack Overflow or respective owner

Related posts about php

Related posts about export-to-word