IronXL 操作指南 添加注释 How to add Comment Chaknith Bin 已更新:六月 9, 2025 Download IronXL NuGet 下载 DLL 下载 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English In Excel, a comment is a note or annotation that can be added to a cell to provide additional information without affecting the actual content of the cell. Comments are useful for providing explanations, context, or reminders about the data or calculations within a specific cell. Quickstart: Add a Comment to a Cell in One Simple Line This code shows how easily you can add a comment to a specific Excel cell using IronXL—with a single method call. No interop, no fuss—just call AddComment on a cell and you're done. Get started making PDFs with NuGet now: Install IronXL with NuGet Package Manager PM > Install-Package IronXL.Excel Copy and run this code snippet. IronXL.WorkBook.Create().DefaultWorkSheet["B2"].First().AddComment("Quick tip!", "Dev"); Deploy to test on your live environment Start using IronXL in your project today with a free trial Free 30 day Trial Minimal Workflow (5 steps) Download the C# library to enable comment functionality Open an existing or create a new Excel spreadsheet Use the AddComment method to add comments Retrieve and edit comments by accessing the Comment property Remove comments from cells using the RemoveComment method Add Comment Example Select the cell and use the AddComment method to add a comment to the cell. By default, the comment will be invisible. Hover on the cell to see the comment. :path=/static-assets/excel/content-code-examples/how-to/add-comment-add-comment.cs using IronXL; using System.Linq; WorkBook workBook = WorkBook.Create(); WorkSheet workSheet = workBook.DefaultWorkSheet; Cell cellA1 = workSheet["A1"].First(); Cell cellD1 = workSheet["D1"].First(); // Add comments cellA1.AddComment("Hello World!", "John Doe"); // Add comment with content and author. The comment is invisible by default. cellD1.AddComment(null, null, true); // Add comment with no content and no author. The comment is set to be visible. workBook.SaveAs("addComment.xlsx"); Imports IronXL Imports System.Linq Private workBook As WorkBook = WorkBook.Create() Private workSheet As WorkSheet = workBook.DefaultWorkSheet Private cellA1 As Cell = workSheet("A1").First() Private cellD1 As Cell = workSheet("D1").First() ' Add comments cellA1.AddComment("Hello World!", "John Doe") ' Add comment with content and author. The comment is invisible by default. cellD1.AddComment(Nothing, Nothing, True) ' Add comment with no content and no author. The comment is set to be visible. workBook.SaveAs("addComment.xlsx") $vbLabelText $csharpLabel Edit Comment Example Access the Comment property of the cell to retrieve the Comment object for the cell. This is the object you can use to change the Author, Content, and visibility. :path=/static-assets/excel/content-code-examples/how-to/add-comment-edit-comment.cs using IronXL; using System.Linq; WorkBook workBook = WorkBook.Load("addComment.xlsx"); WorkSheet workSheet = workBook.DefaultWorkSheet; Cell cellA1 = workSheet["A1"].First(); // Retrieve comment var comment = cellA1.Comment; // Edit comment comment.Author = "Jane Doe"; comment.Content = "Bye World"; comment.IsVisible = true; workBook.SaveAs("editComment.xlsx"); Imports IronXL Imports System.Linq Private workBook As WorkBook = WorkBook.Load("addComment.xlsx") Private workSheet As WorkSheet = workBook.DefaultWorkSheet Private cellA1 As Cell = workSheet("A1").First() ' Retrieve comment Private comment = cellA1.Comment ' Edit comment comment.Author = "Jane Doe" comment.Content = "Bye World" comment.IsVisible = True workBook.SaveAs("editComment.xlsx") $vbLabelText $csharpLabel Remove Comment Example Remove a comment from a cell by first accessing the cell object. Then, call the RemoveComment method on the cell. :path=/static-assets/excel/content-code-examples/how-to/add-comment-remove-comment.cs using IronXL; using System.Linq; WorkBook workBook = WorkBook.Load("addComment.xlsx"); WorkSheet workSheet = workBook.DefaultWorkSheet; Cell cellA1 = workSheet["A1"].First(); // Remove comment cellA1.RemoveComment(); workBook.SaveAs("removeComment.xlsx"); Imports IronXL Imports System.Linq Private workBook As WorkBook = WorkBook.Load("addComment.xlsx") Private workSheet As WorkSheet = workBook.DefaultWorkSheet Private cellA1 As Cell = workSheet("A1").First() ' Remove comment cellA1.RemoveComment() workBook.SaveAs("removeComment.xlsx") $vbLabelText $csharpLabel 常见问题解答 如何使用C#向Excel单元格添加注释? 您可以使用IronXL库在C#中向Excel单元格添加注释。首先,从NuGet下载该库。然后,在单元对象上使用AddComment方法插入注释。 如何在Excel电子表格中编辑现有注释? 要使用IronXL在Excel电子表格中编辑现有注释,请访问单元的Comment属性。这允许您更改注释的内容、作者和可见性。 从Excel单元格中删除注释的过程是什么? 要使用IronXL从Excel单元格中删除注释,请访问该单元格对象并调用RemoveComment方法。 在对注释进行更改后如何保存Excel工作簿? 在使用IronXL在Excel工作簿中添加或编辑注释后,确保调用WorkBook对象的Save方法以保存更改。 Excel中的注释可以默认不可见吗? 是的,使用IronXL添加的注释在Excel中默认不可见。当您将鼠标悬停在单元格上时它们会变得可见。 需要什么来启用C#中的Excel注释功能? 要在C#中启用Excel注释功能,请从NuGet下载并安装IronXL.Excel库。 在Excel中可以更新注释的作者吗? 是的,您可以通过访问单元的Comment对象并使用IronXL设置Author属性来更新注释的作者。 如何验证单元格是否包含注释? 您可以通过使用IronXL单元的HasComment属性来验证单元格是否包含注释。 用于向Excel表添加注释的编程语言是什么? 使用IronXL为Excel表添加注释的编程语言是C#。 是否可以在不使用Interop的情况下注释Excel电子表格? 是的,您可以通过利用IronXL的库来添加、编辑和删除注释,从而在不使用Interop的情况下注释Excel电子表格。 Chaknith Bin 立即与工程团队聊天 软件工程师 Chaknith 在 IronXL 和 IronBarcode 工作。他在 C# 和 .NET 方面有着深厚的专业知识,帮助改进软件并支持客户。他从用户互动中获得的见解有助于更好的产品、文档和整体体验。 准备开始了吗? Nuget 下载 1,686,155 | 版本: 2025.11 刚刚发布 免费 NuGet 下载 总下载量:1,686,155 查看许可证