#!usr/bin/perl #use warnings; #use strict; use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; use Spreadsheet::XLSX; use Spreadsheet::Read; use DBI; #use POSIX qw(strftime); my $dbh = DBI->connect("DBI:mysql:database=MIS_Reports;host=172.16.15.104;mysql_socket=/opt/lampstack-5.5.27-0/mysql/tmp/mysql.sock","root","", {'RaiseError' => 1}); #Selecting the data to fetch my $sth = $dbh->prepare("SELECT * from MIS_P2P"); $sth->execute() or die $DBI::errstr; my $file_path= "/root/prac/packages/B_MUM_dashboard_month_latency_corrected_FDB.XLS"; 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 $max_cols = $worksheet->{'maxcol'}; print "Rows : $max_rows\n"; print "Colomns : $max_cols\n"; while (my @row = $sth->fetchrow_array()) { my $excel_col=0; foreach my $value (@row) { $worksheet->write($max_rows+1,$excel_col,$value); $excel_col++; } }