the scope of '$text_format' is not available to the worksheet->write line.
This worked for me:
use strict;
use Excel::Writer::XLSX;
my $workbook = Excel::Writer::XLSX->new( 'mytest.xlsx' );
my $worksheet = $workbook->add_worksheet( 'testsheet' );
my $text_format = $workbook->add_format(
bold => 1,
italic => 1,
color => 'red',
size => 18,
font => 'Lucida Calligraphy'
);
$worksheet->write( 'A2', "Text" );
$worksheet->write( 'B3', "Hello Excel", $text_format );
$worksheet->write( 'B8', "Hello Excel");
$workbook->close;
__END__