Free Support Forum - aspose.com

Cannot sort the data with first sortkey as blank

Hi Aspose Team,

While sorting the data in ms excel if the first sort key is given as blank then an error message "First sort by box cannot be blank" is thrown. Please confirm if this is the expected behaviour for Aspose as well. Attached document consisting of the screen shot.

Thanks,

Muin

Hi,

I have checked it on Ms-Excel 2010 and found it is expected behavior. Please see the screenshot.

Aspose.Cells behavior should also be the same because it mimics Ms-Excel. If you find some error, then please share your code. We will check it soon.

Screenshot:

Hi,


Please try the new fix: Aspose.Cells for Java (Latest Version)


From this fix we provide new APIs for data sorting:


1). Sorter com.aspose.cells.Cells.getDataSorter(int startRow, int startColumn, int endRow, int endColumn)

Gets data sorter to sort data in given range.

Parameters:
startRow Start row index.
startColumn Start column index.
endRow End row index.
endColumn End column index.
Returns:
Sorter object for sorting data.
2). com.aspose.cells.Sorter

Sorter for cells data sorting.

3). SortValueCriteria com.aspose.cells.Sorter.addLevel(int fieldIndex, byte sortOrder)

Adds new level to sort data by values.

See Also:
SortOrderType
Parameters:
fieldIndex the 0-based field index in the sorted range. Top-left row/column's field index is 0.
sortOrder sort order of the new value sort condition.
Returns:
sort criteria for the new level.
4). void com.aspose.cells.Sorter.sort()

Sorts the data in range of this sorter.

Code example:
Sorter sorter = cells.getDataSorter(ca.getStartRow(), ca.getStartColumn(), ca.getEndRow(), ca.getEndColumn());
sorter.addLevel(0, SortOrderType.ASCENDING);
sorter.addLevel(1, SortOrderType.DESCENDING);
sorter.addLevel(2, SortOrderType.ASCENDING);
...
sorter.sort();