Bug 50718 - New CellReference created from damaged Name throws misleading "Mismatched quotes" Runtime Ex
Summary: New CellReference created from damaged Name throws misleading "Mismatched quo...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.7-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-03 22:37 UTC by Carl Pritchett
Modified: 2011-03-04 11:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carl Pritchett 2011-02-03 22:37:17 UTC
Creating a CellReference from a Name's "refers to formula" when that named range has been half deleted throws a misleading exception:

"java.lang.RuntimeException: Mismatched quotes: ('MySheetName'!#REF!)"

If a Name has been half deleted (e.g. one row out of the two the Name refers to is deleted) then the method Name.getRefersToFormula() will return something like:

'MySheetName'!#REF!

When creating a CellReference from this string the org.apache.poi.ss.util.CellReference.parseSheetName(CellReference.java:376) method will fail as it does not expect the string to contain two "!" characters.

The CellReference is created as follows:

AreaReference aref = new AreaReference(namedRange.getRefersToFormula());

The exception is misleading as the real error is that the "refers to formula" (the "reference" param in the parseSheetName() method) is really invalid. Both quotes are present thus the error "Mismatched quotes" is not correct.


The relevant stack trace is:

java.lang.RuntimeException: Mismatched quotes: ('MySheetTitle'!#REF!)
	at org.apache.poi.ss.util.CellReference.parseSheetName(CellReference.java:376)
	at org.apache.poi.ss.util.CellReference.separateRefParts(CellReference.java:340)
	at org.apache.poi.ss.util.CellReference.<init>(CellReference.java:88)
	at org.apache.poi.ss.util.AreaReference.<init>(AreaReference.java:55)
	at org.apache.poi.hssf.util.AreaReference.<init>(AreaReference.java:28)
Comment 1 Nick Burch 2011-03-04 11:18:06 UTC
Fixed in r1078039 - now gives a more helpful:
  IllegalArgumentException - Cell reference invalid: Sheet1!#REF!