Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Excel::Writer::XLSX::add_table omits zeros

by david2008 (Scribe)
on Jun 12, 2013 at 13:38 UTC ( #1038469=perlquestion: print w/ replies, xml ) Need Help??
david2008 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I use Excel::Writer::XLSX::add_table to write tables.
the table cells have sometimes zeros in them.
They are omitted.
The reason is that in
Excel::Writer::XLSX::Worksheet::add_table
we have the code
4017: if ( $token ) { 4018: $self->write( $row, $col, $token, $col_for +mats[$j] ); 4019 }
Is this a defect?
Is this something in the xlsx specification?
Thanks,
David

Comment on Excel::Writer::XLSX::add_table omits zeros
Download Code
Re: Excel::Writer::XLSX::add_table omits zeros
by choroba (Canon) on Jun 12, 2013 at 13:45 UTC
    If $token is 0, the condition is false. You should rather test its definedness:
    if (defined $token) { $self->write( .... }
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Thanks. I will open a defect for the module maintainer

        It is not a defect. As choroba says, you yourself skip setting the cell to zero if the entry ($token) is zero.

        UPDATE: Apologies. I had not realized that you were quoting module code, rather than your own. Will read the post more carefully next time.

Re: Excel::Writer::XLSX::add_table omits zeros
by AnomalousMonk (Abbot) on Jun 12, 2013 at 18:50 UTC

    Note also that the string  '0' evaluates as false.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1038469]
Approved by runrig
Front-paged by runrig
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2015-07-03 21:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (56 votes), past polls