Other API Samples

Live SpreadsheetGear API Samples

Range Samples Formatting and Other Cell Features Comments

Add cell comments to a worksheet.

// Create a new workbook and some local variables.
SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook();
SpreadsheetGear.IWorksheet worksheet = workbook.ActiveWorksheet;
SpreadsheetGear.IRange cells = worksheet.Cells;
SpreadsheetGear.IComment comment;

// Add a comment that pops up when the parent cell is hovered over.
cells["A1"].AddComment("This is a comment.");
cells["A1"].Value = "Hover over A1 to see comment.";

// Add a comment that is visible by default.
comment = cells["A6"].AddComment("This comment is visible by default.");
comment.Visible = true;

// Add a visible comment whose contents auto-sizes.
comment = cells["A12"].AddComment("This is an\nauto-sized\ncomment.");
comment.Shape.TextFrame.AutoSize = true;
comment.Visible = true;
Run This Sample
Download File

Download an Excel Open XML Workbook (*.xlsx) file with the results of this sample.

Related Samples