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

As you could have read in the documentation, addressing a cell using the name, like in $ss->[1]{A1}, will give you the formatted value. If you want the original unformatted value, you need to address the cell using $ss->[1]{cell}[1]]1].

Use that value and format it yourself, like with the already suggested sprintf.


Enjoy, Have FUN! H.Merijn
  • Comment on Re: Spreadsheet::Read module is rounding the decimals in XLSX file
  • Download Code

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 08:41 UTC
    But how come the same piece of code is giving me .9888 in the other environment. Also you could see that the unformatted value is '0.98880000000000001' (raw data). How can i extract this 0.9888 from that?
      But how come the same piece of code is giving me .9888 in the other environment. Also you could see that the unformatted value is '0.98880000000000001' (raw data). How can i extract this 0.9888 from that?

      See http://floating-point-gui.de/ for the 0000000000001 part. Apart from that, if you want a certain precision, use sprintf, as you were told in other replies.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      "Also you could see that the unformatted value is '0.98880000000000001' (raw data). How can i extract this 0.9888 from that?"

      In Re: Spreadsheet::Read module is rounding the decimals in XLSX file, I provided:

      • A fully functional script.
      • The output from that script.
      • Links to documentation.
      • Advice on issues should you choose a different, but closely related, function.

      My apologies. Clearly that wasn't sufficient, free work for you!

      If, at some point, you want to extract a digit and change 0.9888 to 0.98880000000000001 in my code, you'll find out for yourself. If you're too lazy to do that, stay ignorant!

      -- Ken

        Hi Ken,

        Its not about the precisions missing. My point is why the same Read.pm is working in one environment and not working in other with the same code, same input file and same libraries? I need to know what settings(excel attributes) are missing in these two environments. We can write some customization to play with precision values, but, if you compare both the hashes, why is one environment referring to raw data and the other is printing out the exact value in xlsx file?