Can Excel comments functionality be used with a LightCells API?

Hello,
I am trying to add some comments to my worksheet which is saved via LightCells API. Everything seems to be fine, I am getting no exceptions, but once the file is saved, no comments are present.

Example code snippet:

  @Override
public void startCell(Cell cell) {
	
	CommentCollection comments = cell.getWorksheet().getComments();
	int commentIndex = comments.add(cell.getName());
	Comment comment = comments.get(commentIndex);
	comment.setNote("aaatest");

	cell.putValue("1");
}

@alexgh,

Please note, Aspose.Cells provides the LightCells API which is mainly designed to read and write cell’s data one by one without building a complete data model block into memory. So, knowing the object model of the LightCells API, it might not be feasible for adding other objects (e.g., shapes, comments, pictures, conditional formatting, …etc.) into cells. You should add comments into spreadsheet cells in the outside of the implementation of light weight mode, i.e., normal mode.

1 Like

@amjad.sahi Thank you very much for your prompt response. My real usage scenario is to fill a very large worksheet using LightCells and also add some comments to the header row avoiding an in-memory processing.

Do I understand it correctly that this can’t be achieved using this API?

@alexgh,

Your understanding is correct.

Can I then theoretically create a new worksheet in memory, fill the row with the comments and then continue filling it for example, from the second row via the LightCells API? Like a hybrid approach.

@alexgh,
LightCells does not support adding comments when reading and writing large files. When writing to a large file using LightCells, due to the inability to manipulate other objects while outputting cells, all operations must be completed before saving. When using LightCells to read large files, due to incomplete internal model construction, operating on any object outside of the current cell may result in data being out of sync and lost.
When using LightCells to process large files, it is not recommended to manipulate other data objects except for the data and attributes on the cell object. The design of LightCells is mainly used to improve data processing performance. Due to the incomplete construction of the entire data model during this process, other data objects cannot be processed yet.
We deeply apologize for the inconvenience caused to you.