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

People
Owner: Nobody in particular
Requestors: develop [...] traveljury.com
Cc:
AdminCc:

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



Subject: Doesn't handle UTF8 in object stringification
Hi When writing a value which is actually an object with stringification overloaded, the UTF8 is checked too late, causing a wide-character warning when closing the workbook. This could be fixed by forcing stringification earlier in (eg) write_string: - my $str = $_[2]; + my $str = "$_[2]"; Below is a test script which demonstrates the issue thanks Clint #!/usr/bin/perl use strict; use warnings; use utf8; use Encode qw(encode_utf8); use Spreadsheet::WriteExcel; my $bar = foo->new("5€"); my $count = 1; for ("5€",foo->new("£5"),foo->new("5€")) { test($_); } sub test { my $val = shift; print "Writing workbook '$count.xls' " . "with value : ".encode_utf8($val)."\n"; # Create a new Excel workbook my $workbook = Spreadsheet::WriteExcel->new("$count.xls"); $count++; # Add a worksheet my $worksheet = $workbook->add_worksheet(); $worksheet->write('A1', $val); $workbook->close; } { package foo; use overload q{""} => \&as_string, q{0+} => sub {0}, q{cmp} => \&compare; sub new { my $class = shift; my $val = shift; bless {val=>$val},$class; } sub as_string { my $self = shift; return $self->{val} } sub compare { my ( $left, $right, $swapped ) = @_; return $swapped ? $right cmp $left->{val} : $left->{val} cmp $right; } } Perl version : 5.010000 OS name : linux Module versions: (not all are required) Spreadsheet::WriteExcel 2.25 Parse::RecDescent 1.94 File::Temp 0.18 OLE::Storage_Lite 0.16 IO::Stringy 2.110 Spreadsheet::ParseExcel (not installed) Scalar::Util 1.21 Unicode::Map (not installed)
On Thu Sep 10 13:35:06 2009, DRTECH wrote: Show quoted text
> When writing a value which is actually an object with stringification > overloaded, the UTF8 is checked too late, causing a wide-character > warning when closing the workbook.
Hi Clint, I have mixed feeling about this. I appreciate the very clear bug report and the equally clear example program which suggests to me that you got bitten by this issue in a more complicated real life situation. However, I'm not really convinced that this is a Spreadsheet::WriteExcel issue. It seems to more of a sub-issue of Perl's rather flaky support for overloading. I could pass the buck and say that the problem arises from the fact that within write_string() the Encode::is_utf8($str) call fails to stringify the object. Should that issue be raised with p5p and the Encode.pm maintainer? I imagine that we would get a rather swift and short reply. :- ) So, I am going to reject this issue. To workaround this problem I sugguest stringyfying your objects before passing them to write() or else using the add_write_handler() method to modify the behaviour of write(). Thanks for the bug report. John. --