Cannot find text in Threaded Comments

I created a sample excel file in Office 365 and added some Threaded Comments to a cell. Then I use the Cells.Find method for searching text in the document. For example “This is the first reply” string. In this case, the function returns the correct cell with the comment which contains the searched text.

But after I edit the comment in MS Office Excel 2016 which not supports this Threaded Comments feature the Cells.Find did not find anything however if I reupload the edited file to Office 365 the threaded comment is showing up with the “This is the first reply” text.

I extracted the edited xlsx file with 7-zip and I noticed that there is two comments related XML file and its content is different.

  • comments1.xml contains the edited comment
  • threadedComment1.xml contains the original comment

Do you have any solution for this edge case? How can I find text (with Cells.Find method) in the threaded comments if the old comments (Note) are modified?

Aspose.PDF .NET 20.2 version

sample-files.zip (16.2 KB)

Code snippet:

	private void SearchInCells(Cells cells, string searchTerm)
	{
		CellArea ca = new CellArea {
			StartRow = cells.MinDataRow,
			StartColumn = cells.MinDataColumn,
			EndRow = cells.MaxDataRow,
			EndColumn = cells.MaxDataColumn,
		};

		FindOptions findOptions = new FindOptions();
		findOptions.SetRange(ca);
		findOptions.RegexKey = true;
		findOptions.CaseSensitive = false;
		findOptions.SearchBackward = true;
		findOptions.LookInType = LookInType.Comments;

		Cell nextCell = cells.Find(searchTerm, null, findOptions);
		while (nextCell != null)
		{
			Console.WriteLine($"{nextCell.Name}:");
			Console.WriteLine($"Note: {nextCell.Worksheet.Comments[nextCell.Row, nextCell.Column].Note}");
			
			ThreadedCommentCollection threadedComments = nextCell.Worksheet.Comments.GetThreadedComments(nextCell.Row, nextCell.Column);
			foreach (var threadedComment in threadedComments)
			{
				Console.WriteLine($"{nextCell.Name}:");
				Console.WriteLine($"Threaded Comment Author: {threadedComment.Author.Name}");
				Console.WriteLine($"Threaded Comments: {threadedComment.Notes}");
			}
			nextCell = cells.Find(searchTerm, nextCell, findOptions);
		}
	}

Thanks,

Gabor

@erdeiga,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-47239 – Cells.Find cannot find text in ThreadedComments after editing comments in Excel 2016

1 Like

@erdeiga,

This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-47239”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@erdeiga,

Please try our latest version/fix: Aspose.Cells for .NET v20.3.1 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells20.3.1 For .Net2_AuthenticodeSigned.Zip (5.2 MB)
Aspose.Cells20.3.1 For .Net4.0.Zip (5.2 MB)

1 Like

Hi @Amjad_Sahi

I tried the 20.3.1 what you attached and it is working.

Thanks for the quick response.

@erdeiga,

Good to know that your issue is sorted out by the new fix/version. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

@Amjad_Sahi
Could you tell me which Aspose Cells release will contain this fix?

@erdeiga,

Please try our latest version/fix: Aspose.Cells for .NET v20.4 and let us know your feedback.

1 Like