add R1C1 test

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897668 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-02-01 19:56:54 +00:00
parent 893034c806
commit d7e72c91fd
3 changed files with 12 additions and 0 deletions

View File

@ -171,4 +171,13 @@ public class CellAddress implements Comparable<CellAddress> {
public String formatAsString() {
return CellReference.convertNumToColString(this._col)+(this._row+1);
}
/**
* @return R1C1-style cell address string representation
* @see #formatAsString()
* @since POI 5.2.1
*/
public String formatAsR1C1String() {
return new CellReference(_row, _col).formatAsR1C1String();
}
}

View File

@ -410,11 +410,13 @@ public abstract class BaseTestCellComment {
assertEquals(CellAddress.A1, comment.getAddress());
CellAddress C2 = new CellAddress("C2");
assertEquals("C2", C2.formatAsString());
assertEquals("R2C3", C2.formatAsR1C1String());
comment.setAddress(C2);
assertEquals(C2, comment.getAddress());
CellAddress E10 = new CellAddress(9, 4);
assertEquals("E10", E10.formatAsString());
assertEquals("R10C5", E10.formatAsR1C1String());
comment.setAddress(9, 4);
assertEquals(E10, comment.getAddress());
}

View File

@ -51,6 +51,7 @@ final class TestCellAddress {
@Test
void testFormatAsString() {
assertEquals("A1", CellAddress.A1.formatAsString());
assertEquals("R1C1", CellAddress.A1.formatAsR1C1String());
}
@Test