#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

    POI and display of numeric values


    hi,
    i am trying to write a numeric value using POI and i get the strange results:
    <poi:cell type="numeric" numberformat="##,####0.00" value="1075483609"/>
    <cfset x=#NumberFormat('1075483609','999,999,999,999.99')#> <poi:cell type="string" value="#x#"/>

    if you run the above you get 1,075,483,648.00 1,075,483,609.00 respectively . notice that the last three digits are different, can someone explain this?

    thanks
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    What if you remove the quotes: <cfset x=#NumberFormat(1075483609,'999,999,999,999.99')#> ?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0
    Originally Posted by kiteless
    What if you remove the quotes: <cfset x=#NumberFormat(1075483609,'999,999,999,999.99')#> ?
    the numberformat() function is giving the correct value, the problem is with the other statement

    <poi:cell type="numeric" numberformat="##,####0.00" value="1075483609"/>
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    Ah, in that case I'm not sure. You may have to dig through the Apache POI docs since that's an external library. The only three things I can think of are: something is wrong with your format string, POI is doing something weird with the number because it is so large, or there's a bug in POI.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2008
    Posts
    131
    Rep Power
    7
    Actually that is not pure POI. It looks like Ben Nadel's custom tag wrapper. I am not very familiar with it but had a brief look. The problem seems to involve this line.

    Code:
    <!--- Set numeric value. --->
    <cfset VARIABLES.Cell.SetCellValue( 
                        JavaCast( "float",   THISTAG.GeneratedContent )
                     ) />
    It has something to do with casting the value as "float". If you cast it as a "double" instead of "float" you get the expected output "1,075,483,609.00".

    I have no idea what effect that has on the rest of tag. So I would suggest searching his site to see if a similar issue was raised already, and if so what is the best work-around.

IMN logo majestic logo threadwatch logo seochat tools logo