Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/EPPlusSoftware/EPPlus in…
Browse files Browse the repository at this point in the history
…to develop
  • Loading branch information
swmal committed Jun 10, 2022
2 parents 709ca61 + c95bbf3 commit 9a8da82
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/EPPlus/ExcelRangeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2046,7 +2046,10 @@ private void DeleteComments(ExcelAddressBase Range)
var cse = new CellStoreEnumerator<int>(_worksheet._commentsStore, Range._fromRow, Range._fromCol, Range._toRow, Range._toCol);
while (cse.Next())
{
deleted.Add(cse.Value);
if (_worksheet._threadedCommentsStore.Exists(cse.Row, cse.Column) == false) //Threaded comments keep a comment for backward compatibility that needs to be keept.
{
deleted.Add(cse.Value);
}
}
foreach (var i in deleted)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ public void Remove(ExcelThreadedCommentThread threadedComment)
if (threadedComment == c)
{
var address = threadedComment.CellAddress;
_worksheet.Comments.Remove(_worksheet.Comments[address]); //Remove the underlaying comment.
var comment = _worksheet.Comments[address];
if (comment != null) //Check if the underlaying comment exists.
{
_worksheet.Comments.Remove(comment); //If so, Remove it.
}
var nodes = threadedComment.Comments.Select(x => x.TopNode);
foreach(var node in nodes)
{
Expand Down
23 changes: 23 additions & 0 deletions src/EPPlusTest/Issues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3285,5 +3285,28 @@ public void I653()
SaveAndCleanup(p);
}
}
[TestMethod]
public void I667()
{
using (var p = OpenTemplatePackage("I667.xlsx"))
{
var ws = p.Workbook.Worksheets[0];

var lastDataRowIdx = 10;

var notCopyCols = ws
.Cells[1, 1, 1, 100]
.Where(x =>
x.Value != null &&
x.Value.ToString().Trim().Replace(" ", string.Empty).IndexOf("#NotCopy", StringComparison.InvariantCultureIgnoreCase) >= 0)
.Select(x => x.End);

foreach (var col in notCopyCols)
{
ws.Cells[lastDataRowIdx + 1, col.Column].Clear();
}
SaveAndCleanup(p);
}
}
}
}

0 comments on commit 9a8da82

Please sign in to comment.