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: 7040
Status: resolved
Priority: 0/
Queue: Spreadsheet-WriteExcel

People
Owner: jmcnamara [...] cpan.org
Requestors: albattil [...] tin.it
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Create a damaged xls file
I'm creating multi-sheet workbook using a XML source file with XML::Parser(2.30) and Spreeadsheet::WriteExcel (2.03). On the distribution MDK10.0 work fine, but on MDK8.2 kernel 2.4.18-6mdk create a unreadable damaged file. Perl version v5.6.1 the code: #!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; use XML::Parser; # # Imposto da parametro il file XML di input e l'output XLS # my $XML_filename = shift or die "Missing the output file name\nUse: " . $0 . " input_xml_filename out_xls_filename\n"; my $XLS_filename = shift or die "Missing the input file name\nUse: " . $0 . " input_filename out_xls_filename\n"; # # Inizializzo le variabili private ed imposto la variabile della prima riga per i subtotali # my ($workbook, $worksheet, $f_header, $f_header1, $f_body, $f_body_d); my $first_row = 3; # # Imposto gli handler per il parse del file XML # my $parser = XML::Parser->new( Style => 'Subs', Pkg => 'MySubs', ErrorContext => 2); # # Eseguo il parse # $parser->parsefile($XML_filename); # # Sub che calcola e inserisce i subtotali # sub subtot { $_[0]->write($_[3], 0, $_[2] . $_[1]); $_[0]->write($_[3], 1, ''); $_[0]->write($_[3], 2, '=SUBTOTAL(9,C' . $_[4] . ':C' . $_[5] . ')'); $_[0]->write($_[3], 3, '=SUBTOTAL(9,D' . $_[4] . ':D' . $_[5] . ')'); $_[0]->write($_[3], 4, '=SUBTOTAL(9,E' . $_[4] . ':E' . $_[5] . ')'); $_[0]->write($_[3], 5, '=SUBTOTAL(9,F' . $_[4] . ':F' . $_[5] . ')'); $_[0]->write($_[3], 6, '=SUBTOTAL(9,G' . $_[4] . ':G' . $_[5] . ')'); $_[0]->write($_[3], 7, '=SUBTOTAL(9,H' . $_[4] . ':H' . $_[5] . ')'); $_[0]->write($_[3], 8, '=SUBTOTAL(9,I' . $_[4] . ':I' . $_[5] . ')'); $_[0]->write($_[3], 9, '=SUBTOTAL(9,J' . $_[4] . ':J' . $_[5] . ')'); $_[0]->write($_[3], 10, '=SUBTOTAL(9,K' . $_[4] . ':K' . $_[5] . ')'); $_[0]->write($_[3], 11, '=SUBTOTAL(9,L' . $_[4] . ':L' . $_[5] . ')'); $_[0]->write($_[3], 12, '=SUBTOTAL(9,M' . $_[4] . ':M' . $_[5] . ')'); $_[0]->set_row($_[3], undef, undef, 0, $_[6]); } # # Definisco il package richiamato nel parser # { package MySubs; # # Sub richiamata dall'apertura del tag report_audit # sub report_audit { shift; my ($att, $val, $element, %attr); $element = shift; while (@_) { $att = shift; $val = shift; $attr{$att} = $val; } $workbook = Spreadsheet::WriteExcel->new($XLS_filename); $f_header = $workbook->add_format(align => 'center', valign => 'top', border => 1, font => 'Arial', size => 10, text_wrap => 1); $f_header1 = $workbook->add_format(align => 'center', valign => 'top', border => 1, font => 'Arial', size => 10, text_wrap => 0); $f_body = $workbook->add_format(font => 'Arial', size => 10, text_wrap => 0); $f_body_d = $workbook->add_format(font => 'Arial', size => 10, text_wrap => 0); $f_body_d->set_num_format('d mmmm yyyy'); $::state::store::nomerep = $attr{'name'}; $::state::store::mese = $attr{'mese'}; $::state::store::anno = $attr{'anno'}; } # # Sub richiamata dalla chiusura del tag report_audit # sub report_audit_ { shift; my $element; $element = shift; $workbook->close() or die "Error closing file: $!"; } # # Sub richiamata dall'apertura del tag foglio # sub foglio { shift; my ($att, $val, $element, %attr); $element = shift; while (@_) { $att = shift; $val = shift; $attr{$att} = $val; } $::state::store::banca = $attr{'banca'}; $::state::store::row = '1'; $::state::store::frow = 3; $worksheet = $workbook->add_worksheet('Clone ' . $::state::store::banca); $worksheet->set_column('A:A', 6.5, $f_body); $worksheet->set_column('B:B', 6.5, $f_body); $worksheet->set_column('C:M', 10, $f_body); $worksheet->merge_range('A1:A2', 'Codice IPI', $f_header); $worksheet->merge_range('B1:B2', 'Data', $f_header); $worksheet->merge_range('C1:D1', 'Emergenza MIL normale', $f_header); $worksheet->merge_range('E1:F1', 'Emergenza MIL immediata', $f_header); $worksheet->merge_range('G1:H1', 'Emergenza da ambiente E', $f_header); $worksheet->merge_range('I1:K1', 'Standard', $f_header); $worksheet->merge_range('L1:M1', 'Totali', $f_header); my @sheet_header = ('Packages', 'Programmi', 'Packages', 'Programmi', 'Packages', 'Programmi', 'Packages', 'Programmi','JCL','Packages','Oggetti'); $worksheet->write_row(1,2, \@sheet_header,$f_header1); $worksheet->set_row(0, 25.50); $worksheet->set_row(1, 12.75); $::state::store::curripi = ''; } # # Sub richiamata dalla chiusura del tag foglio # sub foglio_ { shift; my $element; $element = shift; &main::subtot($worksheet, $::state::store::curripi, 'Totale ', ++$::state::store::row, $::state::store::frow, $::state::store::row, 1); &main::subtot($worksheet, '', 'Totale Complessivo', ++$::state::store::row, $first_row, $::state::store::row, 0); $worksheet->set_landscape(); $worksheet->center_horizontally(); $worksheet->repeat_rows(0, 1); $worksheet->set_header('&C&"Arial,Bold Italic"&20' . $::state::store::nomerep . ':' . ' ' . $::state::store::mese . ' ' . $::state::store::anno); $worksheet->set_footer('&L&"Arial,Bold Italic"&16&F&C&"Arial,Bold Italic"&16Page &P of &N&R&16&"Arial,Bold Italic"&A'); undef $::state::store::banca; } # # Sub richiamata dall'apertura del tag datarow # sub datarow { shift; my ($att, $val, $element, %attr, @sheet_row); $element = shift; while (@_) { $att = shift; $val = shift; $attr{$att} = $val; } @sheet_row = split(/,/,$attr{'data'}); $::state::store::row++; if ($sheet_row[0] ne $::state::store::curripi and $::state::store::curripi ne '') { &main::subtot($worksheet,$::state::store::curripi,'Totale ', $::state::store::row, $::state::store::frow, $::state::store::row,1); $::state::store::row++; $::state::store::frow = $::state::store::row+1; } $::state::store::curripi = $sheet_row[0]; $worksheet->write_row($::state::store::row, 0, \@sheet_row); $worksheet->set_row($::state::store::row, undef, undef, 0, 2); } # # Sub richiamata dalla chiusura del tag datarow # sub datarow_ { shift; my ($att, $val, $element, %attr, @sheet_row); $element = shift; while (@_) { $att = shift; $val = shift; $attr{$att} = $val; } } } exit; XML input: <report_audit mese="giugno" anno="2004" name="Passaggi in Produzione"> <foglio banca="AV"> <datarow data="AC,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AC,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AC,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AC,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AE,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AE,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AE,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AG,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AG,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AG,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AG,16,2,3,4,0,5,6,1,6,0,1,6"/> </foglio> <foglio banca="A1"> <datarow data="AC,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AC,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AC,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AC,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AE,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AE,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AE,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AG,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AG,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AG,16,2,3,4,0,5,6,1,6,0,1,6"/> <datarow data="AG,16,2,3,4,0,5,6,1,6,0,1,6"/> </foglio> </report_audit
[guest - Wed Jul 21 04:15:18 2004]: Show quoted text
> I'm creating multi-sheet workbook using a XML source file with > XML::Parser(2.30) and Spreeadsheet::WriteExcel (2.03). On the > distribution MDK10.0 work fine, but on MDK8.2 kernel 2.4.18-6mdk > create a unreadable damaged file. > Perl version v5.6.1
I'd guess that the problem is due to fact that you are getting UTF8 data back from XML::Parser and writing this to a WriteExcel file causes it to become corrupt. See the following for a longer explanation and some workarounds: http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.03/lib/Spreadsheet/WriteExcel.pm#WORKING_WITH_XML Let me know if this does/doesn't fix the problem. John. --
[albattil@tin.it - Wed Jul 21 17:36:41 2004]: Show quoted text
> Now work fine: thank's a lot and excuse me if I don't have read all > the documentation.
Okay. I'm glad that worked. :-) John. --