/** * Creates a comment. * @param anchor the client anchor describes how this comment is attached * to the sheet. * @return the newly Created comment. */ public IComment CreateCellComment(IClientAnchor 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); NPOI.OpenXmlFormats.Vml.CT_Shape vmlShape = vml.newCommentShape(); if (ca.IsSet()) { // convert offsets from emus to pixels since we get a DrawingML-anchor // but create a VML Drawing int dx1Pixels = ca.Dx1 / Units.EMU_PER_PIXEL; int dy1Pixels = ca.Dy1 / Units.EMU_PER_PIXEL; int dx2Pixels = ca.Dx2 / Units.EMU_PER_PIXEL; int dy2Pixels = ca.Dy2 / Units.EMU_PER_PIXEL; String position = ca.Col1 + ", " + dx1Pixels + ", " + ca.Row1 + ", " + dy1Pixels + ", " + ca.Col2 + ", " + dx2Pixels + ", " + ca.Row2 + ", " + dy2Pixels; vmlShape.GetClientDataArray(0).SetAnchorArray(0, position); } String ref1 = new CellReference(ca.Row1, ca.Col1).FormatAsString(); if (comments.FindCellComment(ref1) != null) { throw new ArgumentException("Multiple cell comments in one cell are not allowed, cell: " + ref1); } return(new XSSFComment(comments, comments.NewComment(ref1), vmlShape)); }
/// <summary> /// Removes the comment for this cell, if there is one. /// </summary> public void RemoveCellComment() { IComment comment = this.CellComment; if (comment != null) { CellAddress ref1 = new CellAddress(GetReference()); XSSFSheet sh = (XSSFSheet)Sheet; sh.GetCommentsTable(false).RemoveComment(ref1); sh.GetVMLDrawing(false).RemoveCommentShape(RowIndex, ColumnIndex); } }
/// <summary> /// Removes the comment for this cell, if there is one. /// </summary> public void RemoveCellComment() { IComment comment = this.CellComment; if (comment != null) { String ref1 = _cell.r; XSSFSheet sh = (XSSFSheet)Sheet; sh.GetCommentsTable(false).RemoveComment(ref1); sh.GetVMLDrawing(false).RemoveCommentShape(RowIndex, ColumnIndex); } }
public void RemoveCellComment() { if (this.CellComment == null) { return; } string r = this._cell.r; XSSFSheet sheet = (XSSFSheet)this.Sheet; sheet.GetCommentsTable(false).RemoveComment(r); sheet.GetVMLDrawing(false).RemoveCommentShape(this.RowIndex, this.ColumnIndex); }
public IComment CreateCellComment(IClientAnchor anchor) { XSSFClientAnchor xssfClientAnchor = (XSSFClientAnchor)anchor; XSSFSheet parent = (XSSFSheet)this.GetParent(); CommentsTable commentsTable = parent.GetCommentsTable(true); NPOI.OpenXmlFormats.Vml.CT_Shape vmlShape = parent.GetVMLDrawing(true).newCommentShape(); if (xssfClientAnchor.IsSet()) { string str = xssfClientAnchor.Col1.ToString() + ", 0, " + (object)xssfClientAnchor.Row1 + ", 0, " + (object)xssfClientAnchor.Col2 + ", 0, " + (object)xssfClientAnchor.Row2 + ", 0"; vmlShape.GetClientDataArray(0).SetAnchorArray(0, str); } return((IComment) new XSSFComment(commentsTable, commentsTable.CreateComment(), vmlShape) { Column = xssfClientAnchor.Col1, Row = xssfClientAnchor.Row1 }); }
/** * Creates a comment. * @param anchor the client anchor describes how this comment is attached * to the sheet. * @return the newly Created comment. */ public IComment CreateCellComment(IClientAnchor 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); NPOI.OpenXmlFormats.Vml.CT_Shape vmlShape = vml.newCommentShape(); if (ca.IsSet()) { String position = ca.Col1 + ", 0, " + ca.Row1 + ", 0, " + ca.Col2 + ", 0, " + ca.Row2 + ", 0"; vmlShape.GetClientDataArray(0).SetAnchorArray(0, position); } String ref1 = new CellReference(ca.Row1, ca.Col1).FormatAsString(); XSSFComment shape = new XSSFComment(comments, comments.NewComment(ref1), vmlShape); return(shape); }