Skip to content

Comments and notes ​

The workbook model keeps cell notes, threaded discussions and people apart. This page covers all three; pictures, charts and other drawing objects are on Images and drawings.

Add a note to a cell

A1:B4 holds a small expense list. Notes attach text to a cell without changing its value.

Powered by the real Formulon engine (WASM) — it runs entirely in your browser, nothing is uploaded.

What you can do ​

Reading threads ​

ws.listThreadedComments() returns a flat file-order list: each thread opener is followed by its replies. ws.listThreadedComments('B2'), or (row, col), lists only the thread at that cell, and [] when it has none. Python spells it list_threaded_comments(cell=None).

A ThreadedComment carries these fields:

FieldMeaning
idA GUID string in braces
cellThe anchor, a zero-based CellAddress
personIdThe person id
createdThe timestamp, a CivilTime (Python datetime); null when the file has none or it cannot be parsed. The hundredths of a second are dropped
textThe comment text
parentIdEmpty on an opener
doneThe resolved state
mentionsThe mention spans, in UTF-16 code units in JavaScript and code points in Python

Offsets count a line break as one character. The .xlsx file counts it as two, and a load and a save convert between the two, so a mention after a line break keeps its place.

Adding, updating and removing comments ​

ws.addThreadedComment(comment) opens a thread at cell when parentId is empty or omitted. Otherwise it adds a reply and ignores cell. Two of its keys take several forms:

KeyAccepts
createdA CivilTime (read as UTC), a Date (read through its UTC getters) or null (the pinned clock, else now). Python converts an aware datetime to UTC and reads a naive datetime or a date as UTC
cellA CellAddress or an A1 cell (A1 when omitted)

ws.updateThreadedComment(id, patch) changes the text, the mentions or the resolved state. done is accepted on a thread's opening comment only.

ws.removeThreadedComment(id) removes a comment. Removing an opener removes its whole thread.

People ​

wb.listPeople() reads the workbook person list and wb.addPerson(person) adds one. The person fields behave as follows:

FieldBehavior
displayNameRequired
idAn omitted id is generated as a GUID
userId, providerIdnull when omitted

An empty id or providerId fails with StatusCode.InvalidArgument.

wb.removePerson(id) fails in these cases:

ConditionResult
A comment or mention still names the personStatusCode.InvalidArgument
An unknown idStatusCode.NotFound

Saving threads ​

Each thread keeps Excel's legacy note stub synchronized. Saving .xlsx writes that note in the UI language of the profile's locale, as one plain run with CRLF line breaks. A save orders a thread's replies by creation time and then id, as Excel does on save.

The thread's own text is written with CRLF line breaks and its replies in the same order. The Japanese wording is measured; the other languages use the wording Excel ships for that UI language. Row and column insertions and deletions move or remove comment anchors with their cells.

Notes ​

Classic notes remain available through these members:

MemberDoes
ws.getComment(row, col)Returns the note, or null (Python None) when no note is anchored at the cell
ws.listComments()Lists the notes, including those anchored on otherwise-empty cells
ws.setComment(row, col, comment)Sets a note; comment is { text, author? }
ws.setComment(row, col, null)Removes a note, and does nothing when there is none

An omitted or empty author means none and reads back as null. Python spells the comment Comment(text), and its author reads None. An empty text passed to setComment writes an empty note.

A note loaded from a file keeps its formatted runs, each with its own font, through a save. Setting a note's text through the API replaces them with plain text.

Note visibility ​

ws.getCommentVisible(row, col) reports whether a note is shown without hovering. It returns a Boolean, or null when no note is anchored there. ws.setCommentVisible(row, col, visible) shows or hides the note while keeping the note's box geometry.

ConditionJavaScriptPython
setCommentVisible where no note is anchoredThrows StatusCode.NotFoundset_comment_visible() raises NotFoundError
getCommentVisible where no note is anchorednullget_comment_visible() returns None (a bool otherwise)

Resaving notes ​

A resave keeps each note's box (x:Anchor), its visibility, and the authors table of the comments part, including authors no remaining note names. Adding, removing, or showing a note regenerates the drawing without resetting the other notes' boxes or visibility, and a box follows its note through row and column edits.

Each remaining note re-emits its own original <v:shape> (fill, stroke, shadow, text-box style, font, size) with only its anchor, visibility, and cell patched. A new note gets the default shape.

Threaded comment and person bindings ​

The C calls are fm_sheet_get_threaded_comment_count, fm_sheet_get_threaded_comment_at, fm_sheet_add_threaded_comment, fm_sheet_update_threaded_comment, fm_sheet_remove_threaded_comment, fm_workbook_get_person_count, fm_workbook_get_person_at, fm_workbook_add_person, and fm_workbook_remove_person. WASM and Native Node use the matching camelCase methods; Python uses snake_case.