Hi, I have an excel sheet (xlsx format), with just .9888 as value in A1 cell.

Below is my code to read the contents of this file

#!/bin/env perl use strict; use Spreadsheet::Read; use Spreadsheet::XLSX; my $lExcelFileData = ReadData("test.xlsx"); #Reading Price information from the input excel sheet using template i +nformation my $lRate = $lExcelFileData->[1]{A1}; print "Rate in xlsx file-> ".$lRate . "\n";

Output on which perl 5.8.8 is installed

bash-3.2$ ./print_xlsx_file_surya1.pl test.xlsx Rate in xlsx file-> 0.99

It is getting rounded to two decimals. Interesting thing is this 5.8.8 installataion is on sun solaris machine. Where as, I have run the same program in 5.8.9 installated Linux machine, It is giving me correct value as output .9888. The thing is for both installations, i have set the PERL5LIB to the same libraries. Not sure what is going wrong. Working in one environment and not working in other.

I need this without getting rounded. I also tried to print the content of same Read.pm in those two environments -

5.8.8 (sun solaris): bash-3.2$ ./print_xlsx_file_surya1.pl test.xlsx 8->sheet$VAR1 = 'maxcol'; $VAR2 = 1; $VAR3 = 'maxrow'; $VAR4 = 1; $VAR5 = 'A1'; $VAR6 = '0.99'; $VAR7 = 'label'; $VAR8 = 'Sheet1'; $VAR9 = 'attr'; $VAR10 = []; $VAR11 = 'cell'; $VAR12 = [ [], [ undef, '0.98880000000000001' ] ]; Rate in xlsx file-> 0.99
The same Read.pm is printing the below in linux version: :/cmpnt/slt1.0/devlp/SLTICT01/WORK/cmac6844>./print_xlsx_file_surya1.p +l test.xlsx 8->sheet$VAR1 = 'maxcol'; $VAR2 = 5; $VAR3 = 'maxrow'; $VAR4 = 6; $VAR5 = 'A1'; $VAR6 = '0.9888'; $VAR7 = 'E6'; $VAR8 = ''; $VAR9 = 'label'; $VAR10 = 'Sheet1'; $VAR11 = 'attr'; $VAR12 = []; $VAR13 = 'cell'; $VAR14 = [ [], [ undef, '0.9888' ], [], [], [], [ undef, undef, undef, undef, undef, undef, '' ] ]; Rate in xlsx file-> 0.9888
Our production box is sun solaris and i dont want rounding to happen. Please suggest.

This problem is not coming with xls sheet. Only with xlsx am facing this.


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.