Skip Menu |

This queue is for tickets about the Spreadsheet-WriteExcel CPAN distribution.

Maintainer(s)' notes

If you are reporting a bug in Spreadsheet::WriteExcel here are some pointers

1) State the issues as clearly and as concisely as possible. A simple program or Excel test file (see below) will often explain the issue better than a lot of text.

2) Provide information on your system, version of perl and module versions. The following program will generate everything that is required. Put this information in your bug report.

    #!/usr/bin/perl -w

    print "\n    Perl version   : $]";
    print "\n    OS name        : $^O";
    print "\n    Module versions: (not all are required)\n";

    my @modules = qw(
                      Spreadsheet::WriteExcel
                      Parse::RecDescent
                      File::Temp
                      OLE::Storage_Lite
                      IO::Stringy
                      Spreadsheet::ParseExcel
                      Scalar::Util
                      Unicode::Map
                    );

    for my $module (@modules) {
        my $version;
        eval "require $module";

        if (not $@) {
            $version = $module->VERSION;
            $version = '(unknown)' if not defined $version;
        }
        else {
            $version = '(not installed)';
        }

        printf "%21s%-24s\t%s\n", "", $module, $version;
    }

    __END__

3) Upgrade to the latest version of Spreadsheet::WriteExcel (or at least test on a system with an upgraded version). The issue you are reporting may already have been fixed.

4) Create a small but complete example program that demonstrates your problem. The program should be as small as possible. At the same time it should be a complete program that generates an Excel file. If the Spreadsheet::WriteExcel section is part of a much larger program then simplify it down to the essentials. Simulate any DB reads with an array.

5) Say if you tested with Excel, OpenOffice, Gnumeric or something else. Say which version of that application you used.

6) If you are submitting a patch you should check with the author whether the issue has already been patched or if a fix is in the works. Patches should be accompanied by test cases.

Asking a question

If you would like to ask a more general question there is the Spreadsheet::WriteExcel Google Group.

Report information
The Basics
Id: 5955
Status: resolved
Priority: 0/
Queue: Spreadsheet-WriteExcel

People
Owner: jmcnamara [...] cpan.org
Requestors: aksuska [...] esoteritech.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.42
Fixed in: (no value)



Subject: new( \*STDOUT ) Broken
I have used new( \*STDOUT ) to stream dynamically created Excel files, but when I upgraded to 0.42 the output is now munged and not recognized by Excel. Doing a command line test: Presuming "new( \*STDOUT )": $ mk_excel.pl > testfile.xls Produces output not recognized by Excel. If I change the command to "new( 'testfile.xls')": $ mk_excel.pl The testfile.xls file is perfectly fine, and looking at a byte by byte comparison is *substantially different* from the file created above. I presume from this that streaming to STDOUT is broken, or that the behavior has changed but the documentation has not been updated to reflect this. I haven't tested to see if this is the case for any script, but here's a snippet that includes all the related calls: # Create a new Excel workbook, output to STDOUT $wkb = Spreadsheet::WriteExcel->new( \*STDOUT ); # Add a worksheet $wks = $wkb->addworksheet(); # set column widths @width = (22.50, 9.50, 9.50, 17.33, 8.50, 10, 5.17, 5.50, 7.83, 6, 9.50, 8.50, 7.17, 17.50, 7.17, 14.50, 12, 14.50, 22.50, 11.17, 24.50, 11.17); for ( my $i = 0; $i<@width; $i++ ) { $wks->set_column( $i, $i, $width[$i] ); } # define formats $format{default} = $wkb->addformat( font => 'Times New Roman', size => 12, align => 'left' ); $format{header} = $wkb->addformat( font => 'Times New Roman', size => 12, align => 'left', bold => 1 ); # Set header row @cell = qw(EmailAddress FirstName LastName Address1 Address2 City State Zip Country Phone AgeRange DOB Gender Income Section Status Product SourceCode SourceDescription PromoCode PromoDescription Opt-inDate); $wks->write( 'A1', \@cell, $format{header} ); # read from database $count = 1; while( @{$row_ref = $query->fetch_array} ) { $count++; @cell = ( @{$row_ref}, '', '', '', 'MH', 'COM001', 'USATODAY.com', 'MIL001', 'MileageManager registration', '' ); $wks->write( "A$count", \@cell, $format{default} ); } $wkb->close; ---END--- Environment: perl, v5.8.0 built for i386-linux-thread-multi Linux 2.4.20-6 #1 Thu Feb 27 10:06:59 EST 2003 i686 i686 i386 GNU/Linux (RedHat 9)
Subject: Write:Excel new( \*STDOUT ) Broken
There are a few things that may be causing this. The first is that you may need to binmode() the filehandle. binmode(STDOUT); my $workbook = Spreadsheet::WriteExcel->new(\*STDOUT); Although, this is usually only required on Windows it may also be required with your system (RH9 and 5.8.0) depending on the LC_LANG setting. Note also the above two lines can be replaced with: my $workbook = Spreadsheet::WriteExcel->new('-'); See the Spreadsheet::WriteExcel docs on new() for details. Another thing is that you may be trying to write UTF8 data to the file. This will also cause corruption since some of the internal data will also be coerced into UTF8. See the WORKING WITH XML section of the docs for an explanation and a workaround. Finally, the file may have been corrupted in the transfer to the Windows system, say for instance if the ftp was in ascii mode. Please reply if one of these fixes your problem or else email me directly if it doesn't. John. --
I received a reply from the original poster to say that using binmode() on the filehandle had fixed the problem. While this generally isn't a requirement on non-Windows systems it is required with perls >= 5.8 that are likely to emit UTF8 in response to a non-ASCII LC_LANG or other locale setting. The documentation in the next release will be expanded to highlight this. John. --