What is the best way to know if a column contains duplicate values or not? I dont care about the values itself. I just need to know if there are any or not. Performance is very important here. I am using 18.104.22.168.
Well, I think you may use some Find methods of the Aspose.Cells.Cells class to check the duplicate values if there is any in a range of cells or column, e.g Cells.FindString, Cells.Find, Cells.FindNumber, Cells.FindStringContains etc.
See the sample code below for your reference:
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets;
//Define Area: A1:A11;
CellArea area = new CellArea();
area.StartRow = 0;
area.StartColumn = 0;
area.EndRow = 10;
area.EndColumn = 0;
Aspose.Cells.Cell prevCell = null;
int cnt =0;
//Scan in the first column.
//Search for “abc” string in an area.
for (int i = 0; i < 11; i++)
foundCell = worksheet.Cells.FindString(“abc”, prevCell, area);
if (foundCell != null)
prevCell = foundCell;
But I do not know the value to check for and besides that the value can always be different. Excel 2007 has a function to find duplicates/remove duplicates. Does that exist in aspose.cells?
Well, I am afraid, the Excel 2007 "Remove Duplicate" feature is not supported.
We have logged it into our issue tracking system with an issue id: CELLSNET-14330.
We will inform your when it is sorted out.
Please try the attached version. We have supported this feature.
Please try the new method Cells. RemoveDuplicates method.
Thanks amjad for the reply.
Thanks for your posting.
Above posts are quite old and using the very old version of Aspose.Cells for .NET.
We strongly recommend you to use the latest version:
for .NET v22.214.171.124
and if you are using the older version, then please upgrade your code.
If you get any other question or face some issue, please feel free to post, we will help you asap.