Bug 60460

Summary: Null pointer exception in ExternSheetNameResolver.prependSheetName method
Product: POI Reporter: Ricky <zhangchaowang>
Component: SS CommonAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.15-FINAL   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X 10.1   
Attachments: test file

Description Ricky 2016-12-09 04:29:03 UTC
I'm parsing Excel file from EUSES data set. When get formula of name 'Database' with range ='file:///HEPPC3/gt$/Teaching/Syn/[physyn.xls]#REF'!$AK$70:$AL$70

It throw null pointer exception:
...
for(Name rangedName : wb.getAllNames())
  if (!rangedName.isFunctionName()) {
    xlWorkbook.addNamedRange(rangedName.getNameName(), rangedName.getRefersToFormula());
}
...


Exception in thread "main" java.lang.NullPointerException
	at org.apache.poi.ss.formula.ptg.ExternSheetNameResolver.prependSheetName(ExternSheetNameResolver.java:40)
	at org.apache.poi.ss.formula.ptg.Area3DPtg.toFormulaString(Area3DPtg.java:104)
	at org.apache.poi.ss.formula.FormulaRenderer.toFormulaString(FormulaRenderer.java:91)
	at org.apache.poi.hssf.model.HSSFFormulaParser.toFormulaString(HSSFFormulaParser.java:119)
	at org.apache.poi.hssf.usermodel.HSSFName.getRefersToFormula(HSSFName.java:204)


Sheetname is null. I guess sheet name is #REF error in Excel. Should it return #REF or the index of sheet?

Attached file is test file to replicate the issues.
Comment 1 Ricky 2016-12-09 04:29:59 UTC
Created attachment 34511 [details]
test file
Comment 2 Ricky 2016-12-09 16:19:11 UTC
*** Bug 60459 has been marked as a duplicate of this bug. ***
Comment 3 Ricky 2016-12-09 17:27:27 UTC
Move this bug from HSSF to SS common component.
Comment 4 Dominik Stadler 2018-12-30 22:45:52 UTC
This is fixed via r1850008 now by adding some null-checks and returning #REF for workbook-name and sheetname if needed.