Sort Data

Using Aspose.Cells to Sort Data in a Worksheet

  1. Create a Microsoft Excel file with different data sets or contents. I created a new workbook in Microsoft Excel and added sample data into cells on the first worksheet. The template worksheet created in Microsoft Excel


  1. Download and install Aspose.Cells:
    1. Download Aspose.Cells for Java.
    2. Install it on your development computer.
  1. Create a project. Create a new console application in an editor or Notepad.
  2. Add a class path. To set a Class Path using Eclipse:
    1. Extract the Aspose.Cells.jar and dom4j_1.6.1.jar from
    2. Set the classpath of project in Eclipse:
    3. Select your project in Eclipse and then click menus Project-Properties.
    4. Select “Java Build Path” in the left side of the popup window, then select the “Libraries” tab, click “Add JARs” or “Add External JARs” to select Aspose.Cells.jar and dom4j_1.6.1.jar and add them into build paths.
    5. write application to invoke APIs of Aspose’s components. Or you set it at runtime at the DOS prompt in Windows.
 javac -classpath %classpath%;e:\Aspose.Cells.jar;  ClassName .javajava -classpath %classpath%;e:\Aspose.Cells.jar;  ClassName
  1. Sort the data in the worksheet:
    1. Add code to the project.
  1. Execute the program.

When the above code is executed, the data is sorted:

Output file