This might work better if( "".equals( cell.getStringValue())
hashcode() won't be guaranteed to work always, because someone could decide that the implementation needs to change. "" == cell.getStringValue() won't always work, because you should not use == to compare string values unless both String objects have been finalized. -----Original Message----- From: Mike Serra [mailto:[EMAIL PROTECTED] Sent: Thursday, May 12, 2005 10:14 PM To: POI Users List Subject: Re: POI cell differences between a blank and a completely cleared cell Joe, One thing that I do to see if a cell is blank, is to check whether it contains a blank string. But, I think I recall that checking whether its contents == "" will not work. What I did was to check if (cell.getStringCellValue().hashCode() == 0) It's been a while since I tested it, but I'm pretty sure that works. Of course, this method assumes that when you delete cells with the delete key they are set to a blank string, and presumably they are set to CELL_TYPE_STRING. I don't know for certain whether or not a blank cell could somehow be of numeric type, but it doesn't seem to me like that would make sense. Hope this helps. - Mike S. Joe DeVilla wrote: >Hi > >I had a question regarding POI. > >I have a cell in an Excel sheet that may or may not be empty. I am currently >using the following to see if a cell is empty or not: > >if(cell.getCellType() != HSSFCell.CELL_TYPE_BLANK ) //is the cell empty?, if >not, execute the code below >{ > the cell has contents, do some stuff >} > >When I highlight the cell and use Edit->Clear->All, the cell is empty, and the >code in the brackets isnt executed. > >However, if I only clear it by using the <delete> key, the cell contents >appear to be empty, but the cell itself is not empty, so the code is >executed. > >Is there another method that I can use to determine if a cell has nothing >inside it? > >Thanks > >Joe > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >Mailing List: http://jakarta.apache.org/site/mail2.html#poi >The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/ > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] Mailing List: http://jakarta.apache.org/site/mail2.html#poi The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] Mailing List: http://jakarta.apache.org/site/mail2.html#poi The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
