in reply to ParseExcel:: wackiness

The data being returned is in Excel's UTF-16 Unicode format.

You will need to specify a Unicode formatter in the parse() method to handle the data. Something like this:

#!/usr/bin/perl use warnings; use strict; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::FmtJapan; my $filename = 'file.xls'; my $parser = Spreadsheet::ParseExcel->new(); my $formatter = Spreadsheet::ParseExcel::FmtJapan->new(); my $workbook = $parser->parse($filename, $formatter); if ( !defined $workbook ) { die "Parsing error: ", $parser->error(), ".\n"; } # Set your output encoding to something like this. binmode STDOUT, ':utf8'; for my $worksheet ( $workbook->worksheets() ) { print "Worksheet name: ", $worksheet->get_name(), "\n\n"; 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 " Row, Col = ($row, $col)\n"; print " Value = ", $cell->value(), "\n" +; print " Unformatted = ", $cell->unformatted(), "\n" +; print "\n"; } } } __END__

Ignore the fact that the formatter is called FmtJapan, it is also a general purpose Unicode handler.

--
John.

Replies are listed 'Best First'.
Re^2: ParseExcel:: wackiness
by petecm99 (Pilgrim) on Oct 05, 2010 at 15:47 UTC
    Thanks for that, John! I ran into the same thing a few months ago, and merely did the same as misterperl (edited the wackiness out manually).

    Your module has come in handy many times, I appreciate your work...
Re^2: ParseExcel:: wackiness
by misterperl (Friar) on Dec 18, 2012 at 14:34 UTC
    most helpful thanks..