You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by MPras <4m...@gmail.com> on 2008/01/05 05:41:14 UTC

Date cells in different formats treated as numeric

Hello,

I have an excel spreadsheet with dates in formats like 'M/D/yyyy' and
'Sunday, January 09, 2005'.  Dates in format 'M/D/yyyy' are interpreted
correctly as Date (HSSFDateUtil.isCellDateFormatted() returns true).  The
same method is unable to identify other date formats as Date and they end up
appearing as double.

Previous posts have alluded to using HSSFDateUtil.isADateFormat(int
formatIndex, java.lang.String formatString)) as a possible solution.  Is
this correct?  If yes, how does one obtain the value to the 'formatString'
of a cell?

Thank you.

-- 
View this message in context: http://www.nabble.com/Date-cells-in-different-formats-treated-as-numeric-tp14629970p14629970.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: Date cells in different formats treated as numeric

Posted by Nick Burch <ni...@torchbox.com>.
On Mon, 7 Jan 2008, MPras wrote:
> An earlier
> question/response(http://www.nabble.com/HSSFCell-Time-Code-String-Treated-as-Date-Numeric-to14224700.html#a14224700
> - Nick Burch Dec 10, 2007; 01:54pm ) refers to "grab the format string for
> the the cell".  How can I get the format string of a cell?  Since the
> HSSFWorkbook.getWorkbook() is a protected method, is there a different way
> to obtain this format string?

You shouldn't need to get at it - the updated date detection code ought to
do it all for you

Nick

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


Re: Date cells in different formats treated as numeric

Posted by MPras <4m...@gmail.com>.
Thanks for your response, Nick.

An earlier
question/response(http://www.nabble.com/HSSFCell-Time-Code-String-Treated-as-Date-Numeric-to14224700.html#a14224700 
- Nick Burch Dec 10, 2007; 01:54pm ) refers to "grab the format string for
the the cell".  How can I get the format string of a cell?  Since the
HSSFWorkbook.getWorkbook() is a protected method, is there a different way
to obtain this format string?

Thanks again.



Nick Burch wrote:
> 
> On Fri, 4 Jan 2008, MPras wrote:
>> I have an excel spreadsheet with dates in formats like 'M/D/yyyy' and
>> 'Sunday, January 09, 2005'.  Dates in format 'M/D/yyyy' are interpreted
>> correctly as Date (HSSFDateUtil.isCellDateFormatted() returns true).
>> The same method is unable to identify other date formats as Date and
>> they end up appearing as double.
> 
> Try with poi 3.0.2 beta 1, it has improved date detection
> 
> Nick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Date-cells-in-different-formats-treated-as-numeric-tp14629970p14668754.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: Date cells in different formats treated as numeric

Posted by Nick Burch <ni...@torchbox.com>.
On Fri, 4 Jan 2008, MPras wrote:
> I have an excel spreadsheet with dates in formats like 'M/D/yyyy' and
> 'Sunday, January 09, 2005'.  Dates in format 'M/D/yyyy' are interpreted
> correctly as Date (HSSFDateUtil.isCellDateFormatted() returns true).
> The same method is unable to identify other date formats as Date and
> they end up appearing as double.

Try with poi 3.0.2 beta 1, it has improved date detection

Nick

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