Example usage for org.apache.poi.xssf.usermodel XSSFCell removeCellComment

List of usage examples for org.apache.poi.xssf.usermodel XSSFCell removeCellComment

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFCell removeCellComment.

Prototype

@Override
public void removeCellComment() 

Source Link

Document

Removes the comment for this cell, if there is one.

Usage

From source file:offishell.excel.Excel.java

License:MIT License

public Excel calculate(Object model) {
    Map<CellAddress, XSSFComment> cellComments = sheet.getCellComments();

    VariableContext context = new VariableContext(path, false, model);

    for (Iterator<Entry<CellAddress, XSSFComment>> iterator = cellComments.entrySet().iterator(); iterator
            .hasNext();) {//from w  w  w . j  a v a  2s. c  o m
        Entry<CellAddress, XSSFComment> entry = iterator.next();

        CellAddress address = entry.getKey();
        String comment = entry.getValue().getString().getString().strip();

        entry.getValue().setVisible(false);
        XSSFCell cell = sheet.getRow(address.getRow()).getCell(address.getColumn());

        cell.setCellValue(context.apply(comment));
        cell.removeCellComment();
    }

    try {
        return save(Files.createTempFile("calculated", ".xlsx"));
    } catch (IOException e) {
        throw I.quiet(e);
    }
}