Quantcast
Channel: PHPExcel Forum Rss Feed
Viewing all articles
Browse latest Browse all 2707

New Post: Is it possible to delete all BUT duplicate rows?

$
0
0
I'm trying to find a way to delete all BUT the repeated rows in a file, I know it's possible to delete the duplicates on a file using something like this:

$worksheet = $objPHPExcel->getActiveSheet();
    foreach ($worksheet->getRowIterator() as $row) {
        $rowIndex = $row->getRowIndex();
        foreach ($worksheet->getRowIterator($rowIndex + 1) as $testRow) {
            if ($testRow == $row) {
                $worksheet->removeRow($rowIndex);
            }
        }
taken from here
However I need to do pretty much the opposite, delete all the rows that doesn't have any duplicates in the file.

*Why do I need this: The duplicate rows are the intersection between M x M sets with data. It's way easier to do it directly on the file that having to considerate the M x M possible results.*

I'd greatly appreciate any guidance you might offer me.

Viewing all articles
Browse latest Browse all 2707

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>