Skip Menu |

This queue is for tickets about the Spreadsheet-WriteExcel-Simple CPAN distribution.

Report information
The Basics
Id: 4378
Status: new
Priority: 0/
Queue: Spreadsheet-WriteExcel-Simple

People
Owner: Nobody in particular
Requestors: walsh [...] cenix-bioscience.com
Cc:
AdminCc:

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



Date: Wed, 24 Sep 2003 15:33:56 +0200
From: Andrew Walsh <walsh [...] cenix-bioscience.com>
To: Tony Bowden <kasei [...] tmtm.com>
Subject: Spreadsheet::WriteExcel
Hi Tony, Thanks a lot for the suggested fix on the spreadsheets with 1 row. I wanted to show you something that tripped me up for a bit until I could get to the bottom of it (at least I think I have :) The problem has to do with using worksheets that have been added to the workbook object. I found that if I create a Spreadsheet::WriteExcel object within a function, add a worksheet, and then return the worksheet from the function, it no longer writes rows. However, if I create the Spreadsheet::WriteExcel object outside the function, pass it into the function, and create the worksheet, then the worksheet can be written to once returned from the function. I've attached a test script and the resulting 2 Excel files to make it all a bit clearer. I can imagine that it has to do with the Spreadsheet::WriteExcel object being garbage collected after the function exits. But it really tripped me up because the subsequent calls to the returned worksheet object do not throw any warnings or errors. Should I be getting warning messages? Thanks a lot, Andrew -- ------------------------------------------------------------------ Andrew Walsh, M.Sc. Bioinformatics Software Engineer IT Unit Cenix BioScience GmbH Pfotenhauerstr. 108 01307 Dresden, Germany Tel. +49(351)210-2699 Fax +49(351)210-1309 public key: http://www.cenix-bioscience.com/public_keys/walsh.gpg ------------------------------------------------------------------
Download test1.xls
application/excel 7.4k

Message body not shown because it is not plain text.

Download test2.xls
application/excel 7.4k

Message body not shown because it is not plain text.

#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; my $file1 = 'test1.xls'; my $file2 = 'test2.xls'; my $xls = Spreadsheet::WriteExcel->new($file1); my $sheet1 = get_excel_sheet1($xls); my $sheet2 = get_excel_sheet2($file2); # NB: only $sheet1 will have the 'bar' row written (dunno why) for my $s ($sheet1, $sheet2) { $s->write_row(1, 0, ['bar']); } ## Functions ## sub get_excel_sheet1 { my ($xls) = @_; my $sheet = $xls->addworksheet(); $sheet->write_row(0, 0, ['foo']); return $sheet; } sub get_excel_sheet2 { my ($file_name) = @_; my $xls = Spreadsheet::WriteExcel->new($file_name); my $sheet = $xls->addworksheet(); $sheet->write_row(0, 0, ['foo']); return $sheet; }