Sort Data of Range on an Excel Worksheet

The REST API sorts data within a specified range on an Excel worksheet.

REST API

POST https://api.aspose.cloud/v3.0/cells/{name}/worksheets/{sheetName}/sort

Request parameters

Parameter Name Type Location Required Description
name string path Yes The workbook name.
sheetName string path Yes The worksheet name.
cellArea string query Yes The cell range to be sorted (e.g., A5:A10).
dataSorter object body Yes JSON object that defines the sorting settings (see schema below).
folder string query No The folder that contains the workbook.
storageName string query No The name of the storage where the workbook is located.

dataSorter object schema – The body must contain a JSON object with the following properties:

  • CaseSensitive (boolean, required) – Determines whether the sort is case‑sensitive.
  • HasHeaders (boolean, required) – Indicates whether the range includes a header row.
  • KeyList (array, required) – A collection of sorting keys. Each key object includes:
    • Key (integer) – Zero‑based column index.
    • SortOrder (string)"ascending" or "descending".
  • SortLeftToRight (boolean, required) – If true, sorting proceeds left‑to‑right; otherwise top‑to‑bottom.
  • (Optional) CaseOrder, SortLeftToRight, etc., may also be supplied according to the OpenAPI specification.

The OpenAPI Specification defines a publicly accessible programming interface and lets you carry out REST interactions directly from a web browser.

You can use the cURL command‑line tool to access Aspose.Cells web services easily. The following example shows how to make a call to the Cloud API with cURL.

Error handling – The API can return standard HTTP error codes. Typical responses include:

HTTP Status Code Message
400 400 Bad request – missing or invalid parameters.
401 401 Unauthorized – invalid or absent JWT token.
404 404 Not found – workbook or worksheet does not exist.
500 500 Internal server error.

The response body follows the pattern { "Code": <status>, "Message": "<description>", "Status": "Error" } for error cases.

Cloud SDK Family

Using an SDK is the fastest way to develop. An SDK handles low‑level details so you can focus on your project tasks. Please check out the GitHub repository for a complete list of Aspose.Cells Cloud SDKs.

The following code examples demonstrate how to call Aspose.Cells web services using various SDKs: