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{ ' ' } = ' ' ; $HtmlShitAry{ ''' } = "'" ; $HtmlShitAry{ '"' } = '"' ; # Watch this one -- it bites !!! $HtmlShitAry{ '&' } = '&' ; $HtmlShitAry{ '<' } = '<' ; $HtmlShitAry{ '>' } = '>' ; 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 ; }
In reply to Re: Reading wrong value from excel sheet
by kjhambrick
in thread Reading wrong value from excel sheet
by sandeep_car
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |