@Override public void cell(String cellRef, String formattedValue, XSSFComment comment) { if (firstCellOfRow) { firstCellOfRow = false; } else { output.append('\t'); } if (formattedValue != null) { checkMaxTextSize(output, formattedValue); output.append(formattedValue); } if (includeCellComments && comment != null) { String commentText = comment.getString().getString().replace('\n', ' '); output.append(formattedValue != null ? " Comment by " : "Comment by "); checkMaxTextSize(output, commentText); if (commentText.startsWith(comment.getAuthor() + ": ")) { output.append(commentText); } else { output.append(comment.getAuthor()).append(": ").append(commentText); } } }
public void setString(String string) { setString(new XSSFRichTextString(string)); }
int column1 = o1.getColumn(); int column2 = o2.getColumn(); return o1.hashCode() - o2.hashCode(); int newColumnIndex = shiftedRowNum(startColumnIndex, endColumnIndex, n, columnIndex); if(newColumnIndex != columnIndex){ XSSFComment xssfComment = new XSSFComment(sheetComments, comment, vml == null ? null : vml.findCommentShape(ref.getRow(), columnIndex)); commentsToShift.put(xssfComment, newColumnIndex); entry.getKey().setColumn(entry.getValue());
/** * Set the row of the cell that contains the comment * * If changing both row and column, use {@link #setAddress}. * * @param row the 0-based row of the cell that contains the comment */ @Override public void setRow(int row) { setAddress(row, getColumn()); }
/** * Set the column of the cell that contains the comment * * If changing both row and column, use {@link #setAddress}. * * @param col the 0-based column of the cell that contains the comment */ @Override public void setColumn(int col) { setAddress(getRow(), col); }
/** * Creates a comment. * @param anchor the client anchor describes how this comment is attached * to the sheet. * @return the newly created comment. */ public XSSFComment createCellComment(ClientAnchor anchor) { XSSFClientAnchor ca = (XSSFClientAnchor)anchor; XSSFSheet sheet = (XSSFSheet)getParent(); //create comments and vmlDrawing parts if they don't exist CommentsTable comments = sheet.getCommentsTable(true); XSSFVMLDrawing vml = sheet.getVMLDrawing(true); schemasMicrosoftComVml.CTShape vmlShape = vml.newCommentShape(); if(ca.isSet()){ String position = ca.getCol1() + ", 0, " + ca.getRow1() + ", 0, " + ca.getCol2() + ", 0, " + ca.getRow2() + ", 0"; vmlShape.getClientDataArray(0).setAnchorArray(0, position); } XSSFComment shape = new XSSFComment(comments, comments.newComment(), vmlShape); shape.setColumn(ca.getCol1()); shape.setRow(ca.getRow1()); return shape; }
/** * Finds the cell comment at cellAddress, if one exists * * @param cellAddress the address of the cell to find a comment * @return cell comment if one exists, otherwise returns null */ @Override public XSSFComment findCellComment(CellAddress cellAddress) { CTComment ct = getCTComment(cellAddress); return ct == null ? null : new XSSFComment(this, ct, null); }
@Override public void cell(String cellReference, String formattedValue, XSSFComment comment) { // create empty column, if needed CellAddress currentCellAddress = new CellAddress(cellReference); for (int i=this.currentColumn;i<currentCellAddress.getColumn();i++) { this.spreadSheetCellDAOCurrentRow.add(null); this.currentColumn++; } // add column SpreadSheetCellDAO currentDAO = null; if (comment!=null) { currentDAO = new SpreadSheetCellDAO(formattedValue,comment.getString().getString(), "", cellReference,this.sheetName); } else { currentDAO = new SpreadSheetCellDAO(formattedValue,"", "", cellReference,this.sheetName); } this.currentColumn++; this.spreadSheetCellDAOCurrentRow.add(currentDAO); } @Override
/** * Assign a cell comment to a cell region in this worksheet * * @param cellRef cell region * @param comment the comment to assign * @deprecated since Nov 2009 use {@link XSSFCell#setCellComment(org.apache.poi.ss.usermodel.Comment)} instead */ @Deprecated public static void setCellComment(String cellRef, XSSFComment comment) { CellReference cellReference = new CellReference(cellRef); comment.setRow(cellReference.getRow()); comment.setColumn(cellReference.getCol()); }
/** * Creates a new XSSFComment, associated with a given * low level comment object. */ public XSSFComment(CommentsTable comments, CTComment comment, CTShape vmlShape) { _comment = comment; _comments = comments; _vmlShape = vmlShape; // we potentially need to adjust the column/row information in the shape // the same way as we do in setRow()/setColumn() if(comment != null && vmlShape != null && vmlShape.sizeOfClientDataArray() > 0) { CellReference ref = new CellReference(comment.getRef()); CTClientData clientData = vmlShape.getClientDataArray(0); clientData.setRowArray(0, new BigInteger(String.valueOf(ref.getRow()))); clientData.setColumnArray(0, new BigInteger(String.valueOf(ref.getCol()))); avoidXmlbeansCorruptPointer(vmlShape); } }
/** * Set the row of the cell that contains the comment * * @param row the 0-based row of the cell that contains the comment */ public void setRow(int row) { String oldRef = _comment.getRef(); String newRef = (new CellReference(row, getColumn())).formatAsString(); _comment.setRef(newRef); _comments.referenceUpdated(oldRef, _comment); if(_vmlShape != null) _vmlShape.getClientDataArray(0).setRowArray(0, new BigInteger(String.valueOf(row))); }
/** * Set the column of the cell that contains the comment * * @param col the 0-based column of the cell that contains the comment */ public void setColumn(int col) { String oldRef = _comment.getRef(); CellReference ref = new CellReference(getRow(), col); _comment.setRef(ref.formatAsString()); _comments.referenceUpdated(oldRef, _comment); if(_vmlShape != null) { _vmlShape.getClientDataArray(0).setColumnArray( new BigInteger[] { new BigInteger(String.valueOf(col)) } ); // There is a very odd xmlbeans bug when changing the column // arrays which can lead to corrupt pointer // This call seems to fix them again... See bug #50795 _vmlShape.getClientDataList().toString(); } }
/** * Returns all cell comments on this sheet. * @return A map of each Comment in this sheet, keyed on the cell address where * the comment is located. * @deprecated use <code>getCellAddresses</code> instead */ @Removal(version = "4.2") @Deprecated public Map<CellAddress, XSSFComment> getCellComments() { prepareCTCommentCache(); final TreeMap<CellAddress, XSSFComment> map = new TreeMap<>(); for (final Entry<CellAddress, CTComment> e : commentRefs.entrySet()) { map.put(e.getKey(), new XSSFComment(this, e.getValue(), null)); } return map; }
public XLSXCellNode(XSSFSheet sheet,XSSFCell cell,int index,XLSXExpression expression) { super(sheet,cell,expression); assert cell != null : "null cell" ; if(cell.getCTCell().isSetF()){ formulaStringValue = cell.getCTCell().getF().getStringValue(); } colRef = CellReference.convertNumToColString(index); int rowRef = getCell().getRowIndex() + 1; absoluteRef = colRef + rowRef; if(cell.getCTCell().isSetS()){ s = cell.getCTCell().getS(); } workbookPr = getSheet().getWorkbook().getCTWorkbook().getWorkbookPr(); comment = cell.getCellComment(); if(comment != null){ commnetExpr = CellExpressionParser.parseExpression(comment.getString().getString()); } }
/** * Set the row of the cell that contains the comment * * If changing both row and column, use {@link #setAddress}. * * @param row the 0-based row of the cell that contains the comment */ @Override public void setRow(int row) { setAddress(row, getColumn()); }
/** * Set the column of the cell that contains the comment * * If changing both row and column, use {@link #setAddress}. * * @param col the 0-based column of the cell that contains the comment */ @Override public void setColumn(int col) { setAddress(getRow(), col); }