Hi,
Please try the attached verion.
This fix applies validation and verifies for the input SortOrderType value when calling setOrder*() methods. If you input illegal value, that is, neither SortOrderType.ASCENDING nor SortOrderType.DESCENDING, will cause an Exception.
Sample code:
Workbook workbook = new Workbook();
Integer[] arrN = new Integer[]{new Integer(1), new Integer(15), new Integer(3),};
Cells cells = workbook.getWorksheets().getSheet(0).getCells();
cells.importArray(new int[]{1, 1, 15, 3, 15, 3}, 0, 0, true);
cells.importObjectArray(arrN, 0, 1, true);
cells.importObjectArray(arrN, 3, 1, true);
cells.importArray(new String[]{"1", "3", "15", "1", "15", "3"}, 0, 2, true);
cells.copyCellRange(cells, 0, 0, 8, 0, 6, 3);
cells.copyCellRange(cells, 0, 0, 16, 0, 6, 3);
DataSorter ds = workbook.getDataSorter();
ds.setKey1(0);
try
{
ds.setOrder1((byte)123);
//ds.setOrder1(SortOrderType.DESCENDING);
}
catch(IllegalArgumentException e)
{
System.out.println("As expected, check illegal value of ordertype: " + e.getMessage());
}
ds.sort(cells, new CellArea(0, 0, 5, 0));
ds.setKey1(1);
ds.setOrder1(SortOrderType.ASCENDING);
ds.sort(cells, new CellArea(0, 1, 5, 1));
ds.setKey1(2);
ds.setOrder1(SortOrderType.DESCENDING);
ds.sort(cells, new CellArea(0, 2, 5, 2));
ds.setKey1(0);
ds.setOrder1(SortOrderType.ASCENDING);
ds.setKey2(1);
ds.setOrder2(SortOrderType.ASCENDING);
ds.setKey3(2);
ds.setOrder3(SortOrderType.DESCENDING);
ds.sort(cells, new CellArea(16, 0, 21, 2));
workbook.save("E:\\Files\\sort_output.xls");
Thank you.