Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel sort problem

Posted on 2011-03-08
2
Medium Priority
?
1,101 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
nandithaa earned 200 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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