Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Excel-Writer-XLSX CPAN distribution.

Report information
The Basics
Id: 84243
Status: resolved
Priority: 0/
Queue: Excel-Writer-XLSX

People
Owner: Nobody in particular
Requestors: Robert.Ferrell [...] bnymellon.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Excel-Writer-XLSX not formatting text that looks like numbers
Date: Wed, 27 Mar 2013 16:18:58 +0000
To: "bug-Excel-Writer-XLSX [...] rt.cpan.org" <bug-Excel-Writer-XLSX [...] rt.cpan.org>
From: "Ferrell, Robert J" <Robert.Ferrell [...] bnymellon.com>
Hello, I have been experimenting with the perl module Excel-Writer-XLSX and I came across an issue. I need to write Cusips, which are 9 digit alphanumeric strings, into cells. Sometimes a Cusip is all numeric with a leading zero and the leading zero gets dropped when I write it in a cell. Sometimes a Cusip will be all numeric, except for an "E" in the middle, which will look like an exponent. In order to have these Cusips display correctly in Excel, I need to format the cell as text first, then write the value. However, I follow that procedure using the module, but it still displays them as numbers. I am using perl (v5.16.2) under Windows 7. The following code will demonstrate the issue: use Excel::Writer::XLSX; my $filename = "test.xlsx"; my $workbook = Excel::Writer::XLSX->new( $filename ); my $worksheet = $workbook->add_worksheet( 'Results' ); my $format_string = $workbook->add_format( num_format => '@'); $worksheet->set_column( 0, 0, undef, $format_string); my @cusips = qw/ 123000E14 ABCDEFGHI 012345678 123456789 /; my $row = 0; foreach (@cusips) { $worksheet->write($row++, 0, $_, $format_string); } exit(0); The expected output is: 123000E14 ABCDEFGHI 012345678 123456789 However I get this: 1.23E+19 ABCDEFGHI 12345678 123456789 Thank you. The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses. Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities.
On Wed Mar 27 12:19:24 2013, Robert.Ferrell@bnymellon.com wrote: Show quoted text
> Sometimes a Cusip will be all numeric, except for an > "E" in the middle, which will look like an exponent. In order to > have these Cusips display correctly in Excel, I need to format the > cell as text first, then write the value. However, I follow that > procedure using the module, but it still displays them as numbers.
Show quoted text
> my @cusips = qw/ 123000E14 ABCDEFGHI 012345678 123456789 /;
Show quoted text
> However I get this: > 1.23E+19 > ABCDEFGHI > 12345678 > 123456789
Hi Robert, This is the documented behaviour of the module. It is also the standard behaviour of Excel. If you open a new worksheet in Excel and type in the tokens in the qw() you will see the same results in Excel as in Excel::Writer::XLSX. The write() function is merely a wrapper for other functions. If you need to write strings then the write_string() method is a better option, especially in conjunction with the '@' text format. See the write() section of the docs for more details. P.S., the bug tracker for Excel::Writer::XLSX is on Github if you have any further issues: https://github.com/jmcnamara/excel-writer-xlsx/issues?state=open Regards, John