0
votes

I want to read a column in Excel worksheet using SpreadSheetGear (.NET) and get unique values in that column back.

enter image description here

Example: From the above Excel worksheet, I need to read column B and get back unique values "John" "Mike" and "Wayne"

In real life, there can be 1,000,000+ rows so efficiency is important. How is that achieved?

1
Hello, Is it not as simple as Locking the View m_WorkbookView.GetLock(); then getting the Range SpreadsheetGear.IRange oRange = m_ViewLock.Workbook.ActiveWorksheet.Cells[aRowFrom, aColFrom, aRowTo, aColTo]; and reading from the range. You just add the names into a Dictionary and check whether they already are in the Dictionary before adding them. It seems so simple that I feel I am missing something obvious hereMichael Moreno
If you want a solution using formulas, take a look at the answers to this question: stackoverflow.com/questions/1429899/….Daniel
Another way of approaching this would be to choose a .net data structure that only allows distinct elements. Dictionary springs to mind here.SBI

1 Answers

0
votes

I Understand that the post is quite old but could be helpful for others: The comment entered by @Michael Moreno will be helpful and I endorse the idea. But the concern is: How one can judge the number of rows or columns to iterate the loop. For this I suggest the Property IWorksheet.UsedRange to get the range of data contained by sheet. Curtsy by: @Chris in his thread