#!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


In reply to Re^4: Trying to modify multisheets using Spreadsheet::ParseExcel::SaveParser by ravi45722
in thread Trying to modify multisheets using Spreadsheet::ParseExcel::SaveParser by ravi45722

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.