Update a shape on an Excel worksheet

This REST API updates a shape on an Excel worksheet.

REST API

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

Request parameters

Parameter Name Type Location Description
name string path The name of the workbook file.
sheetName string path The name of the worksheet that contains the shape.
shapeindex integer path The zero‑based index of the shape within the worksheet.
dto object body The shape data‑transfer object that contains the updated properties (see DTO Schema below).
folder string query The folder where the workbook is stored.
storageName string query The name of the Aspose Cloud storage.

DTO Schema

The dto object contains the properties that can be updated. All fields are optional unless otherwise noted.

Field Type Required Description
Name string No New name for the shape.
UpperLeftRow integer No Row index of the shape’s upper‑left corner.
UpperLeftColumn integer No Column index of the shape’s upper‑left corner.
Width integer No Width of the shape (in points).
Height integer No Height of the shape (in points).
RotationAngle integer No Rotation angle in degrees.
IsHidden boolean No true to hide the shape.
IsLocked boolean No true to lock the shape.
Font object No Font settings (see OpenAPI spec for sub‑properties).
No Additional properties such as HtmlText, AlternativeText, ZOrderPosition, etc.

For a complete list, refer to the official OpenAPI specification: https://apireference.aspose.cloud/cells/#/Shapes/PostWorksheetShape.

Request headers

  • Content-Type: application/json
  • Accept: application/json
  • Authorization: Bearer <accessToken> (the JWT token from the _Authentication step)_

Request body (example)

{
  "Name": "MyShape",
  "UpperLeftRow": 2,
  "UpperLeftColumn": 3,
  "Width": 150,
  "Height": 80,
  "RotationAngle": 0,
  "IsHidden": false,
  "IsLocked": false,
  "Font": {
    "Name": "Calibri",
    "Size": 12,
    "IsBold": true,
    "Color": { "A": 255, "R": 0, "G": 0, "B": 0 }
  }
}

Example with cURL (command‑line tool)

curl -v "https://api.aspose.cloud/v3.0/cells/Book1.xlsx/worksheets/Sheet1/shapes/0?folder=Temp" \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <accessToken>" \
  -d '{
        "Name": "UpdatedShape",
        "UpperLeftRow": 1,
        "UpperLeftColumn": 1,
        "Width": 120,
        "Height": 60,
        "IsHidden": false,
        "IsLocked": false
      }'

Response

{
  "Code": 200,
  "Status": "OK"
}

Error handling – The API may return the following status codes:

Code Meaning Typical cause
400 Bad Request Invalid JSON or missing required fields.
401 Unauthorized Missing or invalid JWT token.
404 Not Found Workbook, worksheet, or shape index does not exist.
500 Internal Server Error Unexpected server‑side problem.

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 call Aspose.Cells web services using various SDKs: