How to Sort Ascending Order?

String Ascending order sorting on time Empty cell go first. I need to Values First after Empty needed.

Example:

Given values

  1. (empty)
  2. 3,777
  3. 150,820
  4. 123,454

How to Sorting this format?

  1. 3,777
  2. 123,454
  3. 150,820
  4. (empty)

@Raj1995Java,

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)