-
Notifications
You must be signed in to change notification settings - Fork 277
Threaded comments
EPPlus supports threaded comments from version 5.3. With threaded comments users can add comments to a thread that belongs to a cell in a worksheet. The users can mention eachother in the comments and the entire thread can be resolved (closed/locked) and re-opened. EPPlus supports all of these features. Threaded comments exists in several spreadsheet programs, however the EPPlus implementation is designed to cover most of the functionality in Excel/Office 365.
When a user adds a threaded comment in Excel/Office 365 the user is added to a collection of Persons in the workbook. With EPPlus you can read/edit/delete these users, see code below.
var persons = package.Workbook.ThreadedCommentPersons;
You can add a new person this way:
var p1 = persons.Add("John Doe");
//This method call above is using default parameters same as below
var p2 = persons.Add("John Doe", "John Doe", IdentityProvider.NoProvider);
The Persons collection is also available via the worksheet, see code below.
var sheet = package.Workbook.Worksheets.First();
var author = sheet.ThreadedComments.Persons.First();
The Persons collection exposes functions for an indexer (numeric index and id (string)) and properties/methods such as Count, Find, Remove.
This enum represent the for different sources that are supported:
- NoProvider - The person is not represented in a catalog outside the workbook
- ActiveDirectory - The person corresponds to an Active directory user. Person's userId should be an ActiveDirectory Security Identifier (SID).
- WindowsLiveId - The person corresponds to a Windows Live user. Person's userId should be a 64-bit signed decimal that uniquely identifies a user on Windows Live.
- Office365 - The person corresponds to an Office 365 user. The Person's userId should be a string that uniquely identifies a user. It SHOULD be comprised of three individual values separated by a "::" delimiter.
- PeoplePicker - The person corresponds to a People Picker user. The Persons userId should be an email address provided by People Picker.
Read more about managing persons here: https://docs.microsoft.com/en-us/openspecs/windows_protocols/MS-DTYP/cca27429-5689-4a16-b2b4-9325d93e4ba2
The comment threads can be accessed either on worksheet level or directly via a cell.
using (var package = new ExcelPackage())
{
var sheet = package.Workbook.Worksheets.Add("test");
var person = sheet.ThreadedComments.Persons.Add("John Doe");
var person2 = sheet.ThreadedComments.Persons.Add("Jane Doe");
var thread = sheet.Cells["A1"].AddThreadedComment();
var c1 = thread.AddComment(person2.Id, "Hello");
// Mention Jane Doe (person2) in the comment.
var c2 = thread.AddComment(person.Id, "Hello {0}, how are you?", person2);
}
EPPlus Software AB - https://epplussoftware.com
- 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