Distinct values / Duplicate values

Hello,
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 4.7.0.0.
Thanks

Hi,

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:

Sample code:


Workbook workbook = new Workbook();
workbook.Open(“e:\test\CheckValues.xls”);
Worksheet worksheet = workbook.Worksheets[0];

//Define Area: A1:A11;
CellArea area = new CellArea();
area.StartRow = 0;
area.StartColumn = 0;
area.EndRow = 10;
area.EndColumn = 0;

Aspose.Cells.Cell foundCell;
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)
{
MessageBox.Show(foundCell.Name);
prevCell = foundCell;
}

}



Thank you.

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?

Hi,

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.

Thank you.

Hi,

Please try the attached version. We have supported this feature.

Please try the new method Cells. RemoveDuplicates method.

Thank you.

Thanks amjad for the reply.

Hi,

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:
Aspose.Cells
for .NET v7.1.2.7

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.