Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Spreadsheet::Read module is rounding the decimals in XLSX file

by char_perl (Initiate)
on Jun 24, 2015 at 11:39 UTC ( [id://1131788]=note: print w/replies, xml ) Need Help??


in reply to Re: Spreadsheet::Read module is rounding the decimals in XLSX file
in thread Spreadsheet::Read module is rounding the decimals in XLSX file

Thank you for you're concern. Let me do more research on this and post a reply if i get a solution.

Using sprintf or %.4f will not work here, as the value from ReadData (which is part of Spreadsheet::Read) subroutine is it self coming as rounded, so even i used .4f on .99 it would be the same. As of now, as a work around I have given a vb tool to convert the xlsx files to xls, since this issue is not coming in xls files. May be I should continue by comparing the parsers of XLS and XLSX and see the difference.

Thanks to kcott, Tux, afoken and sundialsvc4 for your help :)

  • Comment on Re^2: Spreadsheet::Read module is rounding the decimals in XLSX file

Replies are listed 'Best First'.
Re^3: Spreadsheet::Read module is rounding the decimals in XLSX file
by Tux (Canon) on Jun 24, 2015 at 13:34 UTC

    I obviously was not clear enough.

    Spreadsheet::Read is no more and no less than a wrapper over a bunch of spreadsheet parsers to feature a generic API to all forms of spreadsheets.

    ReadData does not alter the data being returned by the underlying parser effectively in use. If it does, it might well be a bug.

    The underlying parser in the case of the OP's problem is likely Spreadsheet::XLSX, which is a problem to start with. That module is (very) buggy and unmaintained. It parses the XML with regular expressions and is loaded with small but annoying mistakes. My advice would be to uninstall that module immediately and replace it with Spreadsheet::ParseXLSX. There is a major chance your problems will vanish.

    Even with the use Spreadsheet::XLSX; statement in the code, which is utterly useless here, it does not guarantee that that module is used anywhere. If Spreadsheet::Read finds Spreadsheet::ParseXLSX installed, it will use that instead.

    So let us assume that with Spreadsheet::ParseXLSX your value will always return 0.98880000000000001 (or whatever floating point value is actually stored in that cell). It is still not Spreadsheet::Read's problem in that it is different on different systems. Find out what parser is used and trace back if the difference still exists when you parse the spreadsheet with that module (peel the layers): it might be that even lower levels are to blame like XML::Twig.

    I personally think that sundialsvc4 overreacts, though basically right, I don't see freshman-bashing here. Just valid tips and tricks that might need some more friendlyness in their wording, but are certainly not unfriendly IMHO.

    (There are reasons for people to not use Spreadsheet::ParseXLSX, support for Spreadsheet::XLSX::Reader::LibXML is work in prgress)


    Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1131788]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-23 15:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found