in reply to WriteExcel : The text 801495E40 turns into 8.01495E+45

Your code doesn't look much like the sample in John McNamarra's doc... where it says:
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.
And before you drill all the way down to "CELL FORMATTING" read this:
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 -- ...
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...

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.

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' );
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.

Alternately, you might want to prepend a single-quote to the $var ($var presumed here) you're trying to write to the new sheet.

Come, let us reason together: Spirit of the Monastery

Replies are listed 'Best First'.
Re^2: WriteExcel : The text 801495E40 turns into 8.01495E+45
by voram (Initiate) on Jan 17, 2014 at 16:24 UTC
    Hi ww, Reading the docs further made things quite clear for me.
    Although an alternate solution to prepend the $var with a single quote did the work for me, I didnt feel it wise to use that way as the excel couldn't be used for further automation (which if I plan to do in future would provide me tokens like 801495E40 as '801495E40 which is not advisable).
    Thanks for your help though ! :)