Reputation: 6668
I am using C# and wish to sort some data based on two columns. I have looked at various pages on the internet and have come up with the code below. The issue how ever is that the code does not compile.
I'm using Excel 2013 & in .Net the Microsoft Excel object library is version 15. I can do everything else I need to do in Excel expect sorting the data.
The 3rd line of the sort method where it has Type.Missing is highlighted. It says argument 5 cannot convert from object to Microsoft.Office.Interop.Excel.XlSortOrder.
Excel.Range rngSort = _xlWorksheet.get_Range("A2", "J" + lastRow);
rngSort.Sort(rngSort.Columns[1, Type.Missing], Excel.XlSortOrder.xlAscending,
rngSort.Columns[2, Type.Missing], Type.Missing, Excel.XlSortOrder.xlAscending,
Type.Missing, Excel.XlSortOrder.xlAscending,
Excel.XlYesNoGuess.xlYes, Type.Missing, Type.Missing,
Excel.XlSortOrientation.xlSortColumns,
Excel.XlSortMethod.xlPinYin,
Excel.XlSortDataOption.xlSortNormal,
Excel.XlSortDataOption.xlSortNormal,
Excel.XlSortDataOption.xlSortNormal);
rngSort = null;
Upvotes: 1
Views: 3639