open my $fh, '>', \my $buffer; my $workbook = Spreadsheet::WriteExcel->new($fh); ... close $fh; print $buffer;