I am having a similar problem. I have a link on a report detailing some ticket information. That link should regenerate the same data as displayed on the page but as an excel spreadsheet that is passed to the user for download and not saved on the server.

The link works, a download dialog appears to save the file but for some reason the file appears to be limited to around 400k in size ( a little under 4500 of the 9755 rows that should appear. When I change from a file handle to saving the file to the server it works fine, the problem only happens when it's a direct download. Any help you could offer would be great

    tie *XLS, 'IO::Scalar', \$xls_str;
    my $workbook = Spreadsheet::WriteExcel::Big->new(\*XLS);
    my $worksheet = $workbook->add_worksheet();

    # Hardcoded row and column fields
    $worksheet->set_landscape();
    $worksheet->set_row(0,30);
    $worksheet->set_column(0,0, 20);
    $worksheet->set_column(1,1, 20);
    $worksheet->set_column(2,2, 20);
    $worksheet->set_column(3,3, 20);
    $worksheet->set_column(4,4, 20);
    $worksheet->set_column(5,5, 20);
    $worksheet->set_column(6,6, 20);

    # Spreadsheet Formating
    my $format = $workbook->add_format();
    my $titleformat = $workbook->add_format();
    $format->set_bold(1);
    $titleformat->set_size(15);

    # Counters
    my $rowcount = 1;

    # loops for writing
    while ( my @row = $sth->fetchrow_array ) {
      my $row_ref = \@row;
      $worksheet->write_row($rowcount,0,  $row_ref);
      $rowcount++;
    } #end of loop

    $workbook->close();

    #my $size = (-s $xls_str);
    print "content: myfile.xls\r\n";
    print "content-disposition: inline; filename=myfile.xls\r\n";
    #print "content-length: $size\r\n";
    print "content-type: application/vnd.ms-excel\r\n";

    #local $/ = undef;
    #open (F, "<$xls_str");
    #  binmode(F); binmode(STDOUT);
    #  print <F>;
    #close(F);
    print $xls_str;

in the above script if I replace

    tie *XLS, 'IO::Scalar', \$xls_str;
    my $workbook = Spreadsheet::WriteExcel->new(\*XLS);
with
    my $filename = "myfile.xls";
    my $workbook = Spreadsheet::WriteExcel->new($filename);
The file is saved to my server with the correct number of rows

I believe the problem has something to do with IO::Scalar and/or an apache config but I'm a little lost as to what I could be missing


In reply to Re^2: Update: Provblem 'solved' by Anonymous Monk
in thread Using Spreadsheet::WriteExcel with mod_perl and Content-Disposition? by one4k4

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.