208920902091209220932094209520962097
* * @param toprow the top row to show in desktop window pane * @param leftcol the left column to show in desktop window pane */ public void showInPane(short toprow, short leftcol) { CellReference cellReference = new CellReference(toprow, leftcol); String cellRef = cellReference.formatAsString(); getPane().setTopLeftCell(cellRef); }
2195219621972198219922002201220222032204
* @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()); }
99100101102103104105106
return column.getValue(field_2_col); } protected final String formatReferenceAsString() { // Only make cell references as needed. Memory is an issue CellReference cr = new CellReference(getRow(), getColumn(), !isRowRelative(), !isColRelative()); return cr.formatAsString(); }
453454455456457458459460461462463464465466
// retrieve the cell at the named range and test its contents AreaReference aref = new AreaReference(aNamedCell.getRefersToFormula()); assertTrue("Should be exactly 1 cell in the named cell :'" +cellName+"'", aref.isSingleCell()); CellReference cref = aref.getFirstCell(); assertNotNull(cref); Sheet s = wb.getSheet(cref.getSheetName()); assertNotNull(s); Row r = sheet.getRow(cref.getRow()); Cell c = r.getCell(cref.getCol()); String contents = c.getRichStringCellValue().getString(); assertEquals("Contents of cell retrieved by its named reference", contents, cellValue); }
487488489490491492493494495496497498499
int namedCellIdx = wb.getNameIndex(cname); Name aNamedCell = wb.getNameAt(namedCellIdx); assertNotNull(aNamedCell); // retrieve the cell at the named range and test its contents CellReference cref = new CellReference(aNamedCell.getRefersToFormula()); assertNotNull(cref); Sheet s = wb.getSheet(cref.getSheetName()); Row r = sheet.getRow(cref.getRow()); Cell c = r.getCell(cref.getCol()); String contents = c.getRichStringCellValue().getString(); assertEquals("Contents of cell retrieved by its named reference", contents, cvalue); }
2627282930313233
public final class TestCellReference extends TestCase { public void testAbsRef1(){ CellReference cf = new CellReference("$B$5"); confirmCell(cf, null, 4, 1, true, true, "$B$5"); }
3132333435363738
CellReference cf = new CellReference("$B$5"); confirmCell(cf, null, 4, 1, true, true, "$B$5"); } public void testAbsRef2(){ CellReference cf = new CellReference(4,1,true,true); confirmCell(cf, null, 4, 1, true, true, "$B$5"); }
3637383940414243
CellReference cf = new CellReference(4,1,true,true); confirmCell(cf, null, 4, 1, true, true, "$B$5"); } public void testAbsRef3(){ CellReference cf = new CellReference("B$5"); confirmCell(cf, null, 4, 1, true, false, "B$5"); }
4142434445464748
CellReference cf = new CellReference("B$5"); confirmCell(cf, null, 4, 1, true, false, "B$5"); } public void testAbsRef4(){ CellReference cf = new CellReference(4,1,true,false); confirmCell(cf, null, 4, 1, true, false, "B$5"); }
4647484950515253
CellReference cf = new CellReference(4,1,true,false); confirmCell(cf, null, 4, 1, true, false, "B$5"); } public void testAbsRef5(){ CellReference cf = new CellReference("$B5"); confirmCell(cf, null, 4, 1, false, true, "$B5"); }