title: How to delete duplicated rows with PHPExcel
body: <p>Hello my dear saviors,</p>
  
  <p>I opened a thread a few days ago asking a way to search/filter rows by a cell value with PHPExcel. A developer from this community saved my day (thanks again man!!!). I've been struggling since now with another question.
  ¿Is it possible to delete all duplicated rows with PHPExcel?
  To put you in situation <strong>here's my example table:</strong></p>
  
  <p>Want to show all rows having "I1/027" in his cell (DONE!), but without repeated rows:</p>
  
  <pre><code>Hours | Place | Name
  ------|-------|-----------------
  3     |I1/027 | example1   //------&gt; Want to add it to my list!!!
  6     |I2/025 | example2   //------&gt; Ignore this (no I1/027)
  7     |I1/030 | example3   //------&gt; Ignore this (no I1/027)
  2     |I1/027 | example4   //------&gt; Want to add it to my list!!!
  3     |I1/027 | example1   //------&gt; Don't want this row, it's repeated!!!
  </code></pre>
  
  <p><strong>And the phpexcel code:</strong></p>
  
  <pre><code>  &lt;?php if(isset($_FILES['file']['name'])) { ?&gt;
     &lt;!-- Container progress bar --&gt;
      &lt;div id="progress" style="width:500px;border:1px solid #ccc;"&gt;&lt;/div&gt;
     &lt;!-- progress info --&gt;
      &lt;div id="information" style="width"&gt;&lt;/div&gt;
  
     &lt;?php require_once 'reader/Classes/PHPExcel/IOFactory.php';
         //Extra functions
          function get_cell($cell, $objPHPExcel){
              //Cell selection
              $objCell = ($objPHPExcel-&gt;getActiveSheet()-&gt;getCell($cell));
              //taking cell value
              return $objCell-&gt;getvalue();
          }
          function pp(&amp;$var){
              $var = chr(ord($var)+1);
              return true;
          }
      //==========Displaying Code
          $name     = $_FILES['file']['name'];
          $tname    = $_FILES['file']['tmp_name'];
          $type     = $_FILES['file']['type'];
  
          if($type == 'application/vnd.ms-excel')
          { // excel 97 extension
              $ext = 'xls';
          }
          else if($type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
          { // excel 2007 and 2010 extensions
              $ext = 'xlsx';
          }else
          { // invalid extension
              echo -1;
              exit();
          }
          $xlsx = 'Excel2007';
          $xls  = 'Excel5';
  
          //read creator
          $objReader = PHPExcel_IOFactory::createReader($$ext);
          //loading
          $objPHPExcel = $objReader-&gt;load($tname);
  
          $dim = $objPHPExcel-&gt;getActiveSheet()-&gt;calculateWorksheetDimension();
          // put $start and $end array
          list($start, $end) = explode(':', $dim);
  
          if(!preg_match('#([A-Z]+)([0-9]+)#', $start, $rslt)){
              return false;
          }
          list($start, $start_h, $start_v) = $rslt;
          if(!preg_match('#([A-Z]+)([0-9]+)#', $end, $rslt)){
              return false;
          }
          list($end, $end_h, $end_v) = $rslt;
  
          //starting to read excel doc
          $table = "&lt;table class='tabla'&gt;";
          for($v=$start_v; $v&lt;=$end_v; $v++){     
              // calculate progress bar
              $percent = intval($v/$end_v * 100)."%";
              // progress bar update
              echo '&lt;script language="javascript"&gt;
              document.getElementById("progress").innerHTML="&lt;div style=\"width:'.$percent.';background-color:#ddd;\"&gt;&amp;nbsp;'.$percent.'&lt;/div&gt;";
              document.getElementById("information").innerHTML="'.$v.' files processed.";&lt;/script&gt;'; 
  
              // buffer flush
              echo str_repeat(' ',1024*64);
              // send exit to navigator
              flush();
              sleep(0.25);
  
              //horizontal reading
              $tempRow= "&lt;tr&gt;";
              $contentFound=false;
  
              for($h=$start_h; ord($h)&lt;=ord($end_h); pp($h)){
                  $cellValue = get_cell($h.$v, $objPHPExcel);
                  $tempRow.= "&lt;td&gt;";
                if($cellValue !== null){
                    if($cellValue=="I1/027") $contentFound=true;
                         $tempRow.= $cellValue;
         }
       $tempRow.= "&lt;/td&gt;";
     }
     $tempRow.= "&lt;/tr&gt;";
  
    if($contentFound) $table.=$tempRow;
      }         
          // process completed
          echo '&lt;script language="javascript"&gt;document.getElementById("information").innerHTML="Process completed"&lt;/script&gt;&lt;br&gt;';
          echo $table;
  }?&gt;
  </code></pre>
  
  <p></p>
  
  <p>Found this function I'm trying to exploit, but without luck:</p>
  
  <pre><code>function removeDuplicates($inputFileName, $objPHPExcel) {
                  $worksheet = $objPHPExcel-&gt;getActiveSheet();
                  $urn = array();
  
                    foreach ($worksheet-&gt;getRowIterator() as $row) {
                        $rowIndex = $row-&gt;getRowIndex();
                        $cellValue = $worksheet-&gt;getCell('A'.$rowIndex)-&gt;getValue();
                        array_push($urn, $cellValue);
                    }
                    $numberOfURNs = count($urn);
  
                    for ($rowIndex = $numberOfURNs; $rowIndex != 1; $rowIndex--) {
                     $cellValue = $worksheet-&gt;getCell('A'.$rowIndex)-&gt;getValue();
  
                        for ($i = $rowIndex - 2; $i != 0; $i--) {
                          if ($urn[$i] == $cellValue) {
                              $worksheet-&gt;removeRow($rowIndex);
                              $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
                              $objWriter-&gt;save($inputFileName);
                              break;
                          }
                        }     
                    }
                    return $objPHPExcel = checkExtension($inputFileName);
              }
  </code></pre>
  
  <p>Thanks a lot in advance!!</p>