Subject: | RSTRING doesn't know about BIFF8 (unicode) strings |
Hi,
this bug was originally reported as Debian bug #299870, http://bugs.debian.org/299870 .
The problem is that text in the reporter's spreadsheet comes out containing zero bytes.
I have verified this on Perl 5.8.7 on Debian GNU/Linux.
I looked into this, and the bug is in SpreadSheet::ParseExcel::_subRString(), which doesn't accept BIFF8 type unicode strings.
The attached patch fixes the problem.
Cheers,
--
Niko Tyni (on behalf of the Debian Perl Group)
ntyni@iki.fi
--- 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,
);
}