... while (my @res = $sth->fetchrow_array()) { $worksheet->write($i, 0, $res[0]); $i++; } ...