in reply to Re^2: Spreadsheet::WriteExcel, numbers v strings?
in thread Spreadsheet::WriteExcel, numbers v strings?


The problem is caused by the comma in your number strings. Remove that and you should get the result that you expect.

--
John.

  • Comment on Re^3: Spreadsheet::WriteExcel, numbers v strings?

Replies are listed 'Best First'.
Re^4: Spreadsheet::WriteExcel, numbers v strings?
by chrisjej (Initiate) on Mar 28, 2008 at 11:54 UTC
    I have a similar problem: if I do something like: $worksheet->write_string('A2', '0123'); I get the number in my Excel 2002 spreadsheet displayed as "0123" as desired - but with the annoying green triangle in Excel suggesting I have "Number displayed as string". Is there a way from the Perl WriteExcel side of making the green triangle disappear?

      If you want to avoid the "Number stored as text" warnings in Excel then you will have to write the data as numbers and format it to have a padded leading zero. Item 3 of the example below demonstrates this.
      #!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new('test.xls'); my $worksheet = $workbook->addworksheet(); # A padded number format my $format = $workbook->add_format(num_format => '0000'); # 1. Implicitly write a number, the leading zero is removed: 123 $worksheet->write('B2', '0123'); # 2. Write explicitly as a string: 0123 $worksheet->write_string('B3', '0123'); # 3. Write a zero padded number using a format: 0123 $worksheet->write('B4', '0123', $format); __END__

      --
      John.

Re^4: Spreadsheet::WriteExcel, numbers v strings?
by jamesgerard1964 (Novice) on Oct 09, 2014 at 23:15 UTC
    Hey Mr McNamara, I have a question if you wouldn't mind. When working with multiple excel spreadsheets that are exactly the same with just the difference being in the data, is it possible to just create another keeping all the headers, columns, rows, colors and any other field and just replacing the data. I have to take in about a weeks worth of reports and add the numbers. Instead of having to create headings and all the bells and whistles I was hoping I could just incorporate whatever is in the existing Spreadsheets. Thanks.
Re^4: Spreadsheet::WriteExcel, numbers v strings?
by Anonymous Monk on Oct 21, 2014 at 20:15 UTC
    Hey John, is there a way to write numbers into the xlsx sheet, but comma separated.