Example usage for org.apache.poi.ss.usermodel Comment getAuthor

List of usage examples for org.apache.poi.ss.usermodel Comment getAuthor

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Comment getAuthor.

Prototype

String getAuthor();

Source Link

Document

Name of the original comment author

Usage

From source file:com.vaadin.addon.spreadsheet.Spreadsheet.java

License:Open Source License

private void loadCellComments(int r1, int c1, int r2, int c2) {
    Sheet sheet = getActiveSheet();/*from   w w  w .j a v  a 2s  . c  o  m*/
    for (int r = r1 - 1; r < r2; r++) {
        Row row = sheet.getRow(r);
        if (row != null && row.getZeroHeight()) {
            continue;
        }
        for (int c = c1 - 1; c < c2; c++) {
            if (sheet.isColumnHidden(c)) {
                continue;
            }

            int c_one_based = c + 1;
            int row_one_based = r + 1;

            MergedRegion region = mergedRegionContainer.getMergedRegion(c_one_based, row_one_based);
            // do not add comments that are "below" merged regions.
            // client side handles cases where comment "moves" (because
            // shifting etc.) from merged cell into basic or vice versa.
            if (region == null || region.col1 == c_one_based && region.row1 == row_one_based) {
                Comment comment = sheet.getCellComment(r, c);
                String key = SpreadsheetUtil.toKey(c_one_based, row_one_based);
                if (comment != null) {
                    // by default comments are shown when mouse is over the
                    // red
                    // triangle on the cell's top right corner. the comment
                    // position is calculated so that it is completely
                    // visible.
                    getState().cellComments.put(key, comment.getString().getString());
                    getState().cellCommentAuthors.put(key, comment.getAuthor());
                    if (comment.isVisible()) {
                        getState().visibleCellComments.add(key);
                    }
                }
                if (isMarkedAsInvalidFormula(c_one_based, row_one_based)) {
                    getState().invalidFormulaCells.add(key);
                }

            } else {
                c = region.col2 - 1;
            }
        }
    }
}

From source file:de.enerko.reports2.engine.CommentDefinition.java

License:Apache License

public CommentDefinition(final Comment comment) {
    this(comment.getString().getString(), comment.getAuthor(), comment.getColumn(), comment.getRow(), -1, -1,
            comment.isVisible());/*from   www.  j av  a  2s .com*/
}

From source file:de.jlo.talendcomp.excel.SpreadsheetReferencedCellInput.java

License:Apache License

private boolean fetchCurrentCellValue(Cell cell) {
    if (cell != null) {
        currentCell = cell;/*from w  ww.ja  v a  2  s .c  o m*/
        currentCellValueString = getStringCellValue(cell);
        Comment comment = cell.getCellComment();
        if (comment != null) {
            currentCellComment = comment.getString().getString();
            currentCellCommentAuthor = comment.getAuthor();
        }
        CellType cellType = cell.getCellTypeEnum();
        if (cellType == CellType.BLANK) {
            currentCellValueClassName = "Object";
        } else if (cellType == CellType.STRING) {
            currentCellValueClassName = "String";
            currentCellValueObject = currentCellValueString;
        } else if (cellType == CellType.BOOLEAN) {
            currentCellValueClassName = "Boolean";
            currentCellValueBool = cell.getBooleanCellValue();
            currentCellValueObject = currentCellValueBool;
        } else if (cellType == CellType.ERROR) {
            currentCellValueClassName = "Byte";
            currentCellValueObject = cell.getErrorCellValue();
        } else if (cellType == CellType.FORMULA) {
            currentCellValueClassName = "String";
            currentCellFormula = cell.getCellFormula();
            currentCellValueString = getDataFormatter().formatCellValue(cell, getFormulaEvaluator());
            currentCellValueObject = currentCellValueString;
        } else if (cellType == CellType.NUMERIC) {
            if (DateUtil.isCellDateFormatted(cell)) {
                currentCellValueClassName = "java.util.Date";
                currentCellValueDate = cell.getDateCellValue();
                currentCellValueObject = currentCellValueDate;
            } else {
                currentCellValueClassName = "Double";
                currentCellValueNumber = cell.getNumericCellValue();
                currentCellValueObject = currentCellValueNumber;
            }
        }
        currentCellBgColor = getBgColor(cell);
        currentCellFgColor = getFgColor(cell);
        return currentCellValueObject != null;
    } else {
        return false;
    }
}

From source file:org.alanwilliamson.openbd.plugin.spreadsheet.functions.SpreadsheetGetCellComment.java

License:Open Source License

public cfData execute(cfSession _session, List<cfData> parameters) throws cfmRunTimeException {
    Collections.reverse(parameters);

    if (parameters.size() == 2) {
        throwException(_session, "please specify both a row and a column");
    }//from   w w w .ja  v a2 s .  c  om

    cfSpreadSheetData spreadsheet = (cfSpreadSheetData) parameters.get(0);
    Sheet sheet = spreadsheet.getActiveSheet();

    if (parameters.size() == 3) {
        int rowNo = parameters.get(1).getInt() - 1;
        int columnNo = parameters.get(0).getInt() - 1;

        if (rowNo < 0)
            throwException(_session, "row must be 1 or greater (" + rowNo + ")");
        if (columnNo < 0)
            throwException(_session, "column must be 1 or greater (" + columnNo + ")");

        cfStructData sd = new cfStructData();

        Row row = sheet.getRow(rowNo);
        if (row != null) {
            Cell cell = row.getCell(columnNo);
            if (cell != null) {
                Comment comment = cell.getCellComment();
                if (comment != null) {
                    sd.setData("column", new cfNumberData(columnNo));
                    sd.setData("row", new cfNumberData(rowNo));
                    sd.setData("author", new cfStringData(comment.getAuthor()));
                    sd.setData("comment", new cfStringData(comment.getString().getString()));
                }
            }
        }

        return sd;
    } else {
        cfArrayData arr = cfArrayData.createArray(1);

        Iterator<Row> rowIT = sheet.rowIterator();
        while (rowIT.hasNext()) {
            Row row = rowIT.next();

            Iterator<Cell> cellIT = row.cellIterator();
            while (cellIT.hasNext()) {
                Cell cell = cellIT.next();
                Comment comment = cell.getCellComment();
                if (comment != null) {
                    cfStructData sd = new cfStructData();
                    sd.setData("column", new cfNumberData(cell.getColumnIndex() + 1));
                    sd.setData("row", new cfNumberData(row.getRowNum() + 1));
                    sd.setData("author", new cfStringData(comment.getAuthor()));
                    sd.setData("comment", new cfStringData(comment.getString().getString()));
                    arr.addElement(sd);
                }
            }
        }

        return arr;
    }

}