Closed kevinpacheco closed 5 years ago
Since num_format
can take either a string or an integer, and since Perl doesn't distinguish between them in term of type '0'
is being interpreted as index 0 which gives format General
from the table above.
The way to get format string 0
is to use index 1, from the table above:
$fmt_int = $workbook->add_format(num_format => 1);
I know this is counter-intuitive but it remains for backward compatibility reasons. :-(
When I do "write_number" in conjunction with a format that includes "num_format => '0'", I should get a cell that is formatted as number with zero decimal places, but I don't. I instead get a cell that is formatted as general.
When I open the resulting spreadsheet in Excel, I see 2.1 in cell A1, when I should see just 2. When I right-click the cell and choose "Format Cells", I see that the format is general.
Here are the first three entries in the table of formats in the "set_num_format()" section of the documentation:
How do I get the format at index 1 instead of the format at index 0?