From cb23ca952bc61671b9ff566e9420bbce5f6e4596 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Mon, 9 May 2016 05:25:29 +0000 Subject: [PATCH] bug 59443: use Comment.setAddress when changing both row and column of cell comment address git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742880 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/xssf/usermodel/examples/CellComments.java | 4 ++-- src/java/org/apache/poi/ss/usermodel/Comment.java | 4 ++++ src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java index 252d7488a8..a94e58a342 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java @@ -17,6 +17,7 @@ package org.apache.poi.xssf.usermodel.examples; import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellAddress; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.io.IOException; @@ -68,8 +69,7 @@ public class CellComments { comment2.setString(str2); comment2.setAuthor("Apache POI"); - comment2.setColumn(2); - comment2.setRow(2); + comment2.setAddress(new CellAddress("C3")); String fname = "comments.xlsx"; FileOutputStream out = new FileOutputStream(fname); diff --git a/src/java/org/apache/poi/ss/usermodel/Comment.java b/src/java/org/apache/poi/ss/usermodel/Comment.java index 1fbda29fac..8f5396ca6b 100644 --- a/src/java/org/apache/poi/ss/usermodel/Comment.java +++ b/src/java/org/apache/poi/ss/usermodel/Comment.java @@ -113,6 +113,10 @@ public interface Comment { /** * Return defines position of this anchor in the sheet. + * The anchor is the yellow box/balloon that is rendered on top of the sheets + * when the comment is visible. + * + * To associate a comment with a different cell, use {@link #setAddress}. * * @return defines position of this anchor in the sheet */ diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java index 1053c834de..29aaa867e2 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java @@ -1039,8 +1039,7 @@ public final class XSSFCell implements Cell { return; } - comment.setRow(getRowIndex()); - comment.setColumn(getColumnIndex()); + comment.setAddress(getRowIndex(), getColumnIndex()); } /** -- 2.39.5