Hi Monks,

I have a problem with file size calculation when I create .xls file using Spreadsheet::WriteExcel
File is created properly and after that I want to email that file to customer.
When I tried to print the file size once its created, getting "0" size.
if I check that in directory, I can see the file with exact size.
Can anyone tell me what's wrong in this code and how to resolve this issue?
Here is my code

use strict; use Spreadsheet::WriteExcel; # Create a new Excel workbook called result.xls my $workbook = Spreadsheet::WriteExcel->new("result.xls"); # Add some worksheets my $sheet = $workbook->add_worksheet("Example"); # Add a Format my $format = $workbook->add_format(); $format->set_align('left'); # Set the width of the column in Sheet $sheet->set_column(0, 5, 30); # Set Sheet as the active worksheet $sheet->activate(); open(FH,"<file1.csv") or die "Cannot read\n"; my($row)=0; while (<FH>) { chomp($_); my(@info) = split(/,/,$_); my $col = 0; foreach my $token (@info) { $sheet->write($row, $col, $token, $format); $col++; } $row++; } close(FH); print "Before sleep\n"; sleep(10); my $filesize = -s "result.xls"; print "Size: $filesize\n"; exit;

In reply to Getting file size Zero by Anonymous Monk

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.