<changes>
<release version="3.8-beta2" date="2011-??-??">
+ <action dev="poi-developers" type="fix">50718 - More helpful error message when you try to create a CellReference with #REF!</action>
<action dev="poi-developers" type="fix">50784 - XSSFColors return by XSSFFont now have theme information applied to them</action>
<action dev="poi-developers" type="fix">50846 - Improve how XSSFColor inherits from Themes</action>
<action dev="poi-developers" type="fix">50847 - XSSFFont now accepts the full range of Charsets from FontChartset</action>
* delimited and escaped as per normal syntax rules for formulas.
*/
public CellReference(String cellRef) {
+ if(cellRef.endsWith("#REF!")) {
+ throw new IllegalArgumentException("Cell reference invalid: " + cellRef);
+ }
+
String[] parts = separateRefParts(cellRef);
_sheetName = parts[0];
String colRef = parts[1];
* name still in ALPHA-26 number format. The third element is the row.
*/
private static String[] separateRefParts(String reference) {
-
int plingPos = reference.lastIndexOf(SHEET_NAME_DELIMITER);
String sheetName = parseSheetName(reference, plingPos);
int start = plingPos+1;
try {
new AreaReference(name2.getRefersToFormula());
fail("attempt to supply an invalid reference to AreaReference constructor results in exception");
- } catch (StringIndexOutOfBoundsException e) { // TODO - use a different exception for this condition
+ } catch (IllegalArgumentException e) { // TODO - use a stronger typed exception for this condition
// expected during successful test
}
}
confirmCrInRange(false, "A", "0", v97);
confirmCrInRange(false, "A", "0", v2007);
}
+
+ public void testInvalidReference() {
+ try {
+ new CellReference("Sheet1!#REF!");
+ fail("Shouldn't be able to create a #REF! refence");
+ } catch(IllegalArgumentException e) {}
+
+ try {
+ new CellReference("'MySheetName'!#REF!");
+ fail("Shouldn't be able to create a #REF! refence");
+ } catch(IllegalArgumentException e) {}
+
+ try {
+ new CellReference("#REF!");
+ fail("Shouldn't be able to create a #REF! refence");
+ } catch(IllegalArgumentException e) {}
+ }
private static void confirmCrInRange(boolean expResult, String colStr, String rowStr,
SpreadsheetVersion sv) {