My requirement was to add notes to cells in Excel using OfficeJS.
However since Microsoft confirmed that adding notes using OfficeJS is not possible in the current version, as a workaround I am trying to use the Comments feature.
I could add comments with status as resolved.
However I want to disable/ hide the Reopen thread and Delete thread so that the user cant make any changes to the comment and also remove the timestamp in the comment.
This would make the comments behave somewhat similar to Notes.
Here is my code for adding resolved comments.
async function addCellComment(){
await Excel.run(async (context) => {
let comments = context.workbook.comments;
let cell = context.workbook.getActiveCell();
cell.load("address");
await context.sync();
comments.add(cell.address, "This is "+ cell.address);
let commentThreadCount = context.workbook.comments.getCount();
context.workbook.comments.load("getCount");
await context.sync();
for(let i = 0; i < commentThreadCount.value;i++){
context.workbook.comments.getItemAt(i).resolved = true;
}
});
}