On Tuesday, December 4, 2012 10:17:00 AM UTC, Lvovich wrote:
Hi, John.I spent two tests:
1) Book1.xls - all the cells of the General
2) Book2.xls - all cells in the Text
Â
Â
Â
Hi,
I had a look at the files you sent and the data that you think are strings are actually numbers.
Here is a screenshot of what I see when I open the file.
Â
Â
Â

Â
Perhaps you are on a system that shows the decimal point as a comma.
Â
Also, if I use a data dumping tool on the raw Excel binary file this is what I see:
Â
Â
Â
[LABELSST] (Record = 0x00FD, Length = 0x000A, 10)
   FD 00 0A 00 02 00 02 00 3F 00 03 00 00 00      |........?..... |
   0  Record                  = 0x00FD        253
   2  Length                  = 0x000A        10Â
   4  Row                     = 0x0002        2 Â
   6  Column                  = 0x0002        2 Â
   8  XF                      = 0x003F        63Â
   10 Sting index             = 0x0003        3 Â
[NUMBER] (Record = 0x0203, Length = 0x000E, 14)
   03 02 0E 00 03 00 02 00 3F 00 C8 7B D5 CA 14 90 |........?..{....|
   C8 40                                          |.@             |
   0  Record                  = 0x0203        515
   2  Length                  = 0x000E        14Â
   4  Row                     = 0x0003        3 Â
   6  Column                  = 0x0002        2 Â
   8  XF index                = 0x003F        63Â
   10 Double                  = 12576.162440
Â
Â
Cell (2,2) is a string and cell 3,2 is a number.
Â
So, you are going to have to figure out some way of converting the decimal numbers back into a string in the format that you want. Here is a example to get you started. You will probably have to add extra logic to cover all cases you will encounter:
Â
Â
#!/usr/local/bin/perl
use strict;
use Spreadsheet::ParseExcel;
my $parser  = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse( 'Book2.xls' );
open( FILE, '>Book1.txt' );
if ( !defined $workbook ) {
   print FILE $parser->error() . "\n";
}
for my $worksheet ( $workbook->worksheets() ) {
   my ( $row_min, $row_max ) = $worksheet->row_range();
   my ( $col_min, $col_max ) = $worksheet->col_range();
   for my $row ( $row_min .. $row_max ) {
       for my $col ( $col_min .. $col_max ) {
           my $cell = $worksheet->get_cell( $row, $col );
           next unless $cell;
           print FILE "Row, Col   = ($row, $col)\n";
           if ( $col == 2 && $cell->type() eq 'Numeric' ) {
               my $value = $cell->value();
               # Reformat the number a string.
               $value = sprintf "%.5f", $value;
               # Change decimal point to comma.
               $value =~ s/\./,/;
               # Remove ,00000 item.
               $value =~ s/,00000//;
               print FILE "Value*     = ", $value, "\n";
           }
           else {
               print FILE "Value      = ", $cell->value(), "\n";
           }
           print FILE "Unformatted = ", $cell->unformatted(), "\n";
           print FILE "Type       = ", $cell->type(),       "\n";
           print FILE "\n";
       }
   }
}
close( FILE );
exit;
#####################
#####################
#####################
Â
Â
Â
Â
Â