Solved

Excel sort problem

Posted on 2011-03-08
2
1,057 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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

10 Experts available now in Live!

Get 1:1 Help Now