Here i am trying to read the value in C15 in the below excel sheet.use strict; use warnings; use MongoDB; use MongoDB::OID; use Spreadsheet::ParseExcel; use Spreadsheet::XLSX; use Spreadsheet::Read; use Tie::IxHash; my $date=$ARGV[0]; $date or $date=`date --date='1 day ago' +%d-%m-%Y`; chomp $date; my $file_path="/root/prac/packages/SDP_VAS_NQI-17-06-2015.xlsx"; my $workbook = ReadData($file_path,cells => 0 ); if(defined $workbook->[0]{'error'}) { print "Error occurred while processing $file_path:".$workbook- +>[0]{'error'}."\n"; exit(-1); } my $worksheet = $workbook->[1]; my $max_rows = $worksheet->{'maxrow'}; my $sqi; my $cell_data=0; for my $row_num (15..($max_rows)) { $cell_data = $worksheet->{cell}[2][$row_num]; # same, unforma +tted if($date eq $cell_data) { $sqi = $worksheet->{cell}[4][$row_num]; # same, unfor +matted print "$sqi\n"; print "$cell_data\n"; print "$row_num\n"; # break; last; } } #chomp $sqi; my $db_host="172.16.15.115"; my $db_name="ravi"; my $client = MongoDB::MongoClient->new(host => $db_host, port => 2 +7017); my $database = $client->get_database( $db_name ); my $data = $database->get_collection("SDP_SQI"); my %insert_data_hourly=(); $insert_data_hourly{'date'}=$date; $insert_data_hourly{'SQI'}=$sqi; my $id=$data->insert(\%insert_data_hourly);
In this excel sheet C15 contains a formulae =IF(C15>C$13,IF(C15>C$12,C$8,((C15-C$13)*(C$8-C$9)/(C$12-C$13))+C$9),IF(C15<C$14,C$10,C$9-((C$13-C15)*(C$9-C$10)/(C$13-C$14)))) The default value is 18.05. When i try to read the cell value its giving the default value. But not the modified value. Ex: The default value is 18.05 (generated through formulae). The modified value is 19.95 But when u read through the code it return 18.05 but not 19.95. Note: The program working properly for general data(cell without having formulas). In the last coloumn i need only one digit after '.'.But when i read that it returns upto 8 digits after '.' Ex: Existing value: 114.2 Returning value: 114.198682 How to set limit after the decimal point.15th 12-06-2015 100 19.95 48.7087375 0.97 33.48214286 + 0.98 114.2 16th 13-06-2015 100 19.95 49.0446825 0.97 33.48214286 + 0.98 113.4 17th 14-06-2015 100 19.95 49.1407375 0.97 33.48214286 + 0.98 115 18th 15-06-2015 100 19.95 49.55261 0.97 33.48214286 +0.98 115.6 19th 16-06-2015 100 19.95 49.91307 0.97 33.48214286 +0.98 118.4 20th 17-06-2015 100 19.95 50.625125 0.97 33.48214286 + 0.98 111.8 21th 18.05 1.00 1.00 22th 18.05 1.00 1.00 23th 18.05 1.00 1.00 24th 18.05 1.00 1.00 25th 18.05 1.00 1.00
In reply to Excel-Error reading in formulae value by ravi45722
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |