Bug#299870: libspreadsheet-parseexcel-perl: Choking on NULLs
Niko Tyni
ntyni at iki.fi
Thu Dec 29 13:51:25 UTC 2005
tags 299870 patch
forwarded 299870 http://rt.cpan.org/NoAuth/Bug.html?id=16786
thanks
> perl -MSpreadsheet::ParseExcel -le 'print unpack "H*", Spreadsheet::ParseExcel->new->Parse("products.xls")->{Worksheet}[0]{Cells}[0][0]->Value'
>
> 014d0061006e007400650061007500200065006e0020006300750069007200200033002f003400200062006f00750074006f006e006e00e9002000e00020006c0027006100760061006e0074002c002000610076006500630020006700610072006e006900740075007200650073002000610075007800200065006d0070006900e800630065006d0065006e007400730020006100760061006e00740020006500740020006100720072006900e800720065002c00200065007400200064006f00750062006c007500720065002000690073006f006c0061006e00740065002e00200049006d0070006f0072007400e9002e000a00c90074006f0066006600
Hi,
the nulls show up because Spreadsheet::ParseExcel doesn't handle the
string as Unicode, although it should. The attached patch fixes this. I
have reported this to the upstream author as CPAN bug 299870,
<http://rt.cpan.org/NoAuth/Bug.html?id=16786>.
Cheers,
--
Niko Tyni ntyni at iki.fi
-------------- next part --------------
--- libspreadsheet-parseexcel-perl-0.2603.orig/ParseExcel.pm
+++ libspreadsheet-parseexcel-perl-0.2603/ParseExcel.pm
@@ -620,10 +620,21 @@
my($oBook, $bOp, $bLen, $sWk) = @_;
my($iR, $iC, $iF, $iL, $sTxt);
($iR, $iC, $iF, $iL) = unpack("v4", $sWk);
- $sTxt = substr($sWk, 8, $iL);
+ my $bver = $oBook->{BIFFVersion};
+ my ($rich, $sCode);
+ if($bver == verBIFF8) {
+ my( $raBuff, @rest) = _convBIFF8String($oBook, substr($sWk, 6), 1);
+ $sTxt = $raBuff->[0];
+ $sCode = ($raBuff->[1])? 'ucs2': undef;
+ $rich = $raBuff->[2];
+ } else {
+ $sTxt = substr($sWk, 8, $iL);
+ $sCode = '_native_';
+ $rich = substr($sWk, (8+$iL)+1)
+ if (length($sWk) > (8+$iL));
+ }
- #Has STRUN
- if(length($sWk) > (8+$iL)) {
+ if($rich) {
_NewCell (
$oBook, $iR, $iC,
Kind => 'RString',
@@ -631,9 +642,9 @@
FormatNo=> $iF,
Format => $oBook->{Format}[$iF],
Numeric => 0,
- Code => '_native_', #undef,
+ Code => $sCode,
Book => $oBook,
- Rich => substr($sWk, (8+$iL)+1),
+ Rich => $rich,
);
}
else {
@@ -644,7 +657,7 @@
FormatNo=> $iF,
Format => $oBook->{Format}[$iF],
Numeric => 0,
- Code => '_native_',
+ Code => $sCode,
Book => $oBook,
);
}
More information about the pkg-perl-maintainers
mailing list