I was wondering if there was a way to read and sort a worksheet with a key column that is formatted in the form of:
Where e.g. 18.104.22.168 should be after 1.2 in the sort order, as normally it would take it as text and put it before 1.2.
Due to constraints, I'm not able to edit the Excel file itself so I was thinking either write it to a DataTable and manipulate it there or any other ideas would be appreciated. I need to format the data so that it's sorted and be able to extract the level order from the decimals.
Thank you for contacting Infragistics!
As long as your column is set up a number instead of a string you should be able to apply a sort t the worksheet and have it sort in the matter you wish:
I have two issues:
Even in just normal Excel, in order to retain the value 1.10, it gets stored as text, or else it would turn into 1.1.
Also, when I try to sort that column, I get problems where 1.10 comes before 1.2, and I'm trying to remedy that.
I want to somehow be able to sort the file through code to result in e.g.: 1.1, 1.2, 1.10, 1.13
Thank you for the update. You can try using the CustomListSortCondition www.infragistics.com/.../infragistics.documents.excel~infragistics.documents.excel.sorting.customlistsortcondition_members
Otherwise you would have to apply your own custom sort to the data manually.
Thanks for the idea! I wrote my own sorting algorithm that works for sorting a list of values in a single column. How would I implement that into my code to be able to sort the entire sheet based on that one key column?
Sorry, I just wanted to mention that the algorithm that I wrote was being used as a comparer in a C# list sort function. e.g. myList.Sort(mySortingAlgo)
Are there any changes that I would need to adjust this to sorting in Excel?