As a newbie to POI, I found a few interesting constants and methods,
HSSFCell.CELL_TYPE_NUMERIC, HSSFDateUtil.isCellDateFormatted(HSSFCell cell),
and
cell.getDateCellValue().

>From the package org.apache.poi.hssf.dev, and file HSSF.java, I modified a
few
lines in the data dump section.  My test spreadsheet has date cells and time
cells, but no date/time cells, hence I assumed that integer values were
dates
and non integers were times.

  if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
    if (HSSFDateUtil.isCellDateFormatted(cell)){
      Date cellDate = cell.getDateCellValue();
      if (numCellVal == (int) numCellVal ){
        // datec2 = cell.getDateCellValue();
        value += "\t\t\tDate value="
              + dateFormatter.format(cellDate);

     
      }
      else {
        value += "\tTime value="
               + timeFormatter.format(cellDate);
      }
    }

Cheers 

-----Original Message-----
From: Avik Sengupta [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 17, 2005 5:04 AM
To: POI Users List
Subject: RE: Meaning of values of HSSFCellStyle.getDataFormat()

On Thu, 2005-02-17 at 10:16 +0100, Andrš Petr (EXT) wrote:
> Anyway, something like HSSFCell.getFormatedCellValue() would be really
useful.
> 
Well, its a concious decision in POI to be as close as possible to the file
format as possible (for good or for bad), and not worry about "rendering"
... xls files store the format and the value separately, and thats what POI
gives you.. the actual formatting is done by Excel the application, (and
that logic is not documented or public), and POI expects its clients to
figure that out.

Having said that, many such functions have a place in the contrib jar, and
if anyone were to supply an implementation for getFormattedCellValue, it too
could be put there. 




---------------------------------------------------------------------
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/

Reply via email to