Bug 54316 - NullPointerException when reading spreadsheet with external reference
Summary: NullPointerException when reading spreadsheet with external reference
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.9-dev
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2012-12-17 09:16 UTC by Jan
Modified: 2014-08-01 13:56 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Jan 2012-12-17 09:16:37 UTC
I'm seeing a NullPointerException when trying to read an HSSF spreadsheet using POI 3.9.0. The error happens here:

ExternSheetNameResolver.prependSheetName(FormulaRenderingWorkbook, int, String) line: 34	
Ref3DPtg.toFormulaString(FormulaRenderingWorkbook) line: 91	
FormulaRenderer.toFormulaString(FormulaRenderingWorkbook, Ptg[]) line: 92	
HSSFFormulaParser.toFormulaString(HSSFWorkbook, Ptg[]) line: 83	
HSSFCell.getCellFormula() line: 621	

Debugging it, I see in ExternSheetNameResolver.prependSheetName() that the sheet name coming back from the ExternalSheet object is null. (This comes from LinkTable.getExternalBookAndSheetName(), where shIx gets the value -1).

The spreadsheet in question has a couple of external references of the form 'NNNN.xls'#$''.D1, which is where the error occurs. (I'm unfortunately not able to attach the spreasheet as it contains confidential information)
Comment 1 Nick Burch 2014-08-01 13:56:52 UTC
I believe this has been solved in 3.11 beta 1, with the various updates to how external spreadsheets are supported

If the problem still remains for you with 3.11, please create a simple excel file which shows the problem, and an associated small junit unit test, and re-open the bug.