Skeeve has asked for the wisdom of the Perl Monks concerning the following question:

I just started using Excel::Writer::XLSX and it's nt too difficult, I think, but here is something I don't understand.

The below example code puts the text "4004885000007" into A1 of an excel sheet and sets the format to "@", the Text format.

Now what happens when I open the file:

  1. The text is not displayed as 4004885000007 but just as 4E+12.
  2. When I check the cell format it is correctly set to "Text"
  3. When I press Enter in the input bar(?) where the full text 4004885000007 is displayed, the 4E+12 in the cell is replaced with the full number
  4. Additionally a warning is displayed that I stored a number as text - Great! That's what I wanted in the first place...

Does anyone here has an idea how I could get the text to be displayed correctly?

use strict; use warnings; use Excel::Writer::XLSX; # Create a new workbook called simple.xls and add a worksheet my $workbook = Excel::Writer::XLSX->new( 'a_simple.xlsx' ); my $worksheet = $workbook->add_worksheet(); my $textformat = $workbook->add_format(); $textformat->set_num_format( 0x31 ); $worksheet->write( 0, 0, "4004885000007", $textformat ); $workbook->close();

s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Replies are listed 'Best First'.
Re: Excel::Writer::XLSX how to get the required format?
by hdb (Monsignor) on Jan 30, 2014 at 08:12 UTC

      Thanks! write_string was the correct hint.


      s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
      +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e