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: 47072
Status: resolved
Priority: 0/
Queue: Spreadsheet-ParseExcel

People
Owner: Nobody in particular
Requestors: corey.zeller [...] vonage.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.49
Fixed in: 0.64



Subject: Bug in ExcelLocaltime (Patch)
Download (untitled) / with headers
text/plain 1.5k
Utility::ExcelLocaltime is not correctly handling times which are less than half of a millisecond before midnight. localtime.xls was created by Excel 2003 on Windows XP and contains the following: A1: 1/1/2009 0:00:00 B1: =A1-(0.0005/86400) Both have the same formatting "m/d/yyyy h:mm AM/PM" and both display in Excel as "1/1/2009 12:00 AM". I ran this program on the file: my $parser = Spreadsheet::ParseExcel->new(); my $wb = $parser->Parse("localtime.xls"); my $ws = $wb->Worksheet(0); print "A1: ", $ws->get_cell(0,0)->value(), "\n"; print "B1: ", $ws->get_cell(0,1)->value(), "\n"; This is the output: A1: 1/1/2009 12:00 AM B1: 12/31/2008 12:00 PM This appears to be happening because the millisecond rounding that occurs in ExcelLocaltime pushes the value of $iTime greater than 1, which it should never be since Excel stores time values only in the fractional part of the real number. The attached patch checks for this and corrects it. After applying the patch the output of the above program is: A1: 1/1/2009 12:00 AM B1: 1/1/2009 12:00 AM My system info: Perl version : 5.008008 OS name : linux Module versions: (not all are required) Spreadsheet::ParseExcel 0.49 Scalar::Util 1.18 Unicode::Map (not installed) Spreadsheet::WriteExcel 2.25 Parse::RecDescent 1.94 File::Temp 0.21 OLE::Storage_Lite 0.18 IO::Stringy 2.110
Subject: localtime.xls
Download localtime.xls
application/vnd.ms-excel 13.5k

Message body not shown because it is not plain text.

Subject: Utility.pm.diff
Download Utility.pm.diff
text/x-diff 1.3k
--- /usr/local/share/perl/5.8.8/Spreadsheet/ParseExcel/Utility.pm.old 2009-06-17 14:14:26.000000000 -0400 +++ /usr/local/share/perl/5.8.8/Spreadsheet/ParseExcel/Utility.pm 2009-06-17 15:02:28.000000000 -0400 @@ -1086,7 +1086,7 @@ sub ExcelLocaltime { my ( $dObj, $flg1904 ) = @_; my ( $iSec, $iMin, $iHour, $iDay, $iMon, $iYear, $iwDay, $iMSec ); - my ( $iDt, $iTime, $iYDays ); + my ( $iDt, $iTime, $iYDays, $iMD ); $iDt = int($dObj); $iTime = $dObj - $iDt; @@ -1111,8 +1111,7 @@ && ( ( $iYear % 100 ) || ( $iYear % 400 ) == 0 ) ) ? 366 : 365; } $iYear -= 1900; - for ( $iMon = 1 ; $iMon < 12 ; $iMon++ ) { - my $iMD; + for ( $iMon = 1 ; $iMon <= 12 ; $iMon++ ) { if ( $iMon == 1 || $iMon == 3 || $iMon == 5 @@ -1136,6 +1135,28 @@ #2. Calc Time $iDay = $iDt; $iTime += ( 0.0005 / 86400.0 ); + if ($iTime >= 1.0) + { + $iTime -= int($iTime); + $iwDay = ($iwDay == 6) ? 0 : $iwDay + 1; + if ($iDay == $iMD) + { + if ($iMon == 12) + { + $iMon = 1; + $iYear++; + } + else + { + $iMon++; + } + $iDay = 1; + } + else + { + $iDay++; + } + } $iTime *= 24.0; $iHour = int($iTime); $iTime -= $iHour;
Download (untitled) / with headers
text/plain 246b
On Wed Jun 17 15:34:59 2009, corey.zeller@vonage.com wrote: Show quoted text
> Utility::ExcelLocaltime is not correctly handling times which are less > than half of a millisecond before midnight.
Hi, Thanks for that. I'll fix it in the next release. John. --
Fixed in 0.64


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.