Remove duplicate rows in a Worksheet with C++
Removing duplicate rows is one of Microsoft Excel’s many useful features. It allows users to remove duplicate rows in a Worksheet, and you can pick which columns should be checked for duplicate information.
Aspose.Cells provides the Cells::RemoveDuplicates()
method for this purpose. You can also set startRow
, startColumn
, endRow
, and endColumn
to pick up columns.
Following are the sample files which can be downloaded for testing this feature:
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
<span class="c1">// Create workbook
Workbook book(u"removeduplicates.xlsx");
<span class="c1">// Remove duplicates from the first worksheet
book.GetWorksheets().Get(0).GetCells().RemoveDuplicates(0, 0, 5, 3);
<span class="c1">// Save the result
book.Save(u"removeduplicates-result.xlsx");
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s">"Duplicates removed successfully!"</span> <span class="o"><<</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
<span class="n">Aspose</span><span class="o">::</span><span class="n">Cells</span><span class="o">::</span><span class="n">Cleanup</span><span class="p">();</span>
}