Bug 60430

Summary: XSSFName.getSheetName() does not work with noncontiguous named ranges
Product: POI Reporter: Sean Smitz <sean.smitz>
Component: XSSFAssignee: POI Developers List <dev>
Status: NEW ---    
Severity: normal CC: sean.smitz
Priority: P2    
Version: 3.15-FINAL   
Target Milestone: ---   
Hardware: Macintosh   
OS: All   
Attachments: The 'Safety_getpic1' named range will trigger the IllegalArgumentException

Description Sean Smitz 2016-11-29 15:14:22 UTC
Created attachment 34488 [details]
The 'Safety_getpic1' named range will trigger the IllegalArgumentException

This is apparently related to bug 44949 which reported it in HSSFName. Mine appears in XSSFName. stack trace and trigger file follows:

1-29 09:55:09,561 [utionServiceListener] [execution] ERROR  - [OpName=executeService] [OpId=75eb4e56-720f-46c3-908d-b2acb2ad2f6f] [OpUser=http://openanzo.org/system/internal/sysadmin] [UserDesc=Anzo CLI] o.o.e.SemanticServiceExecutionService- Error executing operaton http://www.lilly.com/service/namedrange#processRequests
org.openanzo.exceptions.AnzoException: ErrorCode[5892] Error executing service/operation: http://www.lilly.com/service/namedrange/http://www.lilly.com/service/namedrange#processRequests service-specific-error:References passed to the AreaReference must be contiguous, use generateContiguous(ref) if you have non-contiguous references Root Cause: java.lang.IllegalArgumentException References passed to the AreaReference must be contiguous, use generateContiguous(ref) if you have non-contiguous references
	at org.openanzo.execution.v2.SemanticServiceExecutionService.executeServiceInternal(SemanticServiceExecutionService.java:727)
	at org.openanzo.execution.v2.SemanticServiceExecutionService.executeService(SemanticServiceExecutionService.java:538)
	at org.openanzo.execution.SemanticServiceExecutionService.executeServiceInternal(SemanticServiceExecutionService.java:590)
	at org.openanzo.execution.SemanticServiceExecutionService.executeService(SemanticServiceExecutionService.java:510)
	at org.openanzo.execution.SemanticServiceExecutionService.executeService(SemanticServiceExecutionService.java:333)
	at org.openanzo.combus.listeners.CombusExecutionServiceListener.handleMessage(CombusExecutionServiceListener.java:123)
	at org.openanzo.combus.endpoint.BaseServiceListener.processMessage(BaseServiceListener.java:660)
	at org.openanzo.combus.endpoint.BaseServiceListener$ProcessThread.run(BaseServiceListener.java:368)
Caused by: java.lang.IllegalArgumentException: References passed to the AreaReference must be contiguous, use generateContiguous(ref) if you have non-contiguous references
	at org.apache.poi.ss.util.AreaReference.<init>(AreaReference.java:45)
	at org.apache.poi.xssf.usermodel.XSSFName.getSheetName(XSSFName.java:293)
	at com.lilly.sdp.named_ranges.poi.NamedRangeWorksheet.processNamedRanges(NamedRangeWorksheet.java:92)
	at com.lilly.sdp.named_ranges.poi.NamedRangeWorksheet.<init>(NamedRangeWorksheet.java:31)
	at com.lilly.sdp.named_ranges.poi.NamedRangeWorkbook.<init>(NamedRangeWorkbook.java:47)
	at com.lilly.sdp.named_ranges.NamedRangeServiceImpl.processFile(NamedRangeServiceImpl.java:224)
	at com.lilly.sdp.named_ranges.NamedRangeServiceImpl.processRequest(NamedRangeServiceImpl.java:204)
	at com.lilly.sdp.named_ranges.NamedRangeServiceImpl.processRequests(NamedRangeServiceImpl.java:172)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.openanzo.execution.v2.SemanticServiceExecutionService.executeServiceInternal(SemanticServiceExecutionService.java:694)
	... 7 common frames omitted
Comment 1 Javen O'Neal 2016-11-29 17:08:13 UTC
Can you share a code sample that generates this error so that we can reproduce this?
Comment 2 Sean Smitz 2016-11-30 00:25:15 UTC
        final FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
        for (int i = 0; i < wb.getNumberOfNames(); i++) {
            Name name = wb.getNameAt(i);
            try {
                if (!ignoreNamedRanges.contains(name.getNameName()) && !name.getRefersToFormula().equals("#REF!") && name.getSheetName().equals(getTitle())) {
                    namedRanges.add(new NamedRange(name, sheet, evaluator));
                }
            } catch (IllegalArgumentException e) {
                // TODO: Add logging.
            }
        }
Comment 3 Sean Smitz 2016-11-30 00:28:57 UTC
final FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
for (int i = 0; i < wb.getNumberOfNames(); i++) {
    Name name = wb.getNameAt(i);
    try {
        if (!ignoreNamedRanges.contains(name.getNameName()) && !name.getRefersToFormula().equals("#REF!") && name.getSheetName().equals(getTitle())) {
                    namedRanges.add(new NamedRange(name, sheet, evaluator));
        }
    } catch (IllegalArgumentException e) {
                // TODO: Add logging.
    }
}


name.getSheetName() in the if-statement throws the exception.