Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
94835fc
Add example: create-a-new-workbook-and-add-a-threaded-comment-to-cell…
agent-aspose-cells-examples May 18, 2026
777891f
Add example: load-an-existing-workbook-retrieve-all-threaded-comments…
agent-aspose-cells-examples May 18, 2026
a280802
Add example: iterate-through-a-threadedcommentcollection-to-display-e…
agent-aspose-cells-examples May 18, 2026
e941856
Add example: edit-a-specific-threaded-comment-by-setting-its-text-pro…
agent-aspose-cells-examples May 18, 2026
acb5ce4
Add example: remove-a-threaded-comment-from-cell-c3-using-the-remove-…
agent-aspose-cells-examples May 18, 2026
88c9a8e
Add example: set-the-text-direction-of-a-comments-shape-to-righttolef…
agent-aspose-cells-examples May 18, 2026
c6ae852
Add example: set-the-text-direction-of-a-comments-shape-to-toptobotto…
agent-aspose-cells-examples May 18, 2026
b5161bb
Add example: change-the-font-color-of-a-comment-by-assigning-a-red-va…
agent-aspose-cells-examples May 18, 2026
7f257b5
Add example: update-the-font-color-of-all-comments-authored-by-alice-…
agent-aspose-cells-examples May 18, 2026
5bb2b05
Add example: apply-a-solid-blue-background-to-a-comment-using-shapefi…
agent-aspose-cells-examples May 18, 2026
1d508f5
Add example: create-a-workbook-add-threaded-comments-to-multiple-cell…
agent-aspose-cells-examples May 18, 2026
9d21e5d
Add example: load-a-workbook-modify-comment-font-colors-based-on-auth…
agent-aspose-cells-examples May 18, 2026
e2084b9
Add example: batch-process-a-folder-of-workbooks-adding-a-standard-di…
agent-aspose-cells-examples May 18, 2026
7883daa
Add example: copy-a-threaded-comment-from-cell-e5-to-cell-f6-while-pr…
agent-aspose-cells-examples May 18, 2026
57284a9
Add example: read-all-threaded-comments-from-a-worksheet-and-count-th…
agent-aspose-cells-examples May 18, 2026
303e9d1
Add example: remove-all-comments-older-than-thirty-days-from-a-workbo…
agent-aspose-cells-examples May 18, 2026
b71125e
Add example: scan-a-workbook-for-empty-comments-and-remove-them-to-cl…
agent-aspose-cells-examples May 18, 2026
39da737
Add example: compare-two-workbooks-by-extracting-their-threaded-comme…
agent-aspose-cells-examples May 18, 2026
588b38e
Add example: read-the-author-of-each-threaded-comment-in-a-worksheet-…
agent-aspose-cells-examples May 18, 2026
2e99121
Add example: change-the-font-color-of-comments-in-column-g-to-blue-us…
agent-aspose-cells-examples May 18, 2026
0c35a63
Add example: add-a-threaded-comment-with-multi-line-text-to-cell-h2-a…
agent-aspose-cells-examples May 18, 2026
702fc5f
Add example: retrieve-and-display-the-total-number-of-threaded-commen…
agent-aspose-cells-examples May 18, 2026
a850e2f
Add example: update-the-text-direction-of-all-comments-in-a-worksheet…
agent-aspose-cells-examples May 18, 2026
fefd7bc
Add example: replace-the-background-picture-of-a-comment-with-a-semi-…
agent-aspose-cells-examples May 18, 2026
63bb93f
Add example: copy-formatting-of-a-comments-shape-including-background…
agent-aspose-cells-examples May 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using Aspose.Cells;

namespace AsposeCellsThreadedCommentExample
{
class Program
{
static void Main()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

// Add a threaded comment author
int authorIndex = worksheet.Workbook.Worksheets.ThreadedCommentAuthors.Add(
"Demo Author", // Author name
"demo.author@example.com", // User ID (email)
"DEMO_PROVIDER"); // Provider ID
ThreadedCommentAuthor author = worksheet.Workbook.Worksheets.ThreadedCommentAuthors[authorIndex];

// Multi-line comment text (preserves line breaks)
string commentText = "First line of comment.\nSecond line of comment.\nThird line of comment.";

// Add a threaded comment to cell H2 (row index 1, column index 7)
worksheet.Comments.AddThreadedComment(1, 7, commentText, author);

// Save the workbook
workbook.Save("ThreadedComment_H2.xlsx");
}
}
}
81 changes: 81 additions & 0 deletions comments-and-notes/agents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Comments and Notes Examples

This folder contains **Aspose.Cells for .NET** code examples related to:

Comments and Notes


## Purpose

These examples demonstrate common **Aspose.Cells APIs** used when working with:

- Workbooks
- Worksheets
- Cells
- Formulas
- Charts
- Data operations


## Example Files

Each `.cs` file demonstrates a specific task related to **Comments and Notes**.

Example:

create-a-workbook.cs


## Required Namespaces

Most examples will require:

using Aspose.Cells;


## Common Pattern

Typical Aspose.Cells workflow:

Workbook workbook = new Workbook();

Worksheet sheet = workbook.Worksheets[0];

Cells cells = sheet.Cells;


## Output

Examples may generate:

- XLSX files
- PDF files
- CSV files
- Images

Output files are written to the working directory.
- create-a-new-workbook-and-add-a-threaded-comment-to-cell-a1-with-author-john.cs
- load-an-existing-workbook-retrieve-all-threaded-comments-from-column-b-and-list-their-authors.cs
- iterate-through-a-threadedcommentcollection-to-display-each-comments-text-author-and-creation-timestamp.cs
- edit-a-specific-threaded-comment-by-setting-its-text-property-to-a-new-string-value.cs
- remove-a-threaded-comment-from-cell-c3-using-the-remove-method-on-the-comment-object.cs
- set-the-text-direction-of-a-comments-shape-to-righttoleft-for-bidirectional-language-support.cs
- set-the-text-direction-of-a-comments-shape-to-toptobottom-for-vertical-annotation-layout.cs
- change-the-font-color-of-a-comment-by-assigning-a-red-value-to-shapetextbodyfontcolor.cs
- update-the-font-color-of-all-comments-authored-by-alice-to-green-using-shapetextbodyfontcolor.cs
- apply-a-solid-blue-background-to-a-comment-using-shapefillforecolor-with-the-appropriate-color-code.cs
- create-a-workbook-add-threaded-comments-to-multiple-cells-and-save-the-file-in-xlsx-format.cs
- load-a-workbook-modify-comment-font-colors-based-on-author-and-save-changes-to-a-new-file.cs
- batch-process-a-folder-of-workbooks-adding-a-standard-disclaimer-comment-to-each-worksheets-top-left-cell.cs
- copy-a-threaded-comment-from-cell-e5-to-cell-f6-while-preserving-its-author-and-text.cs
- read-all-threaded-comments-from-a-worksheet-and-count-the-number-of-comments-per-author.cs
- remove-all-comments-older-than-thirty-days-from-a-workbook-based-on-their-createdtime-values.cs
- scan-a-workbook-for-empty-comments-and-remove-them-to-clean-metadata.cs
- compare-two-workbooks-by-extracting-their-threaded-comments-and-identifying-differences-in-author-attribution.cs
- read-the-author-of-each-threaded-comment-in-a-worksheet-and-output-the-list.cs
- change-the-font-color-of-comments-in-column-g-to-blue-using-shapetextbodyfontcolor.cs
- add-a-threaded-comment-with-multi-line-text-to-cell-h2-and-preserve-line-breaks.cs
- retrieve-and-display-the-total-number-of-threaded-comments-present-in-a-workbook.cs
- update-the-text-direction-of-all-comments-in-a-worksheet-to-lefttoright-for-standard-layout.cs
- replace-the-background-picture-of-a-comment-with-a-semi-transparent-overlay-image.cs
- copy-formatting-of-a-comments-shape-including-background-color-and-font-color-to-another-comment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Drawing;
using Aspose.Cells;
using Aspose.Cells.Drawing;

class ApplyBlueBackgroundToComment
{
static void Main()
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];

// Add a comment to cell A1
int commentIndex = sheet.Comments.Add("A1");
Comment comment = sheet.Comments[commentIndex];
comment.Note = "This is a sample comment";

// Access the shape associated with the comment
Shape commentShape = comment.CommentShape;

// Make sure the shape's fill is visible
commentShape.IsFilled = true;

// Apply a solid blue background using the FillFormat's ForeColor
commentShape.FillFormat.ForeColor = Color.Blue;

// Save the workbook
workbook.Save("CommentBlueBackground.xlsx");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.IO;
using Aspose.Cells;

namespace BatchDisclaimer
{
public static class WorkbookProcessor
{
// Adds a disclaimer comment to the top‑left cell (A1) of every worksheet in all workbooks
// found in the specified folder. The original files are overwritten with the updated version.
public static void AddDisclaimerToFolder(string folderPath, string disclaimer)
{
// Get all Excel files in the folder (you can adjust the pattern if needed)
string[] files = Directory.GetFiles(folderPath, "*.xlsx", SearchOption.TopDirectoryOnly);

foreach (string filePath in files)
{
// Load the workbook using the constructor that accepts a file path
using (Workbook workbook = new Workbook(filePath))
{
// Iterate through each worksheet in the workbook
foreach (Worksheet sheet in workbook.Worksheets)
{
// Add a comment to cell A1 (top‑left cell)
int commentIndex = sheet.Comments.Add("A1");
sheet.Comments[commentIndex].Note = disclaimer;
}

// Save the modified workbook back to the same file (overwrite)
workbook.Save(filePath);
}
}
}

// Example usage
public static void Main()
{
string folder = @"C:\ExcelFiles"; // Folder containing the workbooks
string disclaimerText = "This workbook is confidential and intended for authorized personnel only.";

AddDisclaimerToFolder(folder, disclaimerText);

Console.WriteLine("Disclaimer added to all workbooks in the folder.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Drawing;
using Aspose.Cells;
using Aspose.Cells.Drawing;

namespace AsposeCellsCommentFontColor
{
class Program
{
static void Main()
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

// Add a comment to cell A1
int commentIndex = worksheet.Comments.Add("A1");
Comment comment = worksheet.Comments[commentIndex];
comment.Note = "This is a sample comment";

// Access the shape attached to the comment
CommentShape commentShape = comment.CommentShape;

// Ensure the shape has a TextBody collection
// Set the font color of the first text run to red
// (FontSettingCollection items expose a Font property)
commentShape.TextBody[0].Font.Color = Color.Red;

// Optionally make the comment visible
comment.IsVisible = true;

// Save the workbook
workbook.Save("CommentWithRedFont.xlsx");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Drawing;
using Aspose.Cells;
using Aspose.Cells.Drawing;

class ChangeCommentFontColorInColumnG
{
static void Main()
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

// Add sample comments in column G (index 6)
for (int row = 0; row < 5; row++)
{
// Add a comment to cell G{row+1}
int commentIndex = worksheet.Comments.Add(row, 6);
Comment comment = worksheet.Comments[commentIndex];
comment.Note = $"Comment at G{row + 1}";
}

// Iterate through all comments and change font color to blue for those in column G
foreach (Comment comment in worksheet.Comments)
{
if (comment.Column == 6) // Column G (zero‑based index)
{
// Access the shape associated with the comment
CommentShape shape = comment.CommentShape;

// Use the TextBody collection to set the font color.
// The TextBody collection contains FontSetting objects; we modify the first (and only) one.
// This changes the font color of the entire comment text.
shape.TextBody[0].Font.Color = Color.Blue;

// Ensure the comment is visible (optional)
comment.IsVisible = true;
}
}

// Save the workbook
workbook.Save("CommentsColumnG_BlueFont.xlsx");
}
}
Loading