Spreadsheet shows scientific notation occasionally with some cells,but it is wrong

Discussion in 'Perl Misc' started by mike yue, Aug 4, 2010.

  1. mike yue

    mike yue Guest

    I am not sure if this is related to the perl script(uses WriteExcel
    module), or related to my MS office excel settings.

    e.g. Here are six cells showing in a spreadsheet:

    10b1e4 146914
    10b818 14db80
    8.054E+33 808c940

    The "8.054E+33" is actually from a string "8054e30" representing a
    memory address, which is definitely not 8.054E+33.
    But all other cells are show correct - that is weird.

    My perl script uses WriteExcel, and the cells are with format which
    only set_align('right').

    Anyone got ideas?

    Thank you guys for your attention.
     
    mike yue, Aug 4, 2010
    #1
    1. Advertising

  2. Re: Spreadsheet shows scientific notation occasionally with somecells, but it is wrong

    On 2010-08-03 23:47, mike yue <> wrote:
    > I am not sure if this is related to the perl script(uses WriteExcel
    > module), or related to my MS office excel settings.
    >
    > e.g. Here are six cells showing in a spreadsheet:
    >
    > 10b1e4 146914
    > 10b818 14db80
    > 8.054E+33 808c940
    >
    > The "8.054E+33" is actually from a string "8054e30" representing a
    > memory address, which is definitely not 8.054E+33.


    % perl -le 'print 8054e30'
    8.054e+33


    > But all other cells are show correct - that is weird.
    >
    > My perl script uses WriteExcel, and the cells are with format which
    > only set_align('right').


    Which method do you use to write the cell? "write" or "write_string"?

    If you use write, it needs to guess whether the thing you want to write
    is a string or a number (a perl scalar can be both), and since 8054e30
    looks like a number it guesses that it is one. Use write_string if you
    want to write a string. If you are already using write_string, it's
    probably a bug.

    hp
     
    Peter J. Holzer, Aug 4, 2010
    #2
    1. Advertising

  3. mike yue

    mike yue Guest

    Re: Spreadsheet shows scientific notation occasionally with somecells, but it is wrong

    I didn't use either write or write_string, I used write_col() instead.
    $worksheet->write_col( 14, 1, \@start_addrs, $RIGHT_ALIGN );
    So the data comes from an array.
    Do I need to set the format RIGHT_ALIGN to a particular string or
    something? how?
     
    mike yue, Aug 4, 2010
    #3
  4. mike yue

    Jim Gibson Guest

    Re: Spreadsheet shows scientific notation occasionally with some cells, but it is wrong

    In article
    <>,
    mike yue <> wrote:

    > I didn't use either write or write_string, I used write_col() instead.
    > $worksheet->write_col( 14, 1, \@start_addrs, $RIGHT_ALIGN );
    > So the data comes from an array.
    > Do I need to set the format RIGHT_ALIGN to a particular string or
    > something? how?


    $RIGHT_ALIGN should be a valid Format object reference as returned by
    the add_format() method called on a workbook object:

    my $RIGHT_ALIGN = $workbook->add_format();

    The format should not change the interpretation of the object type as
    determined by the write_col method.

    Try using write_string() to store the data instead of write_col(). You
    will have to store one cell at a time in a loop.

    --
    Jim Gibson
     
    Jim Gibson, Aug 4, 2010
    #4
  5. mike yue

    mike yue Guest

    Re: Spreadsheet shows scientific notation occasionally with somecells, but it is wrong

    On Aug 4, 11:07 am, Jim Gibson <> wrote:
    > In article
    > <>,
    >
    > mike yue <> wrote:
    > > I didn't use either write or write_string, I used write_col() instead.
    > >     $worksheet->write_col( 14, 1, \@start_addrs, $RIGHT_ALIGN );
    > > So the data comes from an array.
    > > Do I need to set the format RIGHT_ALIGN to a particular string or
    > > something? how?

    >
    > $RIGHT_ALIGN should be a valid Format object reference as returned by
    > the add_format() method called on a workbook object:
    >
    >   my $RIGHT_ALIGN = $workbook->add_format();
    >
    > The format should not change the interpretation of the object type as
    > determined by the write_col method.
    >
    > Try using write_string() to store the data instead of write_col(). You
    > will have to store one cell at a time in a loop.
    >
    > --
    > Jim Gibson


    I've done that but don't feel good with it - Still wonder if there is
    a better solution.
    Thanks Jim.
     
    mike yue, Aug 4, 2010
    #5
  6. mike yue

    mike yue Guest

    Re: Spreadsheet shows scientific notation occasionally with somecells, but it is wrong

    Also Thanks to Sherm and Peter!
     
    mike yue, Aug 4, 2010
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gce
    Replies:
    0
    Views:
    778
  2. Ville Ahonen

    No scientific notation?

    Ville Ahonen, Oct 19, 2004, in forum: C++
    Replies:
    2
    Views:
    460
    Mike Wahler
    Oct 19, 2004
  3. Dustan

    Scientific Notation

    Dustan, Dec 4, 2005, in forum: Python
    Replies:
    7
    Views:
    13,488
    Dustan
    Dec 4, 2005
  4. grinder

    reguarding scientific notation

    grinder, Aug 28, 2006, in forum: C Programming
    Replies:
    7
    Views:
    473
    Knemon
    Aug 29, 2006
  5. asdf
    Replies:
    2
    Views:
    569
    Rolf Magnus
    Oct 21, 2006
Loading...

Share This Page