And before you drill all the way down to "CELL FORMATTING" read this:add_format(%properties) The "add_format()" method can be used to create new Format objects w +hich are used to apply formatting to a cell. You can either define the properties at creation time via a hash of property values or later v +ia method calls. $format1 = $workbook->add_format(%props); # Set properties at cr +eation $format2 = $workbook->add_format(); # Set properties later See the "CELL FORMATTING" section for more details about Format properties and how to set them.
So, while I understand that your problem is not leading zeros but rather, the conversion of text to a number in scientific notation, the docs may help there...One problem with the "write()" method is that occasionally data look +s like a number but you don't want it treated as a number. For example +, zip codes or ID numbers often start with a leading zero. If you writ +e this data as a number then the leading zero(s) will be stripped. You + can change this default behaviour by using the "keep_leading_zeros()" method. While this property is in place any integers with leading ze +ros will be treated as strings and the zeros will be preserved. See the "keep_leading_zeros()" section for a full discussion of this issue. More -- ...
But here's where your my $textFormat = $workbook->add_format( num_format => 'Text' ); seems awry: you don't want to set a number format; you want simple text, if I've understood your dilemma correctly.
So unless the conversion is occuring as you READ the source data, it would appear that further reading in the doc (ie, perldoc Spreadsheet::WriteExcel will help you solve this issue.See the note about "Cell notation". The $format parameter is optional In general it is sufficient to use the "write()" method. rite_string($row, $column, $string, $format) Write a string to the cell specified by $row and $column: $worksheet->write_string(0, 0, 'Your text here' ); $worksheet->write_string('A2', 'or here' );
Alternately, you might want to prepend a single-quote to the $var ($var presumed here) you're trying to write to the new sheet.
In reply to Re: WriteExcel : The text 801495E40 turns into 8.01495E+45
by ww
in thread WriteExcel : The text 801495E40 turns into 8.01495E+45
by voram
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |