Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Trying to modify multisheets using Spreadsheet::ParseExcel::SaveParser

by Corion (Patriarch)
on Aug 12, 2015 at 09:11 UTC ( [id://1138290]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Trying to modify multisheets using Spreadsheet::ParseExcel::SaveParser
in thread Trying to modify multisheets using Spreadsheet::ParseExcel::SaveParser

Where does this new error message come from? Does your script still die with the error message you mentioned in the top thread?

Error: Can't call method "AddCell" on an undefined value at parse_exce +l.pl line 38

Please show us the exact source code you are running, and tell us the exact error message you get.

  • Comment on Re^3: Trying to modify multisheets using Spreadsheet::ParseExcel::SaveParser
  • Download Code

Replies are listed 'Best First'.
Re^4: Trying to modify multisheets using Spreadsheet::ParseExcel::SaveParser
by ravi45722 (Pilgrim) on Aug 14, 2015 at 07:22 UTC
    #!usr/bin/perl use DBI; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; $month=$ARGV[0]; $month or $month=`date --date='1 day ago' +%B`; chomp $month; print "Month:$month\n"; my $dbh = DBI->connect("DBI:mysql:database=MIS_Reports;host=172.16.15. +104;mysql_socket=/opt/lampstack-5.5.27-0/mysql/tmp/mysql.sock","root" +,"", {'RaiseError' => 1}); #--------------------------------------------------------------------- +------------------------------------# # Open an existing file with SaveParser my $parser = Spreadsheet::ParseExcel::SaveParser->new(); my $template = $parser->Parse('B_MUM_dashboard_month_latency_corrected +_FDB.XLS'); @tables=("MIS_Overall","MIS_P2P","MIS_P2A","MIS_A2P"); $sheet_no=0; foreach $table (@tables) { chomp $table; my $sth = $dbh->prepare("SELECT * from $table where monthname(Date +)='$month'" ); $sth->execute() or die $DBI::errstr; # Get the first worksheet. my $sheet = $template->worksheet($sheet_no); my $row = 2; my $col = 1; while (my @row = $sth->fetchrow_array()) { $col=1; foreach my $value (@row) { $sheet->AddCell( $row, $col, $value ); ++$col; } $row++; } $sheet_no++; } $template->SaveAs('B_MUM_dashboard_month_latency_corrected_FDB_12-08-2 +015.XLS');

    Error: Can't call method "worksheet" on an undefined value at parse_excel_multisheet.pl line 33

      This means that $template was not initialized properly. Check the return value of

      my $template = $parser->Parse('B_MUM_dashboard_month_latency_corrected +_FDB.XLS');

      like this

      my $filename = 'B_MUM_dashboard_month_latency_corrected_FDB.XLS'; my $template = $parser->Parse($filename) or die "Couldn't read '$filename': " . $parser->error;

      That way, you find out why your template was not initialized properly.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1138290]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found