【问题标题】:EPPlus - How to remove a comment from a cell?EPPlus - 如何从单元格中删除评论?
【发布时间】:2015-06-27 09:01:32
【问题描述】:

在 EPPlus 中,我可以使用 workSheet.Cells[x, y].AddComment() 将 cmets 添加到工作表中的单元格

但是如何从给定单元格中删除评论 - 没有 workSheet.Cells[i, j].RemoveComment() - 我需要保留任何其他 cmets

提前感谢您的任何建议

【问题讨论】:

    标签: epplus


    【解决方案1】:

    人们会认为它会那么简单:)。

    看看这个:

    [TestMethod]
    public void Comment_Test()
    {
        var existingFile = new FileInfo(@"c:\temp\temp.xlsx");
        if (existingFile.Exists)
            existingFile.Delete();
    
        using (var package2 = new ExcelPackage(existingFile))
        {
            var ws = package2.Workbook.Worksheets.Add("Sheet1");
            ws.Cells[1, 1].AddComment("Comment Test 1", "Me");
            ws.Cells[1, 2].AddComment("Comment Test 2", "Me");
            ws.Cells[1, 3].AddComment("Comment Test 3", "Me");
    
            //Alternate way to add a comment
            ws.Comments.Add(ws.Cells[1, 4], "Comment Test 4", "Me");
    
            //Remove middle comment
            ws.Comments.Remove(ws.Cells[1,2].Comment);
    
            package2.Save();
        }
    }
    

    【讨论】:

    • 谢谢 - 我会试一试
    猜你喜欢
    • 2012-08-02
    • 2011-12-18
    • 2022-01-28
    • 1970-01-01
    • 1970-01-01
    • 2016-09-29
    • 1970-01-01
    • 2012-03-09
    • 1970-01-01
    相关资源
    最近更新 更多