Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Spreadsheet shows scientific notation occasionally with some cells,but it is wrong

Reply
Thread Tools

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

 
 
mike yue
Guest
Posts: n/a
 
      08-03-2010
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.
 
Reply With Quote
 
 
 
 
Peter J. Holzer
Guest
Posts: n/a
 
      08-04-2010
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

 
Reply With Quote
 
 
 
 
mike yue
Guest
Posts: n/a
 
      08-04-2010
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?
 
Reply With Quote
 
Jim Gibson
Guest
Posts: n/a
 
      08-04-2010
In article
<298fb657-9ce0-48bf-a7cb->,
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
 
Reply With Quote
 
mike yue
Guest
Posts: n/a
 
      08-04-2010
On Aug 4, 11:07*am, Jim Gibson <jimsgib...@gmail.com> wrote:
> In article
> <298fb657-9ce0-48bf-a7cb-be7132b6c...@i28g2000yqa.googlegroups.com>,
>
> mike yue <needpass...@gmail.com> 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.
 
Reply With Quote
 
mike yue
Guest
Posts: n/a
 
      08-04-2010
Also Thanks to Sherm and Peter!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scientific Notation Conversion N1GHTS C++ 1 02-20-2008 07:22 PM
How to represent the scientific notation? asdf C++ 2 10-21-2006 04:12 PM
reguarding scientific notation grinder C Programming 7 08-29-2006 09:26 PM
Scientific Notation Dustan Python 7 12-04-2005 01:56 PM
No scientific notation? Ville Ahonen C++ 2 10-19-2004 10:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57