Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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
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?

Replies are listed 'Best First'.
Re: Excel::Writer::XLSX::add_table omits zeros
by choroba (Bishop) 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 (Chancellor) on Jun 12, 2013 at 18:50 UTC

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1038469]
Approved by runrig
Front-paged by runrig
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2018-04-26 12:28 GMT
Find Nodes?
    Voting Booth?