I am using Aspose.Cells to read data from Excel spreadsheets and I need to pull the comment if there are any on a cell.
When I get the comment using something like:
worbook.Worksheets[0].Cells[r,c].Comment.Note
The comment always is returned as:
"[Threaded comment]\n\nYour version of Excel allows you to read this threaded comment; however, any edits to it will get removed if the file is opened in a newer version of Excel. Learn more: https://go.microsoft.com/fwlink/?linkid=870924\n\nComment:\n B11 comment in blank sheet"
So should I assume that I need to parse this? Is it safe to look for “\n\nComment:\n” and get whatever is after it?
Why is Excel putting that in every comment (I assume it is Excel). I’m using the latest version of Excel from Microsoft 365 and it’s a new file I created.
@jdenable
We have created a sample file containing notes and comments. You can refer to the following sample code to read notes and comments. Please refer to the attachment. sample.zip (8.1 KB)
Open Excel
Choose template “Blank workbook”
Click in cell A1
Right-click in A1 and choose “New Comment”
Enter “Line 1” and Ctrl-Enter.
Click out into another cell
Save As
Then I run this code:
Console.WriteLine("Version: " + CellsHelper.GetVersion());
var workbook = new Aspose.Cells.Workbook("c:\\temp\\blank_threaded.xlsx");
CommentCollection comments = workbook.Worksheets[0].Comments;
Console.WriteLine("Comment: " + comments[0].Note);
The output is:
Version: 24.3
Comment: [Threaded comment]
Your version of Excel allows you to read this threaded comment; however, any edits to it will get removed if the file is opened in a newer version of Excel. Learn more: https://go.microsoft.com/fwlink/?linkid=870924
Comment:
Line 1
I think Excel is adding that initial comment every time.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.