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

Gentlemen and Colleagues, there is absolutely n-o reason to use such utterly disrespectful language in reference to any other Monk ... who asked a perfectly valid question that I’m not sure really has been properly answered yet.   He has instead received brutal treatment deserving of an apology.

If someone appears to find that a Perl program gives one answer in one environment, but a different answer in another, and says that he can demonstrate this, then that’s a valid question deserving of a careful answer.   We do not practice castigation in this Monastery.

Don’t we? . . .

Replies are listed 'Best First'.
Re^2: Spreadsheet::Read module is rounding the decimals in XLSX file
by char_perl (Initiate) on Jun 24, 2015 at 11:39 UTC
    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 :)

      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
Re^2: Spreadsheet::Read module is rounding the decimals in XLSX file
by hda (Chaplain) on Jun 24, 2015 at 11:25 UTC
    Well said! One of the big assets of PerlMonks is the kindness of its members. Let's contribute to keep this good culture!
Re^2: Spreadsheet::Read module is rounding the decimals in XLSX file
by Anonymous Monk on Jun 24, 2015 at 11:48 UTC
    Looking at your posts you do this to others frequently. You're full of it. Nothing more than another charm offensive on your part.