Add Worksheet Comment

Add a comment to a specific cell in a worksheet of an Excel workbook using the Aspose.Cells Cloud REST API.


Prerequisites / Authentication

Authorization: Bearer <jwt token>

HTTP Request

PUT https://api.aspose.cloud/v3.0/cells/{name}/worksheets/{sheetName}/comments/{cellName}

Path Parameters

Name Type Required Description
name string ✔️ The workbook file name (e.g., test.xlsx).
sheetName string ✔️ The worksheet name (e.g., Sheet1).
cellName string ✔️ The address of the target cell (e.g., A1).

Query Parameters

Name Type Required Description
folder string optional The folder that contains the workbook.
storageName string optional The storage service name where the file is located.

Request Body

The body must contain a Comment object in JSON format.

{
  "CellName": "A1",
  "Author": "string",
  "HtmlNote": "string",
  "Note": "string",
  "AutoSize": true,
  "IsVisible": true,
  "Width": 10,
  "Height": 10,
  "TextHorizontalAlignment": "Left",
  "TextOrientationType": "NoRotation",
  "TextVerticalAlignment": "Top"
}

Comment Object Fields

Field Type Required Description
CellName string ✔️ Cell address (must match the {cellName} path value).
Author string optional Name of the comment author.
HtmlNote string optional HTML‑formatted comment text.
Note string optional Plain‑text comment.
AutoSize boolean optional Auto‑size the comment box.
IsVisible boolean optional Show the comment by default.
Width / Height number optional Size of the comment box (points).
TextHorizontalAlignment string optional Horizontal alignment (Left, Center, Right).
TextOrientationType string optional Text rotation (NoRotation, Rotate90, …).
TextVerticalAlignment string optional Vertical alignment (Top, Center, Bottom).

cURL Example

curl -v "https://api.aspose.cloud/v3.0/cells/test.xlsx/worksheets/Sheet1/comments/A1" \
  -X PUT \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer <jwt token>" \
  -d '{
        "CellName": "A1",
        "Author": "test",
        "HtmlNote": "<font style=\"font-weight:bold;font-family:Tahoma;font-size:9pt;color:#000000;text-align:left;\">this is a comment</font>",
        "Note": "this is a comment",
        "AutoSize": true,
        "IsVisible": true,
        "Width": 10,
        "Height": 10,
        "TextHorizontalAlignment": "Left",
        "TextOrientationType": "NoRotation",
        "TextVerticalAlignment": "Top"
      }'

Response Schema

Field Type Description
Comment object The created comment object (see Comment Object Fields above, plus link metadata).
Code integer HTTP status code returned by the API (e.g., 200).
Status string Textual status message (e.g., "OK").

The Comment object also contains a link sub‑object:

Sub‑field Type Description
Href string Self‑reference URL for the comment resource.
Rel string Relationship type (self).
Title string Optional title (may be null).
Type string Optional MIME type (may be null).

Successful Response Example

{
  "Comment": {
    "CellName": "A1",
    "Author": "test",
    "HtmlNote": "<Font Style=\"FONT-WEIGHT: bold;FONT-FAMILY: Tahoma;FONT-SIZE: 9pt;COLOR: #000000;TEXT-ALIGN: left;\">this is a comment</Font>",
    "Note": "this is a comment",
    "AutoSize": true,
    "IsVisible": true,
    "Width": 10,
    "Height": 10,
    "TextHorizontalAlignment": "Left",
    "TextOrientationType": "NoRotation",
    "TextVerticalAlignment": "Top",
    "link": {
      "Href": "/test.xlsx/worksheets/Sheet1/comments/A1",
      "Rel": "self",
      "Title": null,
      "Type": null
    }
  },
  "Code": 200,
  "Status": "OK"
}

Error Responses

HTTP Code Description Example
400 Bad request – missing or invalid parameters. { "Error": { "Code": "InvalidParameter", "Message": "The 'cellName' parameter is missing or malformed." }, "Code": 400, "Status": "Bad Request" }
401 Unauthorized – token missing or invalid. { "Error": { "Code": "InvalidToken", "Message": "Authentication failed." }, "Code": 401, "Status": "Unauthorized" }
404 Not found – workbook, worksheet, or cell does not exist. { "Error": { "Code": "FileNotFound", "Message": "Workbook 'test.xlsx' not found." }, "Code": 404, "Status": "Not Found" }
500 Internal server error – unexpected condition on the server. { "Error": { "Code": "ServerError", "Message": "An unexpected error occurred." }, "Code": 500, "Status": "Internal Server Error" }

SDK Examples

The following SDKs provide ready‑made wrappers for this operation. Replace placeholder values (<YOUR_TOKEN>, <FILE_NAME>, etc.) with real data.


See Also


Additional Notes