In Excel::Writer::XLSX::Package::Packager there is:

sub _create_package { ... $self->_write_worksheet_files(); } sub _write_worksheet_files { my $self = shift; my $dir = $self->{_package_dir}; _mkdir( $dir . '/xl' ); _mkdir( $dir . '/xl/worksheets' ); ... } sub _mkdir { my $dir = shift; return if -e $dir; my $ret = mkdir( $dir ); if ( !$ret ) { croak "Couldn't create sub directory $dir: $!"; } }

In Excel::Writer::XLSX::Workbook there is:

sub new { my $class = shift; my $self = Excel::Writer::XLSX::Package::XMLwriter->new(); ... $self->{_tempdir} = undef; ... } sub _store_workbook { ... my $tempdir = File::Temp->newdir( DIR => $self->{_tempdir} ); ... $packager->_set_package_dir( $tempdir ); $packager->_create_package(); ... } sub set_tempdir { my $self = shift; my $dir = shift; croak "$dir is not a valid directory" if defined $dir and not -d $ +dir; $self->{_tempdir} = $dir; }

The Workbook most likely is created with an undef _tempdir (the default). It passes a $tempdir to Packager via a call to File::Temp->newdir( DIR => $self->{_tempdir} ). E.g. for me, it created drwx------.    /tmp/4zsSPLpSBSM when given DIR=>undef. The tempdir created in this way is supposedly automatically deleted.

Then Workbook calls the packager with previous tempdir value as its _package_dir

Then Packager creates subdir 'xl', and then 'xl/worksheets'. _mkdir() will not complain if asked to re-create already existing dir (or file!, it checks -e)

I would set some debug messages as follows (in ..../perl5/Excel/Writer/XLSX/Package/Packager.pm):

sub _store_workbook { ... my $tempdir = File::Temp->newdir( DIR => $self->{_tempdir} ); print "tempdir='$tempdir'\n"; # debug if( ! -d $tempdir ){ croak "$tempdir was not created" } # debug my $mode = (stat($tempdir))[2]; printf "Permissions are %04o\n", $mode & 07777; ... $packager->_set_package_dir( $tempdir ); $packager->_create_package(); ... }

In reply to Re: Question regarding error when trying to generate spreadsheet with Excel::Writer::XLSX by bliako
in thread Question regarding error when trying to generate spreadsheet with Excel::Writer::XLSX by atcroft

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.