Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Avoiding Strange Win32::ODBC Return Values for Integers

by LanceDeeply (Chaplain)
on Oct 28, 2005 at 14:51 UTC ( #503670=note: print w/replies, xml ) Need Help??


in reply to Avoiding Strange Win32::ODBC Return Values for Integers (NUL)

your $format may not be set correctly. first try explicitly calling write_number() for that specific column. see the docs

-hth

Replies are listed 'Best First'.
Re^2: Avoiding Strange Win32::ODBC Return Values for Integers
by jonix (Friar) on Oct 28, 2005 at 15:34 UTC
    In the docs it tells me:

    "The "looks like" rule is defined by regular expressions:
    write_number() if $token is a number based on the following regex: $token =~ /^(+-?)(?=\d|\.\d)\d*(\.\d*)?(Ee(+-?\d+))?$/."

    So I changed my code from
    $worksheet->write($row, $col++, $_, $format) for @data;
    to
    for (@data) { if ($_ =~ m/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/){ print; $worksheet->write_number($row, $col++, $_, $format); }else{ $worksheet->write($row, $col++, $_, $format) } }
    It never printed, so it might be a glitch in the "looks like" rules?

    Cheers,
    jonix
      do you know which col# is supposed to be a number?
      i was thinking that you try something like this first:
      if ( $col == 42 ) { $worksheet->write_number($row, $col++, $_); } else { $worksheet->write($row, $col++, $_, $format); }
      and once you're sure 57 is coming back from your query into the sheet, then you can start playing around with $format and your regex
        I have the 57 now, using chop - see my update to the original post.

        > do you know which col# is supposed to be a number?
        No - the SQL queries that I will run with this script may vary. I want it to become quite generic :)

        As I have found the strange last character beeing guilty for spoiling automatic datatype detection by the module, elegantly getting rid of it will be my new goal.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://503670]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2021-05-14 22:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (150 votes). Check out past polls.

    Notices?