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

People
Owner: Nobody in particular
Requestors: MRDVT [...] cpan.org
Cc:
AdminCc:

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



Subject: Write long integers and string
package Spreadsheet::WriteExcel::Worksheet; sub write Please add support for long "integers" to the write method. # Match integer with leading zero(s) elsif ($self->{_leading_zeros} and $token =~ /^0\d+$/) { return $self->write_string(@_); } + + #pass large integers as strings since Excel only has 15 significant digits + elsif ($token =~ /^\d{16,}$/) { + return $self->write_string(@_); + } + # Match number elsif ($token =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))? $/) { return $self->write_number(@_); } Thanks, Mike mrdvt92
On Sun Oct 03 18:36:27 2010, MRDVT wrote: Show quoted text
> package Spreadsheet::WriteExcel::Worksheet; > sub write > > Please add support for long "integers" to the write method.
Hi Mark, Spreadsheet::WriteExcel's behaviour is consistent with Excel's behaviour. If you add a 16 digit number such as 1234567890123456 to Excel it is stored it with IEE754 15 digit precision and will end up as 1234567890123450. To store it as a string it is necessary to explicitly mark it as a string. Equally if you wish to store a 16+ digit number as a string in S::WE you need to use write_string(). To change this would change behaviour that is in place for over tens years. However, there is a mechanism in the standard S::WE API for just these situations: the add_write_handler() method. See the add_write_handler() docs and the example files: http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel- 2.37/lib/Spreadsheet/WriteExcel/Examples.pm#Example:_write_handler1.pl John. --
Subject: Write long integers as string
I have modifed my code to use three standard write helpers. Closing ticket. #Long Integer Support - RT61869 $sheet->add_write_handler(qr/^\d{16,}$/, sub{shift->write_string(@_)}); #Leading Zero Support $sheet->add_write_handler(qr/^0\d+$/, sub{shift->write_string(@_)}); #DateTime Support my $subref=sub { my $sheet=shift; my @args=@_; my ($m,$d,$y,$h,$n,$s)=split(/[\/ :]/, $args[2]); $args[2]=sprintf("%4d-%02d-%02dT%02d:%02d:%02d", $y, $m, $d, $h, $n, $s); $args[3]=$format_datetime; return $sheet->write_date_time(@_); }; $sheet->add_write_handler(qr{^\d{2}/\d{2}/\d{4} \d{2}:\d{2}:\d{2}$}, $subref);
Changing status to rejected.