Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Spreadsheet-ParseExcel CPAN distribution.

Maintainer(s)' notes

If you are reporting a bug in Spreadsheet::ParseExcel here are some pointers

1) State the issues as clearly and as concisely as possible. A simple program or Excel test file (see below) will often explain the issue better than a lot of text.

2) Provide information on your system, version of perl and module versions. The following program will generate everything that is required. Put this information in your bug report.

    #!/usr/bin/perl -w

    print "\n    Perl version   : $]";
    print "\n    OS name        : $^O";
    print "\n    Module versions: (not all are required)\n";

    my @modules = qw(
                      Spreadsheet::ParseExcel
                      Scalar::Util
                      Unicode::Map
                      Spreadsheet::WriteExcel
                      Parse::RecDescent
                      File::Temp
                      OLE::Storage_Lite
                      IO::Stringy
                    );

    for my $module (@modules) {
        my $version;
        eval "require $module";

        if (not $@) {
            $version = $module->VERSION;
            $version = '(unknown)' if not defined $version;
        }
        else {
            $version = '(not installed)';
        }

        printf "%21s%-24s\t%s\n", "", $module, $version;
    }

    __END__

3) Upgrade to the latest version of Spreadsheet::ParseExcel (or at least test on a system with an upgraded version). The issue you are reporting may already have been fixed.

4) Create a small example program that demonstrates your problem. The program should be as small as possible. A few lines of codes are worth tens of lines of text when trying to describe a bug.

5) Supply an Excel file that demonstrates the problem. This is very important. If the file is big, or contains confidential information, try to reduce it down to the smallest Excel file that represents the issue. If you don't wish to post a file here then send it to me directly: jmcnamara@cpan.org

6) Say if the test file was created by Excel, OpenOffice, Gnumeric or something else. Say which version of that application you used.

7) If you are submitting a patch you should check with the maintainer whether the issue has already been patched or if a fix is in the works. Patches should be accompanied by test cases.

Asking a question

If you would like to ask a more general question there is the Spreadsheet::ParseExcel Google Group.

Report information
The Basics
Id: 7376
Status: resolved
Priority: 0/
Queue: Spreadsheet-ParseExcel

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.2603
Fixed in: (no value)



Subject: Warnings during parsing of excel sheet
On occasion I get the following warning when parsing excel sheets: Character in "C" format wrapped at /usr/local/lib/perl5/site_perl/5.8.0/Spreadsheet/ParseExcel/FmtDefault.pm line 68. The parsed data looks OK though. I guess it has something to do with Unicode characters in the excel sheet. Replacing the line 68 with return pack('U*', unpack('n*', $sTxt)); seems to remove the warnings. Regards, Slaven
From: ernst [...] cron-it.de
[SREZIC - Tue Aug 17 06:33:12 2004]: Show quoted text
> On occasion I get the following warning when parsing excel sheets: > (...) > Replacing the line 68 with > (...) > seems to remove the warnings.
Nice. I wonder what side-effects this has. I get a couple of other similar warnings: Character in 'c' format wrapped in pack at /usr/lib/perl5/vendor_perl/5.8.6/Spreadsheet/ParseExcel.pm line 1790. Character in 'c' format wrapped in pack at /usr/lib/perl5/vendor_perl/5.8.6/Spreadsheet/ParseExcel.pm line 1789.
From: afwest
[guest - Fri Jul 15 14:58:51 2005]: Show quoted text
> > [ Change unpack("C*",... to unpack("U*",...
> Nice. I wonder what side-effects this has.
It seems to me that Excel encodes extended characters in UTF-8, so this will correctly parse extended characters into a Unicode string. (I noticed this with several characters, suprisingly including the Euro symbol.) This could potentially mess up calling code which is expecting a string containing ASCII characters, but it seems fine in the context of the module itself. Show quoted text
> I get a couple of other similar warnings: > > Character in 'c' format wrapped in pack at > /usr/lib/perl5/vendor_perl/5.8.6/Spreadsheet/ParseExcel.pm line 1790. > Character in 'c' format wrapped in pack at > /usr/lib/perl5/vendor_perl/5.8.6/Spreadsheet/ParseExcel.pm line 1789.
These warnings are because the module is trying to mask off the last two bits of a character by unpacking it to a *signed* number and then masking 0xFC and then repacking it as a singed number. But, the & 0xFC operation seems to remove the sign. So, I made this change to those two lines: < substr($sWk, 3, 1) &= pack('c', unpack("c",substr($sWk, 3, 1)) & 0xFC); Show quoted text
> 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); Show quoted text
> substr($lWk, 0, 1) &= pack('C', unpack("C",substr($lWk, 0,
1)) & 0xFC); which does the same operation, but uses an unsigned integer.
From: afwest
[guest - Fri Jul 15 14:58:51 2005]: Show quoted text
> > [ Change unpack("C*",... to unpack("U*",...
> Nice. I wonder what side-effects this has.
It seems to me that Excel encodes extended characters in UTF-8, so this will correctly parse extended characters into a Unicode string. (I noticed this with several characters, suprisingly including the Euro symbol.) This could potentially mess up calling code which is expecting a string containing ASCII characters, but it seems fine in the context of the module itself. Show quoted text
> I get a couple of other similar warnings: > > Character in 'c' format wrapped in pack at > /usr/lib/perl5/vendor_perl/5.8.6/Spreadsheet/ParseExcel.pm line 1790. > Character in 'c' format wrapped in pack at > /usr/lib/perl5/vendor_perl/5.8.6/Spreadsheet/ParseExcel.pm line 1789.
These warnings are because the module is trying to mask off the last two bits of a character by unpacking it to a *signed* number and then masking 0xFC and then repacking it as a singed number. But, the & 0xFC operation seems to remove the sign. So, I made this change to those two lines: < substr($sWk, 3, 1) &= pack('c', unpack("c",substr($sWk, 3, 1)) & 0xFC); Show quoted text
> 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); Show quoted text
> substr($lWk, 0, 1) &= pack('C', unpack("C",substr($lWk, 0,
1)) & 0xFC); which does the same operation, but uses an unsigned integer.
Subject: Warnings during parsing of excel sheet - correct patch
From: Sergio Freire
So, is the correct patch something like changing these lines? Can anyone validate this and if its ok include it in the module for a future release? Line 68 of FmtDefault.pm: ------------------------ #return pack('C*', unpack('n*', $sTxt)); return pack('U*', unpack('n*', $sTxt)); Lines 1789,1790 of ParseExcel.pm: ----------------------------------- #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); # changed accordingly with http://rt.cpan.org/Public/Bug/Display.html?id=7376 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); Regards, Sergio Freire On Fri Aug 12 11:02:31 2005, guest wrote: Show quoted text
> [guest - Fri Jul 15 14:58:51 2005]: >
> > > [ Change unpack("C*",... to unpack("U*",...
> > Nice. I wonder what side-effects this has.
> > It seems to me that Excel encodes extended characters in UTF-8, so this > will correctly parse extended characters into a Unicode string. (I > noticed this with several characters, suprisingly including the Euro > symbol.) This could potentially mess up calling code which is > expecting a string containing ASCII characters, but it seems fine in > the context of the module itself. >
> > I get a couple of other similar warnings: > > > > Character in 'c' format wrapped in pack at > > /usr/lib/perl5/vendor_perl/5.8.6/Spreadsheet/ParseExcel.pm line 1790. > > Character in 'c' format wrapped in pack at > > /usr/lib/perl5/vendor_perl/5.8.6/Spreadsheet/ParseExcel.pm line 1789.
> > These warnings are because the module is trying to mask off the last > two bits of a character by unpacking it to a *signed* number and then > masking 0xFC and then repacking it as a singed number. But, the & 0xFC > operation seems to remove the sign. So, I made this change to those > two lines: > < substr($sWk, 3, 1) &= pack('c', unpack("c",substr($sWk, 3, > 1)) & 0xFC);
> > 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);
> > substr($lWk, 0, 1) &= pack('C', unpack("C",substr($lWk, 0,
> 1)) & 0xFC); > > > which does the same operation, but uses an unsigned integer. >
Subject: Warnings during parsing of excel sheet (substr outside of string)
From: mark [...] summersault.com
I got a different warning: substr outside of string at /usr/local/lib/perl5/site_perl/5.8.0/Spreadsheet/ParseExcel.pm line 1558. It means: "You tried to reference a substr that pointed outside of a string. That is, the absolute value of the offset was larger than the length of the string". A check on the string length before the substr is attempted would resolve that. That was with 0.2602, but the Changes file doesn't indicate this changed in the most recent release. Mark
From: mark [...] summersault.com
On Thu Mar 02 10:43:17 2006, guest wrote: Show quoted text
> I got a different warning: > > substr outside of string at > /usr/local/lib/perl5/site_perl/5.8.0/Spreadsheet/ParseExcel.pm line 1558. > > It means: "You tried to reference a substr that pointed outside of a > string. That is, the absolute value of the offset was larger than the > length of the string".
BTW, I got this error when trying parse a file that my system identified as a "Microsoft Excel Worksheet". When the same data was provided in a format identified as a "Microsoft Office Document", it worked. I didn't create these files, so I don't know exactly how they were created.
From: SZABGAB [...] cpan.org
On Tue Aug 17 06:33:12 2004, SREZIC wrote: Show quoted text
> On occasion I get the following warning when parsing excel sheets: > > Character in "C" format wrapped at > /usr/local/lib/perl5/site_perl/5.8.0/Spreadsheet/ParseExcel/FmtDefault.pm > line 68. > > return pack('U*', unpack('n*', $sTxt));
this fix has been applied to version 0.27_01
From: bitcard [...] adpm.de
Hi, On Mon Sep 11 07:42:25 2006, SZABGAB wrote: Show quoted text
> On Tue Aug 17 06:33:12 2004, SREZIC wrote:
> > On occasion I get the following warning when parsing excel sheets: > > > > Character in "C" format wrapped at
> > /usr/local/lib/perl5/site_perl/5.8.0/Spreadsheet/ParseExcel/FmtDefault.pm
> > line 68. > > > > return pack('U*', unpack('n*', $sTxt));
> > this fix has been applied to version 0.27_01
This change might increase the Perl version required for Spreadsheet::ParseExcel. I don't know if the 'U' option for pack() was there before Perl 5.6 (or even later) Maybe wrapping it in an alternative à la return pack(($] >= 5.006) ? 'U*' : 'C*'), unpack('n*', $sTxt)) might do the trick. Alternatively make Spreadsheet::ParseExcel require Perl 5.7 (with all the unicode stuff in place). I prefer the latter. Regards Peter
On Tue Aug 17 06:33:12 2004, SREZIC wrote: Show quoted text
> > return pack('U*', unpack('n*', $sTxt));
This seems to have been done long ago. Let's close this ticket.