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: 45626
Status: resolved
Worked: 2 hours (120 min)
Priority: 0/
Queue: Spreadsheet-ParseExcel

People
Owner: Nobody in particular
Requestors: jmegerman [...] transcontinentaldirect.com
Cc:
AdminCc:

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



Subject: Numeric Rounding Errors
Date: Fri, 1 May 2009 13:52:50 -0400
To: <bug-Spreadsheet-ParseExcel [...] rt.cpan.org>
From: "Megerman, Joshua" <jmegerman [...] transcontinentaldirect.com>

Message body is not shown because sender requested not to inline it.

Download parsetest.pl
text/x-perl 200b

Message body is not shown because sender requested not to inline it.

Download test.dump.postpatch
application/octet-stream 421.2k

Message body not shown because it is not plain text.

Download test.dump.prepatch
application/octet-stream 432.5k

Message body not shown because it is not plain text.

Download test.xls
application/vnd.ms-excel 24k

Message body not shown because it is not plain text.

Download (untitled) / with headers
text/plain 2.8k
I am using Spreadsheet::ParseExcel to extract data from an xls file, and running into rounding errors on an exact '5' value as trailing digit (e.g., 140.755 is rounding to 140.75 NOT 140.76). While I understand that there are limitations in the internal storage format of the values in perl, this should be relatively easy to spot during the parsing process. After rounding the contents of 'Val' using the format to get '_Value', you can do a string comparison and see if it should have rounded up - e.g.: if (($_->'_Value' . '5') eq ($_->'Val') { <force round up at the last decimal Show quoted text
place>
} This occurs on 2 machines as follows: RHEL3: Perl version : 5.008 OS name : linux Module versions: (not all are required) Spreadsheet::ParseExcel 0.49 Scalar::Util 1.09 Unicode::Map (not installed) Spreadsheet::WriteExcel (not installed) Parse::RecDescent (not installed) File::Temp 0.21 OLE::Storage_Lite 0.18 IO::Stringy 2.110 RHEL5: Perl version : 5.008008 OS name : linux Module versions: (not all are required) Spreadsheet::ParseExcel 0.49 Scalar::Util 1.19 Unicode::Map 0.112 Spreadsheet::WriteExcel 2.24 Parse::RecDescent (not installed) File::Temp 0.16 OLE::Storage_Lite 0.16 IO::Stringy 2.110 I'm attaching a patch that forces the rounding by appending a '1' to the raw data value and redoing the sprintf to illustrate my point, but there may be a more elegant solution (not to mention there may be other places that are affected). Also attached is an XLS file created in M$Excel 2007 (saved in 97-2003 format) illustrating the inconsistency in rounding off on a '5' in the lest significant digit, and a simple perl script that shows it. I also am attaching the output of the test script before and after applying the patch. Any and all feedback on both my problem and patch welcome. I'm sorry I don't have test cases, but I'm not really familiar with the perl testing process and so don't have a clue how to go about that. Instructions and pointers welcomed. Thanks, Josh Joshua Megerman Senior Unix Systems Administrator, Transcontinental Direct, USA jmegerman@transcontinentaldirect.com 267-960-3048
Download (untitled) / with headers
text/html 12.1k

Message body is not shown because it is too large.

Download (untitled) / with headers
text/plain 552b
On Fri May 01 13:53:30 2009, jmegerman@transcontinentaldirect.com wrote: Show quoted text
> I am using Spreadsheet::ParseExcel to extract data from an xls file, and > running into rounding errors on an exact '5' value as trailing digit > (e.g., 140.755 is rounding to 140.75 NOT 140.76).
Hi, I think this is a "half-way-point alternation" issue, see the following section of perlfaq4: http://faq.perl.org/perlfaq4.html#Does_Perl_have_a_rou However, if the behaviour is different from Excel's then perhaps it should be fixed. I'll look into it. Thanks, John. --
Download (untitled) / with headers
text/plain 552b
On Fri May 01 13:53:30 2009, jmegerman@transcontinentaldirect.com wrote: Show quoted text
> I am using Spreadsheet::ParseExcel to extract data from an xls file, and > running into rounding errors on an exact '5' value as trailing digit > (e.g., 140.755 is rounding to 140.75 NOT 140.76).
Hi, I think this is a "half-way-point alternation" issue, see the following section of perlfaq4: http://faq.perl.org/perlfaq4.html#Does_Perl_have_a_rou However, if the behaviour is different from Excel's then perhaps it should be fixed. I'll look into it. Thanks, John. --
Subject: RE: [rt.cpan.org #45626] Numeric Rounding Errors
Date: Fri, 1 May 2009 15:24:30 -0400
To: <bug-Spreadsheet-ParseExcel [...] rt.cpan.org>
From: "Megerman, Joshua" <jmegerman [...] transcontinentaldirect.com>
Download (untitled) / with headers
text/plain 1.8k
It's definitely related to it, but the issue in question came about when I used Spreadsheet::Read (which uses Spreadsheet::ParseExcel to read .xls files) to try and automate a process that thus far was manually converting certain columns of an Excel file's many worksheets into a single fixed-length field for Mainframe processing (which I would otherwise have to take over doing by hand - ugh!). One of the columns is formatted as currency, and when I ran it through my Perl script the output was a mismatch on 3 lines - Excel had rounded up, Perl had rounded down. Further investigation showed that all 3 of these fields had raw values of X.XX5 exactly, which led me to my conclusion. I know that Excel has had rounding issues in the past with calculated values, but in this case the data isn't from a formula, it's an 'exact' number in the cell. Thanks for looking into this. Josh Joshua Megerman Senior Unix Systems Administrator, Transcontinental Direct, USA jmegerman@transcontinentaldirect.com 267-960-3048 Show quoted text
-----Original Message----- From: John McNamara via RT [mailto:bug-Spreadsheet-ParseExcel@rt.cpan.org] Sent: Friday, May 01, 2009 3:18 PM To: Megerman, Joshua Subject: [rt.cpan.org #45626] Numeric Rounding Errors <URL: https://rt.cpan.org/Ticket/Display.html?id=45626 > On Fri May 01 13:53:30 2009, jmegerman@transcontinentaldirect.com wrote:
> I am using Spreadsheet::ParseExcel to extract data from an xls file, and > running into rounding errors on an exact '5' value as trailing digit > (e.g., 140.755 is rounding to 140.75 NOT 140.76).
Hi, I think this is a "half-way-point alternation" issue, see the following section of perlfaq4: http://faq.perl.org/perlfaq4.html#Does_Perl_have_a_rou However, if the behaviour is different from Excel's then perhaps it should be fixed. I'll look into it. Thanks, John. --
Download (untitled) / with headers
text/plain 167b
Hi, I've had a chance to look at this in more detail and ParseExcel isn't rounding in the same way as Excel. I'll fix it in an upcoming version. Thanks, John. --
Subject: RE: [rt.cpan.org #45626] Numeric Rounding Errors
Date: Tue, 5 May 2009 08:55:42 -0400
To: <bug-Spreadsheet-ParseExcel [...] rt.cpan.org>
From: "Megerman, Joshua" <jmegerman [...] transcontinentaldirect.com>
Download (untitled) / with headers
text/plain 624b
Thanks! Joshua Megerman Senior Unix Systems Administrator, Transcontinental Direct, USA jmegerman@transcontinentaldirect.com 267-960-3048 Show quoted text
-----Original Message----- From: John McNamara via RT [mailto:bug-Spreadsheet-ParseExcel@rt.cpan.org] Sent: Tuesday, May 05, 2009 6:48 AM To: Megerman, Joshua Subject: [rt.cpan.org #45626] Numeric Rounding Errors <URL: https://rt.cpan.org/Ticket/Display.html?id=45626 > Hi, I've had a chance to look at this in more detail and ParseExcel isn't rounding in the same way as Excel. I'll fix it in an upcoming version. Thanks, John. --
Download (untitled) / with headers
text/plain 224b
Hi, This issue has been fixed in version 0.51 of Spreadsheet::WriteExcel. http://cpansearch.perl.org/src/JMCNAMARA/Spreadsheet-ParseExcel-0.51/Changes Thank you for your help in identifying/fixing this issue. John. --
Subject: RE: [rt.cpan.org #45626] Numeric Rounding Errors
Date: Thu, 20 Aug 2009 09:17:55 -0400
To: <bug-Spreadsheet-ParseExcel [...] rt.cpan.org>
From: "Megerman, Joshua" <jmegerman [...] transcontinentaldirect.com>
Download (untitled) / with headers
text/plain 722b
You're welcome - thanks for the fix! Josh Joshua Megerman Senior Unix Systems Administrator, Transcontinental Direct, USA jmegerman@transcontinentaldirect.com 267-960-3048 Show quoted text
-----Original Message----- From: John McNamara via RT [mailto:bug-Spreadsheet-ParseExcel@rt.cpan.org] Sent: Thursday, August 20, 2009 5:27 AM To: Megerman, Joshua Subject: [rt.cpan.org #45626] Numeric Rounding Errors <URL: https://rt.cpan.org/Ticket/Display.html?id=45626 > Hi, This issue has been fixed in version 0.51 of Spreadsheet::WriteExcel. http://cpansearch.perl.org/src/JMCNAMARA/Spreadsheet-ParseExcel-0.51/Changes Thank you for your help in identifying/fixing this issue. John. --


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.