Bug 60460 - Null pointer exception in ExternSheetNameResolver.prependSheetName method
Summary: Null pointer exception in ExternSheetNameResolver.prependSheetName method
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 3.15-FINAL
Hardware: Macintosh Mac OS X 10.1
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
: 60459 (view as bug list)
Depends on:
Reported: 2016-12-09 04:29 UTC by Ricky
Modified: 2018-12-30 22:45 UTC (History)
0 users

test file (66.50 KB, application/vnd.ms-excel)
2016-12-09 04:29 UTC, Ricky

Note You need to log in before you can comment on or make changes to this bug.
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.