title: Export to excel with multiple sheet using codeigniter?
body: <p>I have a table which contain employee details.I have to export these employee details in excel sheet.In excel each sheet contain each employee details and sheet name should be employee name. In models I have writen a query to fetch the details from database the following is the sample view code. This following code will give only one sheet of result How I implement multiple sheet excel   </p>
  
  <pre><code> &lt;?PHP
      header ("Cache-Control: no-cache, must-revalidate");    
      header ("Pragma: no-cache");    
      header ('Content-type: application/x-msexcel');
      header ("Content-Disposition: attachment; filename=employee_workbook.xls" );  
  
      $this-&gt;load-&gt;view('reader/reader');
  
  ?&gt;  
   &lt;?PHP
      if($result-&gt;num_rows()&gt;0)
      {
    ?&gt;
  
    &lt;?PHP foreach($result-&gt;result_array() as $entry):?&gt;  
  &lt;table width="100%" border="1" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF"&gt;
    &lt;tr&gt;
      &lt;td width="200" bgcolor="#FFFFFF"&gt;&lt;strong&gt;Employee ID&lt;/strong&gt;&lt;/td&gt;
      &lt;td width="150" bgcolor="#FFFFFF"&gt;&lt;strong&gt;Employee Name&lt;/strong&gt;&lt;/td&gt;
      &lt;td width="150" bgcolor="#FFFFFF"&gt;&lt;strong&gt;Check in Time&lt;/strong&gt;&lt;/td&gt;
      &lt;td width="100" bgcolor="#FFFFFF"&gt;&lt;strong&gt;Project Name&lt;/strong&gt;&lt;/td&gt;        
      &lt;td width="100" bgcolor="#FFFFFF"&gt;&lt;strong&gt;Check Out Time&lt;/strong&gt;&lt;/td&gt;   
    &lt;/tr&gt;
  
    &lt;tr&gt;
      &lt;td align="left" bgcolor="#FFFFFF"&gt;&lt;?php echo $entry['emp_id']; ?&gt;&lt;/td&gt;
      &lt;td align="left" bgcolor="#FFFFFF"&gt;&lt;?PHP echo $entry['emp_name']; ?&gt;&lt;/td&gt;
      &lt;td align="left" bgcolor="#FFFFFF"&gt;&lt;?PHP echo $entry['in_time']; ?&gt;&lt;/td&gt;
      &lt;td align="left" bgcolor="#FFFFFF"&gt;&lt;?PHP echo $entry['prj_name']; ?&gt;&lt;/td&gt;
      &lt;td align="left" bgcolor="#FFFFFF"&gt;&lt;?PHP echo $entry['out_time']; ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;?PHP endforeach;?&gt;
  &lt;?PHP
      }   
  ?&gt;
  </code></pre>