[text/plain 958b]
When ParseExcel parses an XLS file with cells having certain
characteristics, it gives the following warnings:
Character in "c" format wrapped at Spreadsheet/ParseExcel.pm line 1789.
Character in "c" format wrapped at Spreadsheet/ParseExcel.pm line 1790.
I'm sorry, I don't know what conditions produce the warnings, but
those conditions are present in the first cell in the attached
spreadsheet, but not the other cell.
The warnings result from trying to unpack a 1-byte negative number,
while unpack() thinks it is looking at a 4-byte number. To fix, we
convert 1-byte negatives to 4-byte negatives by ORing with 0xFFFFFF00.
The exact source code patch is attached.
Distribution: Spreadsheet-ParseExcel-0.2603.tar.gz
Perl version: v5.8.0 built for aix-thread-multi
uname -a: AIX excelsioribm 2 5 00C0E82E4C00
Exact warning messages: see above
Code to reproduce: attached, show-warnings.pl with gives-warnings.xls
Patch to fix: attached, patch.txt
[text/plain 177b]
#!/usr/bin/perl -w
use File::Basename;
use lib $ENV{HOME} . "/.perl";
use Spreadsheet::ParseExcel;
my $oBook = Spreadsheet::ParseExcel::Workbook->Parse('gives-warnings.xls');
[application/vnd.ms-excel 14.5k]
Message body not shown because it is too large or is not plain text.
[text/plain 565b]
Spreadsheet/ParseExcel.pm lines 1789-1790:
substr($sWk, 3, 1) &= pack('c', unpack("c",substr($sWk, 3, 1)) & 0xFC);
substr($lWk, 0, 1) &= pack('c', unpack("c",substr($lWk, 0, 1)) & 0xFC);
replace with:
my $u = unpack("c",substr($sWk, 3, 1)) & 0xFC;
$u |= 0xFFFFFF00 if ($u & 0x80); # raise neg bits for neg 1-byte value
substr($sWk, 3, 1) &= pack('c', $u);
$u = unpack("c",substr($lWk, 0, 1)) & 0xFC;
$u |= 0xFFFFFF00 if ($u & 0x80); # raise neg bits for neg 1-byte value
substr($lWk, 0, 1) &= pack('c', $u);