-
Notifications
You must be signed in to change notification settings - Fork 275
Adding a comment
JanKallman edited this page Oct 19, 2023
·
10 revisions
You can add Comments (in later Excel versions called Notes) either via the ExcelRange class or via the Comments
property on the ExcelWorksheet
class.
Comments/Notes can be added using plain text or using richtext as descibed in this example below.
using(var package = new ExcelPackage(@"c:\temp\commentstest.xlsx"))
{
var ws = package.Workbook.Worksheets.Add("comments");
//Add Comments using the range class
var comment = ws.Cells["A3"].AddComment("Jan Källman:\r\n", "JK");
comment.Font.Bold = true;
var rt = comment.RichText.Add("Here is some text that isn't bold...");
rt.Bold = false;
rt.FontName = "Helvetica";
rt.Color = Color.Purple;
comment.AutoFit = true;
//Add a comment using the worksheet's Comments collection
var comment2 = ws.Comments.Add(ws.Cells["B3"],"Jan Källman:", "JK");
//This sets the size and position. (The position is only when the comment is visible)
comment2.From.Column = 7;
comment2.From.Row = 3;
comment2.To.Column = 16;
comment2.To.Row = 8;
comment2.BackgroundColor = Color.White;
comment2.RichText.Add("\r\nThis comment has white background and size/position set...\r\n");
}
EPPlus Software AB - https://epplussoftware.com
- Getting Started
- The Sample Project
- EPPlus and Docker
- EPPlus and Blazor
- EPPlus and Linux
- Security
- Configuration
- Releases/versioning
- What is new in EPPlus 5+
- Breaking Changes in EPPlus 5
- Breaking Changes in EPPlus 6
- Breaking Changes in EPPlus 7
- Addressing a worksheet
- Dimension/Used range
- Copying ranges/sheets
- Insert/Delete
- Filling ranges
- Sorting ranges
- Taking and skipping columns/rows
- Data validation
- Comments
- Freeze and Split Panes
- Header and Footer
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles