Solved

Excel sort problem

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SqlDataBase 7 54
Reference issues in Visual Studio 3 41
VS2010 Build fails to install 14 40
C# class library debugging - Breakpoint will not hit. 8 22
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 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