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

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.