List of usage examples for org.apache.poi.xssf.usermodel XSSFSheet getCellComments
@Override
public Map<CellAddress, XSSFComment> getCellComments()
From source file:org.tiefaces.components.websheet.configuration.ConfigurationHandler.java
License:MIT License
/** * build command list from comments. after transfer the comment to command, * remove it from comments.//from w w w .jav a 2 s .com * * @param sheet * sheet. * @param sheetRightCol * the sheet right col * @param cellAttributesMap * the cell attributes map * @return command list. */ private List<ConfigCommand> buildCommandListFromSheetComment(final XSSFSheet sheet, final int sheetRightCol, final CellAttributesMap cellAttributesMap) { List<ConfigCommand> commandList = new ArrayList<>(); // if skip then return empty list. if (parent.isSkipConfiguration()) { return commandList; } Map<CellAddress, ? extends Comment> comments = null; try { // due to a poi bug. null exception throwed if no comments in the // sheet. comments = sheet.getCellComments(); } catch (Exception ex) { LOG.log(Level.FINE, "Null exception throwed when no comment exists: " + ex.getLocalizedMessage(), ex); } if (comments == null) { return commandList; } // not sure the map is sorted. So use tree map to sort it. SortedSet<CellAddress> keys = new TreeSet<>(comments.keySet()); // go through each comments // if found tie command then transfer it to list also remove from // comments. for (CellAddress key : keys) { Cell cell = sheet.getRow(key.getRow()).getCell(key.getColumn(), MissingCellPolicy.CREATE_NULL_AS_BLANK); buildCommandList(sheet, sheetRightCol, cell, commandList, cellAttributesMap); } return commandList; }