my $sth = $dbh->prepare("SELECT * from $MIS_SHEET"); #Getting data from table $sth->execute() or die $DBI::errstr; while (my @row = $sth->fetchrow_array()) { ++$row; foreach my $value (@row) { $sheet->AddCell( $row, $col, $value ); ++$col; } }