title: PHPExcel Multiple sheets
body: <p>Basically I need to take this SQL data and have it create a workbook with different sheet names for each user and the data that belongs to that user. So Smith_Joe would have a sheet named Smith_Joe and in that sheet it would show his information. Here is the sql data:</p>
  
  <pre><code>TeamName      UserID     Deparment     Description
  ---------------------------------------------------
  Smith_Joe    JOE4S       52200          Sales
  Smith_Joe    JOE4S       53002          Budget
  Smith_Joe    JOE4S       43302          Dev
  Black_BJ     BJ3OO       43332          Mrkt
  Steh_Tray    ST44S       65573          Prod
  Steh_Tray    ST44S       52200          Sales
  </code></pre>
  
  <p>So far I have not had much luck but here is the code I have so far:</p>
  
  <pre><code>while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)){
  
  
      $tn         =   $row['TeamName'];
      $userid     =   $row['UserID'];
      $dep        =   $row['Departments'];
      $des        =   $row['Description'];
  
  
      $objWorksheet = new PHPExcel_Worksheet($objPHPExcel);
      $objPHPExcel-&gt;addSheet($objWorksheet);
      $objWorksheet-&gt;setTitle(''. $tn);
  
  
      $objWorksheet-&gt;setCellValue('A2' , $tn);
      $objWorksheet-&gt;setCellValue('B2' ,  $userid);
      $objWorksheet-&gt;setCellValue('C2', $dep);
      $objWorksheet-&gt;setCellValue('D2' , $des);
  </code></pre>
  
  <p>The problem I am getting is I get all the sheets with names but each row is listed on separate sheets. So for an example with the code above. I get Smith_Joe with 3 sheets with one record per sheet. Black_BJ get one sheet and Steh_Tray gets 2 sheets.  They all should just have one sheet each with all their information on it.</p>