in reply to Reading wrong value from excel sheet

Sandeep --

It has been a while since anyone posted to this thread but the following trick may help someone else.

This feature of SpreadsheetXLSX has annoyed me for several years.

When the Cell is Numeric, try using $cell->unformatted() +0 ;

Worked for me ... it did remove the excess precision from the numbers.

-- kjh

Example:

# place these somewhere in the BEGIN Section # my $DateFmt = "yyyy-mm-dd" ; my %HtmlShitAry ; $HtmlShitAry{ '&nbsp;' } = ' ' ; $HtmlShitAry{ '&apos;' } = "'" ; $HtmlShitAry{ '&quot;' } = '"' ; # Watch this one -- it bites !!! $HtmlShitAry{ '&amp;' } = '&' ; $HtmlShitAry{ '&lt;' } = '<' ; $HtmlShitAry{ '&gt;' } = '>' ; my $HtmlShitREx = join "|", keys %HtmlShitAry ; $HtmlShitREx = qr/$HtmlShitREx/ ; # # place those somewhere in the BEGIN Section : # # then, to 'fix' excess precision, add 0 to unformatted() ; # if ( defined $Cell->{Type} ) { if ( $Cell->{Type} eq 'Date' ) { $Val = ExcelFmt( $DateFmt, $Cell->{Val} ); } elsif ( $Cell->{Type} eq 'Numeric' ) { $Val = ( $Cell->unformatted() ) ? $Cell->unformatted() +0 # fix precision ! : 0 ; } else { $Val =~ s/($HtmlShitREx)/$HtmlShitAry{ $1 }/g ; } } else { $Val =~ s/($HtmlShitREx)/$HtmlShitAry{ $1 }/g ; }