Sort Excel Data in Java

This article demonstrates how to sort data within a cell range using Spire.XLS for Java.

import com.spire.xls.Worksheet;
import com.spire.xls.Workbook;
import com.spire.xls.OrderBy;
import com.spire.xls.ExcelVersion;

public class SortData {

    public static void main(String[] args) {

        //Create a Workbook object
        Workbook workbook = new Workbook();

        //Load the sample Excel file

        //Get the first worksheet
        Worksheet sheet = workbook.getWorksheets().get(0);

        //Specify the column index and the sort mode. The column index starts from 0.

        //Specify the range to sort

        //Save the document
        workbook.saveToFile("SortData.xlsx", ExcelVersion.Version2016);

Sort Excel Data in Java