String Ascending order sorting on time Empty cell go first. I need to Values First after Empty needed.
Example:
Given values
- (empty)
- 3,777
- 150,820
- 123,454
How to Sorting this format?
- 3,777
- 123,454
- 150,820
- (empty)
String Ascending order sorting on time Empty cell go first. I need to Values First after Empty needed.
Example:
Given values
How to Sorting this format?
You can sort the column with code snippet as under. See Data Sorting document with example.
// Instantiate a new Workbook object.
Workbook workbook = new Workbook("Ascending.xlsx");
// Get the workbook datasorter object.
DataSorter sorter = workbook.getDataSorter();
// Set the first order for datasorter object.
sorter.setOrder1(SortOrder.ASCENDING);
// Define the first key.
sorter.setKey1(0);
// Sort data in the specified data range
CellArea cellArea = new CellArea();
cellArea.StartRow = 0;
cellArea.StartColumn = 0;
cellArea.EndRow = 3;
cellArea.EndColumn = 0;
sorter.sort(workbook.getWorksheets().get(0).getCells(), cellArea);
// Save the excel file.
workbook.save("DataSorting_out.xls");
Input and output files are attached.Sorting.zip (9.4 KB)