title: PHPExcel -> creating duplicate worksheets
body: <p>I am trying to create a application that will parse a CSV file of items, and do specific things for each item in the CSV file.  I have the upload/parsing figured out, however, when I export it to Excel each CSV entry is duplicated in the worksheets.  For example, if there were 4 entries in the CSV file, the first entry is duplicated 4 times, the second entry is duplicated 3 times, etc.  I have look through documentation for days, and I am unable to locate where I am going wrong.  Below is the code that is generating the XLSX file.</p>
  
  <pre><code>if (in_array($type,$csv_types)){
  if (move_uploaded_file($tmp_name, $path)){
      foreach ($csv as $locar){
          foreach ($locar as $locid){
              $locs[] = $locid;
              $count = count($locs);
              /*if ($i &lt; $count - 1){
                  $objPHPExcel-&gt;createSheet();
                  $i++;
              }*/
              $xmls = array();
              foreach ($locs as $locids){
                  $url = 'Link to XML API' . $locids;
                  $xmls[] = $url;
                  $objWorkSheet = $objPHPExcel-&gt;createSheet();
                  $objWorkSheet-&gt;setTitle($locids);
                  $objPHPExcel-&gt;setActiveSheetIndexByName($locids);
  
  
              }
              foreach ($xmls as $links){
                  $locations = explode("=", $links);
                  $row = 1;
  
                  //
                  $objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('A'.$row,'Location ID:' . $locations[1]);
                  $row++;
                  $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('A'.$row,'Database');
                  $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('B'.$row,'URL');
                  $row++;
  
  
                  $xml = simplexml_load_file($links);
  
                  foreach ($xml as $product){
                      foreach ($product-&gt;title as $item){
                          $dbtitle = str_replace(',',' ',$item);
                          $dblink = $product-&gt;link;
  
                      }
                      $objPHPExcel-&gt;setActiveSheetIndexByName($locations[1]);
                      $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('A'.$row,$dbtitle);
                      $objPHPExcel-&gt;getActiveSheet()-&gt;SetCellValue('B'.$row,$dblink);
                      $row++;
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>The Links that are generated by the code are only showing up in the correct worksheet (the first created worksheet for the entry in the csv). Any help would be greatly appreciated. </p>