poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Lloyd" <llo...@us.ibm.com>
Subject RE: Recognizing Dates
Date Wed, 12 Mar 2003 20:14:52 GMT

Louri,
Thanks for the code snippet. With a couple of modifications to avoid false
detections, it worked for me. I changed the condition to look for "D" and
"M" in the format to avoid confusion with "RED". This seems to work for my
application.

Thanks again,
John

Email  * lloydj@us.ibm.com
Phone  * 919-254-8021
Snail  * MZDA/062, IBM Corp., P.O. Box 12195, RTP, NC 27709-2195



                                                                                         
                                       
                      "Iouri                                                             
                                       
                      Michtchenko"             To:       "POI Users List" <poi-user@jakarta.apache.org>
                         
                      <Iouri.Michtchenk        cc:                                    
                                          
                      o@cern.ch>               Subject:  RE: Recognizing Dates        
                                          
                                                                                         
                                       
                      03/12/2003 11:45                                                   
                                       
                      AM                                                                 
                                       
                      Please respond to                                                  
                                       
                      "POI Users List"                                                   
                                       
                                                                                         
                                       



Hi,
I use this code:

  boolean isCellDateFormatted(HSSFWorkbook book, HSSFCell cell)
  {
    boolean result = false;
    short   format = cell.getCellStyle().getDataFormat();

    if (HSSFDateUtil.isValidExcelDate(cell.getNumericCellValue()))
    {
      if (HSSFDateUtil.isInternalDateFormat(format))
      {
        result = true;
      }
      else
      {
        String fmtText = book.createDataFormat().getFormat(format);

        if (fmtText != null
            && ((fmtText = fmtText.toUpperCase()).indexOf("D") >= 0
                  || fmtText.indexOf("M") >= 0
                  || fmtText.indexOf("Y") >= 0
                  || fmtText.indexOf("H") >= 0
                  || fmtText.indexOf("S") >= 0))
        {
          result = true;
        }
      }
    }

    return result;
  }

I am not sure that it works in 100% of cases.

Regards,
Iouri

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






Mime
View raw message