Unexpected Hex conversion with Text format
swarmhawk opened this issue · 1 comments
I looked through documentation and both open and closed issues and didn't see this discussed, so I'm not sure this behavior is expected or not.
I am attempting to convert tab delimited hex numbers to Excel file using text format and keep leading zeros. Values with "E" are being interpreted as scientific notation number instead of text.
The program is based on the idiomatic conversion example in the Excel::Writer::XLSX documentation:
Results in expected text results in top line, but scientific numbers in the bottom line:
The same thing happens when using Spreadsheet::WriteExcel as well. Is there another way I should be dealing with this conversion?
Excel::Writer::XLSX is just (more of less) copying perl's handling of strings that look like numbers:
$ perl -le 'print 0 + "2E25"'
2e+25
The write()
method is just some syntactic sugar. It tries to do the right thing but in the absence of type information it doesn't always get it right.
The best thing to do is to avoid using it in cases like this where it doesn't do what you want and instead use a more explicit method such as write_string()
or write_number()
.