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: 7163
Status: resolved
Worked: 20 min
Priority: 0/
Queue: Spreadsheet-WriteExcel

People
Owner: jmcnamara [...] cpan.org
Requestors: Marianne.M.Mason [...] verizon.com
Cc:
AdminCc:

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

Attachments


Subject: File created in UNIX crashes Excel
I am trying to create spreadsheet from data extracted from MySQL 3.23. The script is running on SunOS corsair 5.6 Generic_105181-29 sun4u sparc SUNW,Ultra-Enterprise. When opening file in Excel XP (2003) or Excel 2000, the following behavior occurs: First appearance of text in column A, and column Q (last column written) is not shown. Attempts to resize any column or otherwise format the cell to make the text appear, causes Excel to crash and send error report. Upon restarting and repairing the original file, all text is seen and no actions cause Excel to crash. Code snippet as follows: my $workbook = Spreadsheet::WriteExcel->new("TNECPC04-CTR1.xls"); $sheet1 = $workbook->add_worksheet("NE CPC TOTAL"); $format1 = $workbook->add_format(); $format1->set_bold(); $format1->set_align('center'); $format1->set_valign('vcenter'); $format2 = $workbook->add_format(); $format2->set_bg_color('red'); $format3 = $workbook->add_format(); $format3->set_bold(); $format3->set_align('center'); $format3->set_valign('center'); $format3->set_italic(); $format3->set_size('8'); $format4 = $workbook->add_format(); $format4->set_align('left'); $format4->set_italic(); $format4->set_size('8'); $fnum1 = $workbook->add_format(); $fnum1->set_num_format('#,##0'); $fnum2 = $workbook->add_format(); $fnum2->set_num_format('0.00%'); $sheet1->set_column('A:A', 20); $sheet1->set_column('Q:Q', 10); $sheet1->merge_range('A1:Q1', 'Main Title', $format1); $sheet1->merge_range('A2:Q2', 'SubTitle', $format1); $sheet1->merge_range('A3:Q3', 'SubTitle', $format1); $sheet1->merge_range('A4:Q4', "$mon, $year", $format1); $sheet1->merge_range('A5:Q5', ' ', $format1); $sheet1->write_blank('A6', undef); $sheet1->write('B6', 'MESSAGE', $format1);#this text sporadically appears $sheet1->merge_range('C6:G6', 'DSO\'s', $format1); $sheet1->write('H6', 'HI-CAP', $format1); $sheet1->merge_range('I6:K6', 'CARRIER', $format1); $sheet1->merge_range('L6:P6', 'OTHER TIRKS PROVISIONING', $format1); $sheet1->write('Q6', 'TOTAL', $format1);#this text does not appear $sheet1->write('A7', 'TOTAL MONTH', $format1);#this text does not appear $sheet1->write_blank('B7', $format1); $sheet1->write('C7', 'Analog', $format3); $sheet1->write('D7', 'Digital', $format3); $sheet1->write('E7', 'Loc. Spec.', $format3); $sheet1->write('F7', 'Comp. Ckts.', $format3); $sheet1->write('G7', 'Total', $format3); $sheet1->write_blank('H7', $format3); $sheet1->write('I7', 'Customer', $format3); $sheet1->write('J7', 'Infra.', $format3); $sheet1->write('K7', 'Total', $format3); $sheet1->write('L7', 'Cables', $format3); $sheet1->write_string('M7', 'Power/Pulse', $format3); $sheet1->write('N7', 'Routing', $format3); $sheet1->write('O7', 'Spans', $format3); $sheet1->write('P7', 'Total', $format3); $sheet1->write_blank('Q7', $format3); $sheet1->set_row(7, 5); $sheet1->merge_range('A8:Q8', ' ', $format2); #row 9 $sheet1->write('A9', 'Orders RID Total', $format4); $sheet1->write('B9', "$messagetotal", $fnum1); $sheet1->write('C9', "$dsoanatotal", $fnum1); $sheet1->write('D9', "$dsodigtotal", $fnum1); $sheet1->write('E9', "$dsolstotal", $fnum1); $sheet1->write('F9', "$dsocctotal", $fnum1); $sheet1->write('G9', "$dsototal", $fnum1); $sheet1->write('H9', "$hicaptotal", $fnum1); $sheet1->write('I9', "$carriercustotal", $fnum1); $sheet1->write('J9', "$carrierinfratotal", $fnum1); $sheet1->write('K9', "$carriertotal", $fnum1); $sheet1->write('L9', "$cablestotal", $fnum1); $sheet1->write('M9', "$pptotal", $fnum1); $sheet1->write('N9', "$routingtotal", $fnum1); $sheet1->write('O9', "$spanstotal", $fnum1); $sheet1->write('P9', '=SUM(L9:O9)', $fnum1); $sheet1->write('Q9', '=SUM(B9,G9,H9,K9,P9)', $fnum1); .... more of same code.... $sheet1->activate(); $sheet1->select(); $workbook->close(); Thank you for any help or suggestions you may provide. Marianne
Download TNECPC04-CTR1.xls
application/vnd.ms-excel 10k

Message body not shown because it is not plain text.

[guest - Wed Jul 28 15:17:38 2004]: Show quoted text
> When opening file in Excel XP (2003) or Excel 2000, the following > behavior occurs: > First appearance of text in column A, and column Q (last column > written) is not shown. > Attempts to resize any column or otherwise format the cell to make the > text appear, causes Excel to crash and send error report. > Upon restarting and repairing the original file, all text is seen and > no actions cause Excel to crash. > > Code snippet as follows: > ... >
Hi, Thanks for the detailed report. The problem is that formats used for merged ranges shouldn't be used for non-merged cells. This is mentioned in the documentation but it probably isn't highlighted enough. See http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm#merge_range($first_row,_$first_col,_$last_row,_$last_col,_$token,_$format) I have some code changes that will make this unnecessary but they require further testing. In the meantime the workaround for this problem is to use separate formats for merge_ranges(). For example I added the following to your code and then used the $formatX_merge formats in the merge_range() calls: # New formats only to be used with merged ranges. $format1_merge = $workbook->add_format(); $format2_merge = $workbook->add_format(); $format1_merge ->copy($format1); $format2_merge ->copy($format2); Here is your updated code. I tested this with Excel 97, 2000 and 2003. It also fixes the related problem of the text in some cells not displaying. #!/usr/bin/perl -w #use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new('TNECPC04-CTR1.xls'); $sheet1 = $workbook->add_worksheet("NE CPC TOTAL"); $format1 = $workbook->add_format(); $format1->set_bold(); $format1->set_align('center'); $format1->set_valign('vcenter'); $format2 = $workbook->add_format(); $format2->set_bg_color('red'); $format3 = $workbook->add_format(); $format3->set_bold(); $format3->set_align('center'); $format3->set_valign('center'); $format3->set_italic(); $format3->set_size('8'); $format4 = $workbook->add_format(); $format4->set_align('left'); $format4->set_italic(); $format4->set_size('8'); # New formats only to be used with merged ranges. $format1_merge = $workbook->add_format(); $format2_merge = $workbook->add_format(); $format1_merge ->copy($format1); $format2_merge ->copy($format2); $fnum1 = $workbook->add_format(); $fnum1->set_num_format('#,##0'); $fnum2 = $workbook->add_format(); $fnum2->set_num_format('0.00%'); $sheet1->set_column('A:A', 20); $sheet1->set_column('Q:Q', 10); $sheet1->merge_range('A1:Q1', 'Main Title', $format1_merge); $sheet1->merge_range('A2:Q2', 'SubTitle', $format1_merge); $sheet1->merge_range('A3:Q3', 'SubTitle', $format1_merge); $sheet1->merge_range('A4:Q4', "$mon, $year", $format1_merge); $sheet1->merge_range('A5:Q5', ' ', $format1_merge); $sheet1->write_blank('A6', undef); $sheet1->write('B6', 'MESSAGE', $format1);#this text sporadically appears $sheet1->merge_range('C6:G6', 'DSO\'s', $format1_merge); $sheet1->write('H6', 'HI-CAP', $format1); $sheet1->merge_range('I6:K6', 'CARRIER', $format1_merge); $sheet1->merge_range('L6:P6', 'OTHER TIRKS PROVISIONING', $format1_merge); $sheet1->write('Q6', 'TOTAL', $format1);#this text does not appear $sheet1->write('A7', 'TOTAL MONTH', $format1);#this text does not appear $sheet1->write_blank('B7', $format1); $sheet1->write('C7', 'Analog', $format3); $sheet1->write('D7', 'Digital', $format3); $sheet1->write('E7', 'Loc. Spec.', $format3); $sheet1->write('F7', 'Comp. Ckts.', $format3); $sheet1->write('G7', 'Total', $format3); $sheet1->write_blank('H7', $format3); $sheet1->write('I7', 'Customer', $format3); $sheet1->write('J7', 'Infra.', $format3); $sheet1->write('K7', 'Total', $format3); $sheet1->write('L7', 'Cables', $format3); $sheet1->write_string('M7', 'Power/Pulse', $format3); $sheet1->write('N7', 'Routing', $format3); $sheet1->write('O7', 'Spans', $format3); $sheet1->write('P7', 'Total', $format3); $sheet1->write_blank('Q7', $format3); $sheet1->set_row(7, 5); $sheet1->merge_range('A8:Q8', ' ', $format2_merge); #row 9 $sheet1->write('A9', 'Orders RID Total', $format4); $sheet1->write('B9', "$messagetotal", $fnum1); $sheet1->write('C9', "$dsoanatotal", $fnum1); $sheet1->write('D9', "$dsodigtotal", $fnum1); $sheet1->write('E9', "$dsolstotal", $fnum1); $sheet1->write('F9', "$dsocctotal", $fnum1); $sheet1->write('G9', "$dsototal", $fnum1); $sheet1->write('H9', "$hicaptotal", $fnum1); $sheet1->write('I9', "$carriercustotal", $fnum1); $sheet1->write('J9', "$carrierinfratotal", $fnum1); $sheet1->write('K9', "$carriertotal", $fnum1); $sheet1->write('L9', "$cablestotal", $fnum1); $sheet1->write('M9', "$pptotal", $fnum1); $sheet1->write('N9', "$routingtotal", $fnum1); $sheet1->write('O9', "$spanstotal", $fnum1); $sheet1->write('P9', '=SUM(L9:O9)', $fnum1); $sheet1->write('Q9', '=SUM(B9,G9,H9,K9,P9)', $fnum1); #.... more of same code.... $sheet1->activate(); $sheet1->select(); $workbook->close(); __END__
[Marianne.M.Mason@verizon.com - Wed Jul 28 18:21:48 2004]: Show quoted text
> > Thank you for your detailed response. I apologize for not picking > that up
It is far from obvious. :-) I've made a TODO note to highlight this feature more clearly in the documentation until it is fixed. John. --