You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Davinder Kohli <kd...@yahoo.com> on 2004/04/11 02:40:39 UTC

How to distinguish between different dates formats and decimals

Hi,
I am trying to get the actual format of the cell
containing different date formats and decimal values.
I am also trying to determine how many decimal places
are there in a decimal field.

Since the celltype returned for all of them is
NUMERIC, I get the cell style and then check the
dataformat as shown below. 

int cellType = theCell.getCellType();
HSSFCellStyle cellStyle = theCell.getCellStyle();
short dataFormatIndex = cellStyle.getDataFormat(); 

For all the 17 date formats supported by excel the
dataformatIndex was one the following indexes:
14,15,16,17,18,19,20,21,22,164,165,168,169,170,171,172,173,174,175,177,176,178,179,180,181,182.

I got the same indexes back for some of the decimal
values. The dataFormatIndex is unique when the dates
and decimals are in the same sheet but when they are
in separate sheets, the dataFormatIndex is same for,
say, date in the format 3/12/2001 and a decimal field
having 3 decimal places.

Please let me know if you need me to be more specific.
BTW I have tried the HSSFDateUtil methods, they return
me true for fields containing decimal values.

Any help would be appreciated!



__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html

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


Re: How to distinguish between different dates formats and decimals

Posted by Davinder Kohli <kd...@yahoo.com>.
Mr Oliver, 
I read your website more carefully, apologise for
sending you email privately. I can assure you and the
rest on this mailing list is not going to hear from me
on this topic again.

From:
http://jakarta.apache.org/poi/who.html
===================================================
We ask that you please do not send us emails privately
asking for support. We are non-paid volunteers who
help out with the project and we do not necessarily
have the time or energy to help people on an
individual basis. Instead, we have set up mailing
lists which often contain hundreds of individuals who
will help answer detailed requests for help. The
benefit of using mailing lists over private
communication is that it is a shared resource where
others can also learn from common mistakes and as a
community we all grow together. 



__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html

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


Re: How to distinguish between different dates formats and decimals

Posted by Davinder Kohli <kd...@yahoo.com>.
For the benefit of all other users...here is what I
had asked in my email to Mr.Oliver and Mr. Laubach to
get their blessings on the solution below. The email
below had a reference to my earlier email also.
========================================
Hello,
 Please correct me if I am wrong...here is how I am
planning to figure out the underlying cell type for
different dates and decimals (figuring out how many
decimal places it has).

Since there is no way to get Workbook from
HSSFWorkbook, for now I am going to insert a accessor
method to get it.

Once I get the dataFormatIndex.....
int cellType = theCell.getCellType();
HSSFCellStyle cellStyle = theCell.getCellStyle();
short dataFormatIndex = cellStyle.getDataFormat(); 

I will get the list of FormatRecord from Workbook
(workbook.formats) and search for those
dataFormatIndex which are not in the HSSFDataFormat.

I have experimented with this, this seems to work!
Please let me know if I am correct in my approach.
Thanks for your help.

__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html

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


Re: How to distinguish between different dates formats and decimals

Posted by Rainer Klute <kl...@rainer-klute.de>.
Am Mon, 2004-04-12 um 17.22 schrieb Andrew C. Oliver:
> Obviously replying to him will encourage this kind of behavior in the
> future.

Andy,

if I'd get furious everytime I receive an e-mail that I consider
superflous, I'd died of a heart attack long ago.

Davinder's behaviour gave no reason at all for any criticism. Please do
not discourage him!

Best regards
Rainer Klute

                           Rainer Klute IT-Consulting GmbH
  Dipl.-Inform.
  Rainer Klute             E-Mail:  klute@rainer-klute.de
  Körner Grund 24          Telefon: +49 172 2324824
D-44143 Dortmund           Telefax: +49 231 5349423



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


Re: How to distinguish between different dates formats and decimals

Posted by "Andrew C. Oliver" <ac...@apache.org>.
To the other committers:

Obviously replying to him will encourage this kind of behavior in the
future.  

-Andy
-- 
Andrew C. Oliver
http://www.superlinksoftware.com/poi.jsp
Custom enhancements and Commercial Implementation for Jakarta POI

http://jakarta.apache.org/poi
For Java and Excel, Got POI?

The views expressed in this email are those of the author and are almost
definitely not shared by the Apache Software Foundation, its board or its
general membership.  In fact they probably most definitively disagree with
everything espoused in the above email.

> From: Davinder Kohli <kd...@yahoo.com>
> Reply-To: "POI Users List" <po...@jakarta.apache.org>
> Date: Sun, 11 Apr 2004 15:10:01 -0700 (PDT)
> To: POI Users List <po...@jakarta.apache.org>
> Subject: Re: How to distinguish between different dates formats and decimals
> 
> Mr. Oliver,
> I did not realize I had sent this message twice and
> secondly I wasn't sure if you are part of this user
> list. Apologies to everyone who got this email twice.
> 
> Now I think you are acting too smart, if you can't
> answer this question simply don't reply. Please behave
> like a professional!
> 
> --- "Andrew C. Oliver" <ac...@apache.org> wrote:
>> I won't be answering this question because you sent
>> everyone a cc of it as
>> well and then forwarded it to me a second time.  I
>> don't need multiple
>> duplicate copies of a question sent to the list.  If
>> you want priority
>> support you have to pay for it.  No amount of
>> discourtesy will acquire it.
>> Don't play dumb either, I simply cannot believe that
>> it wouldn't occur to
>> you that we didn't all want a duplicate of this
>> message.
>> -- 
>> Andrew C. Oliver
>> http://www.superlinksoftware.com/poi.jsp
>> Custom enhancements and Commercial Implementation
>> for Jakarta POI
>> 
>> http://jakarta.apache.org/poi
>> For Java and Excel, Got POI?
>> 
>> The views expressed in this email are those of the
>> author and are almost
>> definitely not shared by the Apache Software
>> Foundation, its board or its
>> general membership.  In fact they probably most
>> definitively disagree with
>> everything espoused in the above email.
>> 
>>> From: Davinder Kohli <kd...@yahoo.com>
>>> Reply-To: "POI Users List"
>> <po...@jakarta.apache.org>
>>> Date: Sat, 10 Apr 2004 17:40:39 -0700 (PDT)
>>> To: POI Users List <po...@jakarta.apache.org>
>>> Subject: How to distinguish between different
>> dates formats and decimals
>>> 
>>> Hi,
>>> I am trying to get the actual format of the cell
>>> containing different date formats and decimal
>> values.
>>> I am also trying to determine how many decimal
>> places
>>> are there in a decimal field.
>>> 
>>> Since the celltype returned for all of them is
>>> NUMERIC, I get the cell style and then check the
>>> dataformat as shown below.
>>> 
>>> int cellType = theCell.getCellType();
>>> HSSFCellStyle cellStyle = theCell.getCellStyle();
>>> short dataFormatIndex = cellStyle.getDataFormat();
>>> 
>>> For all the 17 date formats supported by excel the
>>> dataformatIndex was one the following indexes:
>>> 
>> 
> 14,15,16,17,18,19,20,21,22,164,165,168,169,170,171,172,173,174,175,177,176,178
>>> ,179,180,181,182.
>>> 
>>> I got the same indexes back for some of the
>> decimal
>>> values. The dataFormatIndex is unique when the
>> dates
>>> and decimals are in the same sheet but when they
>> are
>>> in separate sheets, the dataFormatIndex is same
>> for,
>>> say, date in the format 3/12/2001 and a decimal
>> field
>>> having 3 decimal places.
>>> 
>>> Please let me know if you need me to be more
>> specific.
>>> BTW I have tried the HSSFDateUtil methods, they
>> return
>>> me true for fields containing decimal values.
>>> 
>>> Any help would be appreciated!
>>> 
>>> 
>>> 
>>> __________________________________
>>> Do you Yahoo!?
>>> Yahoo! Tax Center - File online by April 15th
>>> http://taxes.yahoo.com/filing.html
>>> 
>>> 
>> 
> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:
>> poi-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail:
>> poi-user-help@jakarta.apache.org
>>> 
>> 
>> 
>> 
> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> poi-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail:
>> poi-user-help@jakarta.apache.org
>> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online by April 15th
> http://taxes.yahoo.com/filing.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org
> 


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


Re: How to distinguish between different dates formats and decimals

Posted by Davinder Kohli <kd...@yahoo.com>.
Mr. Oliver,
I did not realize I had sent this message twice and
secondly I wasn't sure if you are part of this user
list. Apologies to everyone who got this email twice.

Now I think you are acting too smart, if you can't
answer this question simply don't reply. Please behave
like a professional!

--- "Andrew C. Oliver" <ac...@apache.org> wrote:
> I won't be answering this question because you sent
> everyone a cc of it as
> well and then forwarded it to me a second time.  I
> don't need multiple
> duplicate copies of a question sent to the list.  If
> you want priority
> support you have to pay for it.  No amount of
> discourtesy will acquire it.
> Don't play dumb either, I simply cannot believe that
> it wouldn't occur to
> you that we didn't all want a duplicate of this
> message.
> -- 
> Andrew C. Oliver
> http://www.superlinksoftware.com/poi.jsp
> Custom enhancements and Commercial Implementation
> for Jakarta POI
> 
> http://jakarta.apache.org/poi
> For Java and Excel, Got POI?
> 
> The views expressed in this email are those of the
> author and are almost
> definitely not shared by the Apache Software
> Foundation, its board or its
> general membership.  In fact they probably most
> definitively disagree with
> everything espoused in the above email.
> 
> > From: Davinder Kohli <kd...@yahoo.com>
> > Reply-To: "POI Users List"
> <po...@jakarta.apache.org>
> > Date: Sat, 10 Apr 2004 17:40:39 -0700 (PDT)
> > To: POI Users List <po...@jakarta.apache.org>
> > Subject: How to distinguish between different
> dates formats and decimals
> > 
> > Hi,
> > I am trying to get the actual format of the cell
> > containing different date formats and decimal
> values.
> > I am also trying to determine how many decimal
> places
> > are there in a decimal field.
> > 
> > Since the celltype returned for all of them is
> > NUMERIC, I get the cell style and then check the
> > dataformat as shown below.
> > 
> > int cellType = theCell.getCellType();
> > HSSFCellStyle cellStyle = theCell.getCellStyle();
> > short dataFormatIndex = cellStyle.getDataFormat();
> > 
> > For all the 17 date formats supported by excel the
> > dataformatIndex was one the following indexes:
> >
>
14,15,16,17,18,19,20,21,22,164,165,168,169,170,171,172,173,174,175,177,176,178
> > ,179,180,181,182.
> > 
> > I got the same indexes back for some of the
> decimal
> > values. The dataFormatIndex is unique when the
> dates
> > and decimals are in the same sheet but when they
> are
> > in separate sheets, the dataFormatIndex is same
> for,
> > say, date in the format 3/12/2001 and a decimal
> field
> > having 3 decimal places.
> > 
> > Please let me know if you need me to be more
> specific.
> > BTW I have tried the HSSFDateUtil methods, they
> return
> > me true for fields containing decimal values.
> > 
> > Any help would be appreciated!
> > 
> > 
> > 
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Tax Center - File online by April 15th
> > http://taxes.yahoo.com/filing.html
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> poi-user-help@jakarta.apache.org
> > 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> poi-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html

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


Re: How to distinguish between different dates formats and decimals

Posted by "Andrew C. Oliver" <ac...@apache.org>.
I won't be answering this question because you sent everyone a cc of it as
well and then forwarded it to me a second time.  I don't need multiple
duplicate copies of a question sent to the list.  If you want priority
support you have to pay for it.  No amount of discourtesy will acquire it.
Don't play dumb either, I simply cannot believe that it wouldn't occur to
you that we didn't all want a duplicate of this message.
-- 
Andrew C. Oliver
http://www.superlinksoftware.com/poi.jsp
Custom enhancements and Commercial Implementation for Jakarta POI

http://jakarta.apache.org/poi
For Java and Excel, Got POI?

The views expressed in this email are those of the author and are almost
definitely not shared by the Apache Software Foundation, its board or its
general membership.  In fact they probably most definitively disagree with
everything espoused in the above email.

> From: Davinder Kohli <kd...@yahoo.com>
> Reply-To: "POI Users List" <po...@jakarta.apache.org>
> Date: Sat, 10 Apr 2004 17:40:39 -0700 (PDT)
> To: POI Users List <po...@jakarta.apache.org>
> Subject: How to distinguish between different dates formats and decimals
> 
> Hi,
> I am trying to get the actual format of the cell
> containing different date formats and decimal values.
> I am also trying to determine how many decimal places
> are there in a decimal field.
> 
> Since the celltype returned for all of them is
> NUMERIC, I get the cell style and then check the
> dataformat as shown below.
> 
> int cellType = theCell.getCellType();
> HSSFCellStyle cellStyle = theCell.getCellStyle();
> short dataFormatIndex = cellStyle.getDataFormat();
> 
> For all the 17 date formats supported by excel the
> dataformatIndex was one the following indexes:
> 14,15,16,17,18,19,20,21,22,164,165,168,169,170,171,172,173,174,175,177,176,178
> ,179,180,181,182.
> 
> I got the same indexes back for some of the decimal
> values. The dataFormatIndex is unique when the dates
> and decimals are in the same sheet but when they are
> in separate sheets, the dataFormatIndex is same for,
> say, date in the format 3/12/2001 and a decimal field
> having 3 decimal places.
> 
> Please let me know if you need me to be more specific.
> BTW I have tried the HSSFDateUtil methods, they return
> me true for fields containing decimal values.
> 
> Any help would be appreciated!
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online by April 15th
> http://taxes.yahoo.com/filing.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org
> 


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