You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Jan Stette <ja...@gmail.com> on 2012/12/12 19:12:59 UTC

NullPointerException when accessing HSSF spreadsheet with external reference

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

Is this a bug in POI, or is the external reference invalid? Is there
something I can do to work around this problem, given that I can't
necessarily change the content of these spreadsheets?

Regards,
Jan

Re: NullPointerException when accessing HSSF spreadsheet with external reference

Posted by Jan Stette <ja...@gmail.com>.
Raised as a bug: https://issues.apache.org/bugzilla/show_bug.cgi?id=54316


On 12 December 2012 18:12, Jan Stette <ja...@gmail.com> wrote:

> 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
>