使用以下代码可以从Excel工作表单元格中删除注释:
import org.apache.poi.ss.usermodel.*;
public class RemoveCommentsFromCell {
public static void removeCommentFromCell(Cell cell) {
if (cell.getCellComment() != null) {
cell.removeCellComment();
}
}
}
在上述代码中,首先导入Apache POI的ss.usermodel包,然后定义一个名为“removeCommentFromCell”的方法,该方法将单元格作为参数传递。该方法首先检查单元格是否具有注释。如果单元格附有注释,则该方法通过调用removeCellComment方法来删除注释。在这种情况下,使用上述方法将单元格中的注释删除。