You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by shankarrao <sh...@gmail.com> on 2011/01/28 13:18:44 UTC

How to determine if a cell has value in it?

I want to know if a cell (say A3) has a value in it. If so, i do not want to
replace the existing value in the cell with the new value. However if the
cell does not have any value in it, i want to add a new value to it.

Could you please let me know how can i do this.

Thanks for your help!
-Shankar
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-determine-if-a-cell-has-value-in-it-tp3361343p3361343.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How to determine if a cell has value in it?

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
Be aware also that if a cell does not have a value in it, it may well not
exist. What you see when viewing the file using Excel is a GUI that is
populated with data read from the file. If the user never populated cell A13
for example then a record for that cell will not exist in the file. The
upshot of all of this is that you also want to check to make sure that the
cell is not null; a null value will be returned if you try to get a cell
that appears empty when viewing the sheet using Excel but in fact does not
exist in the file. If you prefer, rather than checking for null values, you
can use the MissingCellPolicy technique and say, simply, return a new empty
cell rather than a null value.

Yours

Mark B
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-determine-if-a-cell-has-value-in-it-tp3361343p3361368.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How to determine if a cell has value in it?

Posted by Aniket Banerjee <co...@gmail.com>.
You can try :
if(cell.getCellType() == Cell.CELL_TYPE_BLANK) {

}

Hope this is clear.

Thanks,
Aniket
On Fri, Jan 28, 2011 at 5:48 PM, shankarrao <sh...@gmail.com> wrote:

>
> I want to know if a cell (say A3) has a value in it. If so, i do not want
> to
> replace the existing value in the cell with the new value. However if the
> cell does not have any value in it, i want to add a new value to it.
>
> Could you please let me know how can i do this.
>
> Thanks for your help!
> -Shankar
> --
> View this message in context:
> http://apache-poi.1045710.n5.nabble.com/How-to-determine-if-a-cell-has-value-in-it-tp3361343p3361343.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>