Here is some code to get to the same error message.
Run the code to the point it pauses, then try to open the perl.xlsx file using Excel.
It uses an undocumented internal method, so hopefully is not what is actually being done. I tried a few variants of deferred close etc. but without success as all files were zero sized until the close method is called (or objects destroyed). Perhaps there is a point where Excel::Writer::XLSX reaches a memory or size threshold and writes the data to file, and this is being hit by the OP.
# adapted from the Excel::Writer::XLSX synopsis
use 5.010;
use warnings;
use Excel::Writer::XLSX;
my $workbook = Excel::Writer::XLSX->new( 'perl.xlsx' );
# Add a worksheet
$worksheet = $workbook->add_worksheet();
# some data
for my $row (0..5) {
for my $col (0..2) {
$worksheet->write( $row, $col, $row );
}
}
# internal method used in ->close()
$workbook->_store_workbook();
$workbook->close();
{
# defer garbage collection to test file
local $| = 1;
say 'Pausing, press any key to continue';
my $pause = <>;
}