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

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

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