Click here to get back home

Spreadsheet::WriteExcel new($var) not working

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Spreadsheet::WriteExcel new($var) not working Mick 05-20-2008
Posted by Mick on May 20, 2008, 6:10 am
Please log in for more thread options
Hi

I am trying to use the perl module Spreadsheet::WriteExcel to create a
new XLS file and write into it, however in my case the name of the xls
file has to be entered by the user and it can not be fixed. So to
achieve this write something like this in my code where $XLSPath is
entered by the user before this line.

#46 my $xlsReport = Spreadsheet::WriteExcel->new($xlsFileName);

However, I get the error
---
Can't call method "add_worksheet" on an undefined value at line 96 in
c:\report-xls.pl which is
---

#95 # Create new Worksheet in the workbook
#96 $worksheet = $xlsReport->add_worksheet();

I reckon this means that the variable $xlsReport is undefined which
may be because of some error in line 46. I have seen the examples and
previous question threads and do not find any example in which the
name of the file is a variable. Please help!!

Regards

Mick

Posted by Mick on May 20, 2008, 6:12 am
Please log in for more thread options


> Hi
>
> I am trying to use the perl module Spreadsheet::WriteExcel to create a
> new XLS file and write into it, however in my case the name of the xls
> file has to be entered by the user and it can not be fixed. So to
> achieve this write something like this in my code where $XLSPath is
> entered by the user before this line.
>
> #46 my $xlsReport = Spreadsheet::WriteExcel->new($xlsFileName);
>
> However, I get the error
> ---
> Can't call method "add_worksheet" on an undefined value at line 96 in
> c:\report-xls.pl which is
> ---
>
> #95 # Create new Worksheet in the workbook
> #96 $worksheet = $xlsReport->add_worksheet();
>
> I reckon this means that the variable $xlsReport is undefined which
> may be because of some error in line 46. I have seen the examples and
> previous question threads and do not find any example in which the
> name of the file is a variable. Please help!!
>
> Regards
>
> Mick

Extremely sorry, please read $XLSPath as $xlsFileName in the first
para.

Posted by Mick on May 20, 2008, 7:12 am
Please log in for more thread options
>
>
>
> > Hi
>
> > I am trying to use the perl module Spreadsheet::WriteExcel to create a
> > new XLS file and write into it, however in my case the name of the xls
> > file has to be entered by the user and it can not be fixed. So to
> > achieve this write something like this in my code where $XLSPath is
> > entered by the user before this line.
>
> > #46 my $xlsReport = Spreadsheet::WriteExcel->new($xlsFileName);
>
> > However, I get the error
> > ---
> > Can't call method "add_worksheet" on an undefined value at line 96 in
> > c:\report-xls.pl which is
> > ---
>
> > #95 # Create new Worksheet in the workbook
> > #96 $worksheet = $xlsReport->add_worksheet();
>
> > I reckon this means that the variable $xlsReport is undefined which
> > may be because of some error in line 46. I have seen the examples and
> > previous question threads and do not find any example in which the
> > name of the file is a variable. Please help!!
>
> > Regards
>
> > Mick
>
> Extremely sorry, please read $XLSPath as $xlsFileName in the first
> para.

Hi!

I figured out the problem after a long tussle. There was some problem
with the scope of variable definition. I can now certainly say that
statements like

my $xlsReport = Spreadsheet::WriteExcel->new($xlsFileName)

work.

MCK

Similar ThreadsPosted
Spreadsheet::WriteExcel December 7, 2005, 3:50 pm
ANNOUNCE: Spreadsheet::WriteExcel 2.04 August 19, 2004, 12:05 am
Query about Spreadsheet::WriteExcel September 10, 2004, 3:54 pm
ANNOUNCE: Spreadsheet::WriteExcel 2.10 September 24, 2004, 12:52 am
Spreadsheet::WriteExcel and Frames October 11, 2004, 1:08 pm
Spreadsheet::WriteExcel format width May 20, 2005, 1:04 pm
WriteExcel internal hyperlink August 5, 2004, 8:31 am
WriteExcel->sheets() fails in getting worksheets May 5, 2008, 7:38 pm
WriteExcel module set_row and set_column to group by both January 20, 2005, 2:40 pm
GD not working September 13, 2004, 2:52 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap