We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Match VBA Sorting


I have to convert some pre-existing VBA Macro code to .NET / ASPOSE Cells. A lot of sorting is done via VBA. I am wondering how to mimic it, exactly, in ASPOSE.Cells.

I am not very familiar with the Excel API via VBA nor all of the tricks associated to it... nor have I used ASPOSE extensively.

It appears that the ASPOSE Cells DataSorter class does not expose MatchCase, Orientation, DataOption1 etc. etc. And I am also wondering if Range("A2") in the VBA code will equate to Column 0?

The VBA code for a sort looks as follows:

Selection.Sort Key1:=Range("A2"), Order1:=xlDescending, Key2:=Range("B2") _

, Order2:=xlAscending, Key3:=Range("C2"), Order3:=xlAscending, Header:= _

xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _

DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _


And my .NET code looks as follows:

sorter.Key1 = 0;

sorter.Key2 = 1;

sorter.Key3 = 2;

sorter.Order1 = Aspose.Cells.SortOrder.Descending;

sorter.Order2 = Aspose.Cells.SortOrder.Ascending;

sorter.Order3 = Aspose.Cells.SortOrder.Ascending;

ca.StartRow = 1;

ca.StartColumn = 0;

ca.EndRow = shProcData.Cells.MaxDataRow;

ca.EndColumn = 6;

sorter.Sort(shProcData.Cells, ca);

Thanks in advance,

Jai Singh Khalsa


1,Will Range("A2") in the VBA code equate to Column 0?

Yes, you are right. Range("B2") means column 1.

2,We have supported most of options except DataOption.Please check the following map:

Aspose.Cells.DataSorter.CaseSensitive ->VBA.MatchCase


We will look into DataOption later,but i am afraid that we could not support it soon.