Solved

Excel sort problem

Posted on 2011-03-08
2
1,064 Views
Last Modified: 2012-05-11
Hi, I have a excel sort problem with C#. Please look at my code.
xlRange.Sort((Excel.Range)xlWorkSheet1.Cells[1, 2], Excel.XlSortOrder.xlAscending,
            Type.Missing, Type.Missing, Excel.XlSortOrder.xlAscending,
            Type.Missing, Excel.XlSortOrder.xlAscending,
            Excel.XlYesNoGuess.xlNo, Type.Missing, Type.Missing,
            Excel.XlSortOrientation.xlSortRows,
            Excel.XlSortMethod.xlStroke,
            Excel.XlSortDataOption.xlSortNormal,
            Excel.XlSortDataOption.xlSortNormal,
            Excel.XlSortDataOption.xlSortNormal);

Open in new window

Here, three questions:
1) Cells[1, 2] means sort fron row 1, column 2?
2) What is the sort direction? I mean sort row or sort column?
3) I google search with msdn but not found the corresponding materials. Could you please give me a link?
Thanks.
0
Comment
Question by:zhshqzyc
2 Comments
 
LVL 6

Accepted Solution

by:
nandithaa earned 50 total points
ID: 35079815
Please refer following sites:
http://msdn.microsoft.com/en-us/library/wxks80sb%28v=vs.80%29.aspx
http://msdn.microsoft.com/en-us/library/wxks80sb.aspx


xlRange.Sort((Excel.Range)xlWorkSheet1.Columns[1, missing], Excel.XlSortOrder.xlAscending,
            Type.Missing, Type.Missing, Excel.XlSortOrder.xlAscending,
            Type.Missing, Excel.XlSortOrder.xlAscending,
            Excel.XlYesNoGuess.xlNo, Type.Missing, Type.Missing,
            Excel.XlSortOrientation.xlSortColumns,
            Excel.XlSortMethod.xlStroke,
            Excel.XlSortDataOption.xlSortNormal,
            Excel.XlSortDataOption.xlSortNormal,
            Excel.XlSortDataOption.xlSortNormal);

Open in new window


Hope this helps....
0
 

Author Comment

by:zhshqzyc
ID: 35083308
So if I want to sort row 1 but from the second cell to the end, I have to defind a range first.
 xlRange = xlWorkSheet1.get_Range("B1:" + GetExcelColumnName(nCols) + nRows.ToString(), Type.Missing);

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get String split 5 46
Convert to Hour/minute textbox and compare 3 52
MVC5 Dataformat String for Phone not working 3 25
What .NET website keeps me current? 9 52
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now