Click here to Skip to main content
15,789,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
DevEpress Spreadsheet doesn't currently support "Remove Duplicate" function. I want to write a C# code to do this manually. I have a column of values. Some of them are duplicate and those duplicate values may or may not be adjacent. I want to remove corresponding row of duplicate values.
I tried my own code but it doesn't work properly.
Hoe can I get desired result?

What I have tried:

IWorkbook workbook = spreadsheetControl.Document;
           Worksheet worksheet = workbook.Worksheets["Sheet1"];
           CellRange range = worksheet.GetUsedRange();
           int LastRow = range.BottomRowIndex;
           for (int i = 0; i < LastRow; i++)
               for (int n = 1; n < LastRow; n++)
                   if (worksheet.Cells[i,0].Value == worksheet.Cells[i+n,0].Value)
Updated 24-Jan-21 10:15am

1 solution

This will only find adjacent values. It will work to do what you asked it to. To find all duplicates, create a list of values. As you find a value, if it's already in the list, it exists, so delete it
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900