final String c1str = (sheet1 != null ? sheet1 : "") + (sheet2 != null ? (":" + sheet2) : "") + (sheet1 != null ? "!" : "") + lt;
final SpreadsheetVersion ver = ((Book)sheet.getWorkbook()).getSpreadsheetVersion();
final int maxcol = ver.getLastColumnIndex();
final int maxrow = ver.getLastRowIndex();
AreaReference ref = null;
try {
final CellReference c1 = new CellReference(c1str);
if (c1.getCol() <= maxcol && c1.getRow() <= maxrow) {
final CellReference c2 = rb != null ? new CellReference(rb) : c1;
if (rb != null) {
if (c2.getCol() <= maxcol && c2.getRow() <= maxrow) {
ref = new AreaReference(c1, c2);
}
} else {
ref = new AreaReference(c1, c2);
}
}
} catch(Exception ex) {
//ignore, return null ref and let upper case do it!
}