Copy columns in an Excel worksheet
This REST API copies columns in an Excel worksheet. The Copy Columns operation lets you duplicate a single column or a range of columns and insert the copy at a specified location within the same worksheet.
REST API
POST https://api.aspose.cloud/v3.0/cells/{name}/worksheets/{sheetName}/cells/columns/copy
Request Parameters
| Parameter Name | Type | Location | Description |
|---|---|---|---|
| name | string | path | The workbook name. |
| sheetName | string | path | The worksheet name. |
| sourceColumnIndex | integer | query | 0‑based index of the column to copy. |
| destinationColumnIndex | integer | query | 0‑based index where the copied column(s) will be inserted. |
| columnNumber | integer | query | Number of consecutive columns to copy. |
| worksheet | string | query | (Optional) Worksheet identifier used when the worksheet name differs from the path. |
| folder | string | query | Path to the folder containing the workbook in Aspose Cloud storage. |
The OpenAPI Specification defines the full contract for this operation.
cURL Example
curl -X POST "https://api.aspose.cloud/v3.0/cells/test.xlsx/worksheets/Sheet1/cells/columns/copy?sourceColumnIndex=1&destinationColumnIndex=12&columnNumber=10" \
-H "Authorization: Bearer $ASPOSE_TOKEN" \
-H "accept: application/json"
Response
{
"Code": 200,
"Status": "OK"
}
Error Handling
The API returns standard HTTP status codes with a JSON payload describing the error.
| Status Code | Meaning | Example JSON Body |
|---|---|---|
| 400 | Bad request – invalid parameters | { "Code": 400, "Message": "Invalid column index." } |
| 401 | Unauthorized – missing or invalid token | { "Code": 401, "Message": "Access token is invalid or expired." } |
| 404 | Not found – workbook or worksheet does not exist | { "Code": 404, "Message": "Workbook not found." } |
| 500 | Internal server error – unexpected condition | { "Code": 500, "Message": "An unexpected error occurred." } |
How to troubleshoot: Verify that the access token is current, the workbook and worksheet names are correct, and that
sourceColumnIndex,destinationColumnIndex, andcolumnNumberare within the worksheet’s column range.
Cloud SDK Family
Using an SDK is the best way to speed up development. 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 make calls to Aspose.Cells web services using various SDKs: