AppPage.pl use strict; use CGI qw(:standard); use CGI::Carp('fatalsToBrowser'); use Spreadsheet::ParseExcel::SaveParser; print header(); print start_multipart_form(); if(param('Submit')){ if(param('file_upl')){ Display_File(); } }else{ Display_Main(); } sub Display_Main(){ print "Please upload file for processing"; print filefield(-name=>"file_upl",-accept=>'application/vnd.ms-excel') ; print submit(-name=>"Submit"); } sub Display_File{ my $fh = upload('upload_file'); if(!$fh){ print "file too big". $cgi_error(); exit 0; }else{ open (OUTFILE, ">> $file_path") or die("Can't open/create $file_name".$!); binmode OUTFILE; while(<$fh>){ print OUTFILE; } close OUTFILE; } my $out_file = Read_Write_excel(); #Saves file in a folder on server print "Thank you. Dowload"; print "here"; } sub Read_Write_excel{ my $out_file = 'C:\OUT_File.xls' my $parser = new Spreadsheet::ParseExcel::SaveParser; my $Book = $parser->Parse($file_path); my $Sheet = $Book->worksheet('Data'); my ($first_row,$last_row) = $Sheet->row_range(); my $key_col = 0; my $id; for(my $row=1;$row<=$last_row;$row++){ $id = $Sheet->get_cell($row,$key_col)->value(); if($id){ $col = $col++; $Sheet->AddCell($row,$col,'Id found'); } else{ $col = $col++; $Sheet->AddCell($row,$col,'Id Not found'); } } $Book->SaveAs($out_file); return $out_file;