You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Jeffrey A Kenward <ke...@dteenergy.com> on 2008/09/15 21:53:01 UTC
Blank and null cells
Hi all,
I'm using the 3.5 beta release and it's not working as I expect it to. I
don't know if I'm doing it wrong or this is a bug.
I'm using the Row iterator from sheet and subsequently the Cell iterator
from row to read a sheet's data.
It's basically a sheet with addresses. But some cells (like a 2nd address
- typically used for something like an apartment or suite number) are
empty.
When this value is filled, the size of the iterator comes back as 8 cells
in the row (location code, location name, addr1, addr2, city, st, zip,
country).
But when the addr2 is blank in excel 2007, the iterator comes back as only
have 7 values (shifting all the values and messing up my location data
basically).
I've tried setting the workbook MissingCellPolicy to RETURN_NULL_AND_BLANK
but that doesn't seem to help.
Am I doing this wrong? How is this typically done?
-Jeff
*** PROPRIETARY, CONFIDENTIAL OR PRIVILEGED COMMUNICATION ***
This communication may contain proprietary, privileged or confidential
information protected by law. It is solely for the use of the intended
recipient named above. Any review, dissemination, distribution,
forwarding, or copying of this communication by someone other than the
intended recipient, or the employee responsible for delivering this
communication to the intended recipient, is prohibited. If you have
received this communication in error, please immediately notify the sender
via email, then destroy the original message.
Re: Blank and null cells
Posted by Nick Burch <ni...@torchbox.com>.
On Mon, 15 Sep 2008, Jeffrey A Kenward wrote:
> I'm using the Row iterator from sheet and subsequently the Cell iterator
> from row to read a sheet's data.
>
> But when the addr2 is blank in excel 2007, the iterator comes back as
> only have 7 values (shifting all the values and messing up my location
> data basically).
This is entirely as expected. The iterators only by default iterate over
things which are physically present in the file. The javadocs do explain
this, eg
http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFRow.html#cellIterator()
> I've tried setting the workbook MissingCellPolicy to
> RETURN_NULL_AND_BLANK but that doesn't seem to help.
It won't. As per the javadocs, that only affects fetching cells, not the
iterator
> Am I doing this wrong? How is this typically done?
Either check the cell's number when it's returned, or follow most of the
examples and just use a for loop + getCell(num), which uses the missing
cell policy
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org