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.
Owner: |
Nobody in particular
|
Requestors: |
jmegerman [...] transcontinentaldirect.com
|
Cc: |
|
AdminCc: |
|
|
Severity: |
(no value)
|
Broken in: |
(no value)
|
Fixed in: |
(no value)
|
parseexcel-utility-rounding.patch
parsetest.pl
test.dump.postpatch
test.dump.prepatch
test.xls
|
Fri May 01 13:53:30 2009
jmegerman [...] transcontinentaldirect.com - Ticket created
Message body is not shown because sender requested not to inline it.
Message body is not shown because sender requested not to inline it.
Message body not shown because it is not plain text.
Message body not shown because it is not plain text.
Message body not shown because it is not plain 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). 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 textplace>
}
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
Message body is not shown because it is too large.
Fri May 01 15:18:18 2009
jmcnamara [...] cpan.org - Correspondence added
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.
--
Fri May 01 15:18:19 2009
The RT System itself - Status changed from 'new' to 'open'
Fri May 01 15:18:20 2009
jmcnamara [...] cpan.org - Correspondence added
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.
--
Fri May 01 15:25:12 2009
jmegerman [...] transcontinentaldirect.com - Correspondence added
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.
--
Tue May 05 06:47:40 2009
jmcnamara [...] cpan.org - Correspondence added
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.
--
Tue May 05 08:56:46 2009
jmegerman [...] transcontinentaldirect.com - Correspondence added
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.
--
Thu Aug 20 05:27:00 2009
jmcnamara [...] cpan.org - Status changed from 'open' to 'resolved'
Thu Aug 20 09:18:14 2009
jmegerman [...] transcontinentaldirect.com - Correspondence added
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
Thu Aug 20 09:18:15 2009
The RT System itself - Status changed from 'resolved' to 'open'
Fri Aug 21 11:42:36 2009
jmcnamara [...] cpan.org - Status changed from 'open' to 'resolved'