my $comment; $comment = $wsheet->Cells($row_num,$col_num)->{Comment}; if(defined $comment) { $wsheet->Cells($row_num,$col_num)->{Comment}->Text({Text => $cell_value}); } else { $wsheet->Cells($row_num,$col_num)->AddComment($cell_value); $comment = $wsheet->Cells($row_num,$col_num)->{Comment}; if(!defined $comment) { print STDERR "Could not add comment in row $row_num and column $col_num\n"; } }