IRONSOFTWAREHOME

How to Add Comment in Excel with C# (without Interop)

Curtis Chau
Curtis Chau
Updated: August 2, 2026

Add comments to Excel cells in C# using IronXL's simple API - no interop required. Just call AddComment() on any cell to add notes, annotations, or explanations that won't affect your cell data.

Quickstart: Add a Comment to a Cell in One Simple Line

Add a comment to any Excel cell with a single method call. No interop, no complexity - just call AddComment on a cell and you're done.

  1. 1Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. 2Copy and run this code snippet.

    IronXL.WorkBook.Create().DefaultWorkSheet["B2"].First().AddComment("Quick tip!", "Dev");
    C#
  3. 3Deploy to test on your live environment

    Start using IronXL in your project today with a free trial
    arrow pointer

Get started with IronXL

Start using IronXL in your project today with a free trial.

First Step:
arrow pointer

How Do I Add Comments to Excel Cells?

What Parameters Does AddComment Accept?

Select the cell and use the AddComment method to add a comment to the cell. By default, the comment will be invisible. Hover over the cell to see the comment. The AddComment method accepts three parameters: content (string), author (string), and isVisible (boolean). Both content and author parameters are optional and can be null, allowing you to create empty comments or comments without author attribution.

When working with Excel comments in your .NET applications, understanding how IronXL handles cell referencing is essential. If you're new to IronXL, check out the comprehensive getting started overview to understand the basics of working with Excel files programmatically. For enterprise applications requiring cloud deployment, IronXL seamlessly integrates with Azure environments and AWS Lambda functions.

When Should I Make Comments Visible by Default?

Comments are typically hidden by default in Excel to maintain a clean spreadsheet appearance. However, you might want visible comments in scenarios like creating training materials, providing detailed instructions for data entry, or highlighting critical information that users must see immediately. Set the third parameter of AddComment to true to make comments visible without hovering.

For more advanced Excel manipulation tasks, including creating new spreadsheets from scratch or managing existing worksheets, IronXL provides a comprehensive set of tools that work seamlessly together. When building data-driven applications, you might also need to export Excel data to various formats or convert between different spreadsheet types.

What Happens If I Add a Comment to a Cell That Already Has One?

When you call AddComment on a cell that already contains a comment, IronXL will replace the existing comment with the new one. This behavior ensures you don't accidentally create duplicate comments on a single cell. If you need to preserve existing comment content, first retrieve it using the Comment property, then concatenate or merge the content before adding the updated comment.

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");

Here's a practical example of adding comments to multiple cells in a loop, useful for adding batch annotations or validation notes:

using IronXL;
using System;

// Load an existing workbook
WorkBook workBook = WorkBook.Load("salesData.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Add comments to cells that meet specific criteria
for (int row = 2; row <= 10; row++)
{
    var cell = workSheet[$"D{row}"].First();
    var value = cell.DoubleValue;
    
    if (value > 1000)
    {
        // Add performance comment for high values
        cell.AddComment($"Excellent performance! Value: {value:C}", "Sales Manager", true);
    }
    else if (value < 500)
    {
        // Add improvement comment for low values
        cell.AddComment($"Needs attention. Current: {value:C}", "Sales Manager", false);
    }
}

// Add timestamp comment to track last update
var updateCell = workSheet["A1"].First();
updateCell.AddComment($"Last updated: {DateTime.Now:yyyy-MM-dd HH:mm}", "System");

workBook.SaveAs("salesDataWithComments.xlsx");

How Can I Edit Existing Comments?

Why Does the Comment Property Return Null Sometimes?

The Comment property returns null when the selected cell doesn't have an associated comment. This is a common scenario when iterating through cells programmatically. Always check for null before attempting to modify comment properties to avoid NullReferenceException. This pattern is similar to other cell properties in IronXL's comprehensive API.

If you're working with complex Excel files and encountering unexpected null values, the troubleshooting guides can help you understand IronXL's behavior with different Excel formats and file structures. For performance-critical applications processing large Excel files, refer to the performance milestones documentation to optimize your comment operations.

What Properties Can I Modify on a Comment?

IronXL's Comment object exposes three main properties you can modify: Author (string), Content (string), and IsVisible (boolean). The Author property identifies who created the comment, useful for collaborative documents. Content holds the actual comment text, supporting multi-line strings for detailed annotations. IsVisible controls whether the comment displays permanently or only on hover.

These comment properties work alongside other cell formatting features. For instance, you might want to combine comments with cell styling and borders to create visually distinct annotated sections in your spreadsheet. You can also apply conditional formatting to cells with comments to make them stand out visually.

How Do I Change Comment Visibility After Creation?

Retrieve the Comment object by accessing the cell's Comment property. Set the IsVisible property to true or false based on your requirements. This dynamic control allows you to show or hide comments based on user actions or specific conditions in your application logic.

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");

When editing Excel files programmatically, comments provide a non-invasive way to add metadata or notes without altering the actual cell values. This makes them perfect for audit trails, review processes, or providing context for data changes. For applications that need to maintain data integrity, consider protecting your Excel files with passwords while still allowing comment modifications.

How Do I Remove Comments from Cells?

What Happens to Cell Formatting When I Remove a Comment?

Removing a comment from a cell doesn't affect any other cell properties or formatting. The cell's value, formula, style, borders, and background colors remain unchanged. This isolation ensures that comment management operations are safe and won't inadvertently modify your carefully formatted spreadsheets. This behavior aligns with IronXL's principle of preserving workbook metadata and formatting unless explicitly modified.

Can I Remove Multiple Comments at Once?

While IronXL doesn't provide a built-in method to remove all comments from a worksheet simultaneously, you can easily implement this functionality by iterating through cells. Create a simple loop that checks each cell for comments and removes them. This approach gives you fine-grained control, allowing you to selectively remove comments based on criteria like author, content keywords, or cell location.

Remove a comment from a cell by accessing the cell object and calling the RemoveComment method. This operation is immediate and doesn't require saving the workbook to take effect, though you should save your changes to persist them to disk.

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");

Comments in Excel serve various purposes beyond simple annotations. They're valuable for code documentation when generating reports programmatically, providing instructions for data entry forms, or adding revision notes during collaborative editing. When working with data validation, comments can provide helpful hints about acceptable values. For complex data processing workflows, you might combine comments with named ranges to create self-documenting spreadsheets that are easier to maintain.

With IronXL's straightforward API, managing these comments becomes as simple as any other cell operation, making it an essential tool for creating professional, well-documented Excel files in your C# applications. Whether you're building ASP.NET web applications or desktop solutions, IronXL's comment functionality integrates seamlessly into your workflow without the complexity of COM Interop.

Frequently Asked Questions

How can I add a comment to an Excel cell using IronXL?

To add a comment, use the IronXL method 'AddComment()' on any worksheet cell. It allows you to associate notes or annotations directly with cells.

What parameters does the 'AddComment' method require?

The 'AddComment' method accepts 'content' (string), 'author' (string), and 'isVisible' (boolean) as parameters. All are optional, allowing flexibility in comment creation.

Can I control the visibility of comments by default in IronXL?

Yes, you can set comments to be visible by default with IronXL by specifying 'true' for the 'isVisible' parameter when calling 'AddComment'.

What happens if I add a comment to a cell that already has one?

Using 'AddComment' on a cell that contains an existing comment will replace the old comment with the new one, ensuring no duplicates occur.

How can I edit existing comments in an Excel file using IronXL?

To edit a comment, access the cell's 'Comment' property in IronXL, modify the 'Author', 'Content', or 'IsVisible' properties, then save the workbook.

What happens to the formatting of a cell when a comment is removed?

Removing a comment from a cell in IronXL does not impact the cell’s value, formula, or formatting, ensuring your spreadsheets remain intact.

Is it possible to remove multiple comments from a worksheet in IronXL?

While there's no single method to remove all comments, you can loop through cells programmatically to selectively remove them based on desired criteria.

Why might the 'Comment' property return null in IronXL?

The 'Comment' property returns null if a cell does not have an associated comment, which is common when iterating through cells without comments.

How do I make changes to comment visibility after creation in IronXL?

Access the cell's 'Comment' object and adjust the 'IsVisible' property to 'true' or 'false' as needed to modify comment visibility programmatically.

What types of applications can benefit from using IronXL's comment functionality?

IronXL’s comment functionality is beneficial for ASP.NET web applications and desktop solutions that require annotated, professional, and well-documented Excel files.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 2,237,574Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronXL.Excel
nuget.org/packages/IronXL.Excel/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronXL"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronXL to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronXL.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required