创建删除并获取 GridCell 注释

可能的使用场景

以下文章介绍了如何在 GridWeb 工作表中创建、删除和获取 GridCell 注释。值得注意的是,当您将鼠标悬停在单元格上时,GridWeb 将像 MS-Excel 一样将注释显示为工具提示,如此屏幕截图所示。

待办事项:图像_替代_文本

在 Cell 内创建 Comment 对象

请使用 GridCell.CreateComment 方法在单元格内创建注释对象。以下示例代码在 GridWeb 第一个工作表的单元格 B4 中创建示例注释。

 // Access first worksheet of GridWeb

GridWorksheet sheet = GridWeb1.getWorkSheets().get(0);

// Access cell B4

GridCell cell = sheet.getCells().get("B4");

// Create comment with these parameters

// i.e. note, author, isvisible

cell.createComment("This is a B4 note.", "Peter", true);

从 Cell 中删除 Comment 对象

请使用 GridCell.RemoveComment 方法从单元格中删除注释对象。以下示例代码删除 GridWeb 第一个工作表内的单元格 B4 注释。

 // Access first worksheet of GridWeb

GridWorksheet sheet = GridWeb1.getWorkSheets().get(0);

// Access cell B4

GridCell cell = sheet.getCells().get("B4");

// Remove the comment object from this cell.

cell.removeComment();

从 Cell 获取 Comment 对象

请使用 GridCell.GetComment() 方法从单元格获取注释对象。以下示例代码从单元格 B4 获取注释对象,然后访问其各种属性,如作者、注释、可见性等。

 // Access first worksheet of GridWeb

GridWorksheet sheet = GridWeb1.getWorkSheets().get(0);

// Access cell B4

GridCell cell = sheet.getCells().get("B4");

// Get comment of this cell

GridComment gridComm = cell.getComment();

// Access its various properties

String strAuth = gridComm.getAuthor();

String strNote = gridComm.getNote();

boolean isVis = gridComm.isVisible();