Add Empty Column to Excel Worksheet Using Aspose.Cells Cloud API
This REST API inserts one or more columns into a worksheet.
Prerequisites
Before calling this endpoint, ensure you have completed the following steps:
- Obtain a valid OAuth 2.0 access token and include it in the
Authorizationheader. - Store the target workbook in the selected storage (default = “Default”) or specify the appropriate
folderandstorageNameparameters. - Verify that the worksheet name provided in
sheetNameexists in the workbook.
PutInsertWorksheetColumns API
PUT https://api.aspose.cloud/v3.0/cells/{name}/worksheets/{sheetName}/cells/columns/{columnIndex}?totalColumns=1
Security and Authentication
The Aspose.Cells Cloud APIs are secure and require JWT token-based authentication.
Request parameters
| Parameter Name | Type | Location | Description |
|---|---|---|---|
| name | string | path | The workbook file name. |
| sheetName | string | path | The worksheet name. |
| columnIndex | integer | path | Zero‑based index of the column where insertion begins. |
| totalColumns | integer | query | Number of columns to insert. |
| updateReference | boolean | query | When true, cell references are updated to reflect the insertion. |
| folder | string | query | Path to the folder containing the workbook. |
| storageName | string | query | Name of the storage service. |
Notes
- The
columnIndexmust be between 0 and the current number of columns in the worksheet. Inserting beyond the existing range will automatically expand the sheet. - Inserting multiple columns (
totalColumns> 1) shifts existing columns to the right. - The
updateReferenceflag defaults tofalse; set totrueto update formulas and named ranges.
The OpenAPI Specification defines a publicly accessible programming interface and lets you perform REST interactions directly from a web browser.
You can use the cURL command‑line tool to call Aspose.Cells web services. The following example shows a complete request, including authentication and the correct path parameter.
Response codes
| Code | Description |
|---|---|
| 200 | Column(s) inserted successfully. |
| 400 | Bad request – missing or invalid parameters. |
| 401 | Unauthorized – invalid or missing token. |
| 404 | Workbook or worksheet not found. |
| 500 | Internal server error. |
Example error responses
// 400 Bad Request – missing or invalid parameters
{
"Code": 400,
"Message": "Invalid parameter: totalColumns must be a positive integer."
}
// 401 Unauthorized – invalid or missing token
{
"Code": 401,
"Message": "Authentication failed. Access token is missing or invalid."
}
// 404 Not Found – workbook or worksheet does not exist
{
"Code": 404,
"Message": "Workbook 'test.xlsx' not found."
}
// 500 Internal Server Error
{
"Code": 500,
"Message": "An unexpected error occurred on the server."
}
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 logic. See 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: