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

People
Owner: Nobody in particular
Requestors: john.duncan [...] crackerbarrel.com
Cc:
AdminCc:

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



Subject: formatting bug with add_format()
Date: Fri, 28 May 2010 10:14:09 -0500
To: <bug-Spreadsheet-WriteExcel [...] rt.cpan.org>
From: "Duncan John 403" <john.duncan [...] crackerbarrel.com>
Bug: The new approach of applying formats in a $workbook->add_format statement isn't handling "overlapping" formats. The old approach of applying formats individually via a series of set_XXX methods handled "overlapping" formats. Two specific cases: 1. Border=>1 followed by bottom=>2, remains (1) all around. This still works okay if using set_border(1) followed by set_bottom(2). A workaround is to set all four sides in the add_format, but I prefer using border() as a shortcut for 3 of the sides. 2. Align center combined with align vcenter applies just the last one in the list. Example code: #!/usr/bin/perl -w use Spreadsheet::WriteExcel; my $file = "testcase.xls"; unlink("$file"); my $w = Spreadsheet::WriteExcel->new($file); my $border_format1 = $w->add_format(border=>1,bottom=>2); my $border_format2 = $w->add_format(); $border_format2->set_border(1); $border_format2->set_bottom(2); my $align_format1 = $w->add_format(border=>2,align=>'center',align=>'vcenter'); my $align_format2 = $w->add_format(border=>2,align=>'vcenter',align=>'center'); $t = $w->add_worksheet('test'); $t->merge_range('B2:D2', 'bottom is still 1 not 2', $border_format1); $t->merge_range('B4:D4', 'bottom is now 2 as expected', $border_format2); $t->merge_range('B6:D7', 'got vcenter, not center', $align_format1); $t->merge_range('B9:D10', 'got center, not vcenter', $align_format2); $w->close(); Versions: Perl version : 5.008003 OS name : hpux Module versions: (not all are required) Spreadsheet::WriteExcel 2.37 Parse::RecDescent 1.94 File::Temp 0.18 OLE::Storage_Lite 0.14 IO::Stringy 2.110 Spreadsheet::ParseExcel 0.32 Scalar::Util 1.13 Unicode::Map (not installed)
Download testcase.xls
application/vnd.ms-excel 13.5k

Message body not shown because it is not plain text.

On Fri May 28 11:14:47 2010, john.duncan@crackerbarrel.com wrote: Show quoted text
> Bug: > > The new approach of applying formats in a $workbook->add_format > statement isn't handling "overlapping" formats.
Hi, It isn't exactly a new feature. :-) It has been available since 2001. Show quoted text
> The old approach of applying formats individually via a series of > set_XXX methods handled "overlapping" formats. > > > Two specific cases: > > 1. Border=>1 followed by bottom=>2, remains (1) all around. This still > works okay if using set_border(1) followed by set_bottom(2). A > workaround is to set all four sides in the add_format, but I prefer > using border() as a shortcut for 3 of the sides.
This mainly happens because the add_format( bottom => 2, border => 1 ) properties are converted to a hash internally and retrieved via each(). It is just down to luck and the hashing algorithm that "border" come after "bottom". I can see a case for calling this a bug but it is fairly minor and it would probably be best just to use the workaround that you describe. Show quoted text
> $w->add_format(border=>2,align=>'vcenter',align=>'center');
In this case you need to differentiate by using valign: $w->add_format(border=>2,valign=>'vcenter',align=>'center'); Thanks for reporting this. If you don't feel too strongly about the first issue I'll just close the bug report without modification after the next release. John. --
Subject: RE: [rt.cpan.org #57952] formatting bug with add_format()
Date: Fri, 28 May 2010 11:17:24 -0500
To: <bug-Spreadsheet-WriteExcel [...] rt.cpan.org>
From: "Duncan John 403" <john.duncan [...] crackerbarrel.com>
Thanks for the quick response. I'm okay with the workaround for item #1. Just thought you guys might want to know. And didn't know if that behavior was related to the alignment problem. I didn't catch valign on the documentation page originally. I'll give that a shot. Thanks again! Show quoted text
-----Original Message----- From: John McNamara via RT [mailto:bug-Spreadsheet-WriteExcel@rt.cpan.org] Sent: Friday, May 28, 2010 11:10 AM To: Duncan John 403 Subject: [rt.cpan.org #57952] formatting bug with add_format() <URL: https://rt.cpan.org/Ticket/Display.html?id=57952 > On Fri May 28 11:14:47 2010, john.duncan@crackerbarrel.com wrote:
> Bug: > > The new approach of applying formats in a $workbook->add_format > statement isn't handling "overlapping" formats.
Hi, It isn't exactly a new feature. :-) It has been available since 2001.
> The old approach of applying formats individually via a series of > set_XXX methods handled "overlapping" formats. > > > Two specific cases: > > 1. Border=>1 followed by bottom=>2, remains (1) all around. This > still works okay if using set_border(1) followed by set_bottom(2). A > workaround is to set all four sides in the add_format, but I prefer > using border() as a shortcut for 3 of the sides.
This mainly happens because the add_format( bottom => 2, border => 1 ) properties are converted to a hash internally and retrieved via each(). It is just down to luck and the hashing algorithm that "border" come after "bottom". I can see a case for calling this a bug but it is fairly minor and it would probably be best just to use the workaround that you describe.
> $w->add_format(border=>2,align=>'vcenter',align=>'center');
In this case you need to differentiate by using valign: $w->add_format(border=>2,valign=>'vcenter',align=>'center'); Thanks for reporting this. If you don't feel too strongly about the first issue I'll just close the bug report without modification after the next release. John. --