Bug 60352

Summary: XSSFExcelExtractor extracts "null" as text from empty cells
Product: POI Reporter: Cosmin Marginean <cos.marginean>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.16-dev   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X 10.1   
Attachments: File that reproduces this

Description Cosmin Marginean 2016-11-08 09:29:27 UTC
We use XSSFExcelExtractor as a mechanism to extract the complete text in an Excel file, however it seems that in certain circumstances the "null" value is extracted from an empty cell.

For example:

> Breakdown of data generated by project, technology, submitting centre	null	> null	null	null	null	null
> null	null	null	null	null	null	null
> null	Abbreviation Definitions	null	null	null	null	null
> null	Platform	Definition	null	null	null	null
> null	LS454	454 Roche Genome Sequencer FLX System	null	null	null	


The patch is relatively simple (and I'm happy to create a PR for it on GitHub). All we need to is to wrap the last two lines in XSSFExcelExtractor.handleNonStringCell() with a null check

>         if (contents != null) {
>             checkMaxTextSize(text, contents);
>             text.append(contents);
>         }

This would then perform as expected and extract this text instead.

> Breakdown of data generated by project, technology, submitting centre						
> 						
> 	Abbreviation Definitions					
> 	Platform	Definition				
> 	LS454	454 Roche Genome Sequencer FLX System

We believe that an empty string is the preferred option here, because the text "null" itself might be used as cell contents in certain cases. In that situation it's difficult to discriminate between these occurrences (is it the text "null" or is the cell empty?)

Looking forward to hearing your thoughts.
Comment 1 Dominik Stadler 2017-05-08 18:11:48 UTC
Fixed via r1794260, should be included in release 3.17-beta1, thanks for the report and the suggested fix.
Comment 2 Cosmin Marginean 2017-05-09 13:42:26 UTC
Great! Many thanks!
Comment 3 m.ion@oodrive.com 2018-07-31 14:57:38 UTC
Is it possible to have a sample file to reproduce the bug, please?

Regards,

M. Ion
Comment 4 Cosmin Marginean 2018-07-31 15:00:36 UTC
Created attachment 36062 [details]
File that reproduces this
Comment 5 Cosmin Marginean 2018-07-31 15:01:31 UTC
Hi Marian.

I tried replying to your email earlier today but it bounced (Recipient address rejected)

Attached is a sample file for this. Please note this bug seems to be solved in 3.17.

Regards
Cos