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

People
Owner: Nobody in particular
Requestors: tlb [...] rapanden.dk
Cc:
AdminCc:

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



Subject: Encoding problem with worksheet names if string is marked as utf8
Sample code to show error: #!/usr/bin/env perl use strict; use warnings; use Carp; use utf8; use Spreadsheet::WriteExcel; my $normal_str = "test1"; my $utf8_str = "test2"; utf8::upgrade($utf8_str); my $same_str = "test2"; print "utf8 flag on utf8_str is ".(utf8::is_utf8($utf8_str) ? 'on' : 'off')."\n"; print "utf8 flag on normal_str is ".(utf8::is_utf8($normal_str) ? 'on' : 'off')."\n"; print "utf8 flag on same_str is ".(utf8::is_utf8($same_str) ? 'on' : 'off')."\n"; if($same_str eq $utf8_str) { print "strings are the same even if only one has the utf8 flag set\n"; } my $workbook = Spreadsheet::WriteExcel->new("test.xls"); $workbook->add_worksheet($normal_str); $workbook->add_worksheet($utf8_str); my $sheet = $workbook->add_worksheet("test"); $sheet->write_formula("A1","=test1!A1"); $sheet->write_formula("A2","=test2!A1");
Additional information supplied via initial github post: If a string has the UTF8 flag set it gets encoded to UTF-16BE even if non of the chars in the string requires this conversion. Later when trying to reference the sheet name in a formular this fails as here the name is not convert to UTF-16BE. In general using perl's internal utf8 flag to find out about encoding is a bad idea, you should instead try to decode the string to see if the allowed encoding is supported. my $decoded = eval { decode($encoding, $name, Encode::FB_CROAK); }; if($@) { print "$name contains non utf8 characters\n"; } Sample code that shows the problem: #!/usr/bin/env perl use strict; use warnings; use Carp; use utf8; use Spreadsheet::WriteExcel; my $normal_str = "test1"; my $utf8_str = "test2"; utf8::upgrade($utf8_str); my $same_str = "test2"; print "utf8 flag on utf8_str is ".(utf8::is_utf8($utf8_str) ? 'on' : 'off')."\n"; print "utf8 flag on normal_str is ".(utf8::is_utf8($normal_str) ? 'on' : 'off')."\n"; print "utf8 flag on same_str is ".(utf8::is_utf8($same_str) ? 'on' : 'off')."\n"; if($same_str eq $utf8_str) { print "strings are the same even if only one has the utf8 flag set\n"; } my $workbook = Spreadsheet::WriteExcel->new("test.xls"); $workbook->add_worksheet($normal_str); $workbook->add_worksheet($utf8_str); my $sheet = $workbook->add_worksheet("test"); $sheet->write_formula("A1","=test1!A1"); $sheet->write_formula("A2","=test2!A1");
Hi, Thanks for the detailed bug report. It leads me to think that it probably took a while to track down when you were bitten by it. I will put a fix for this in a later release. John. --
On Tue Apr 27 09:17:38 2010, JMCNAMARA wrote: Show quoted text
> Hi, > > Thanks for the detailed bug report. It leads me to think that it > probably took a while to track down when you were bitten by it. > > I will put a fix for this in a later release. > > John.
It did :), but your quick response is a nice reward for the effort spent. Thanks for a great module. Regards Troels.
Closing this issue. Can't fix. Suggest using Excel::Writer::XLSX instead.