#!usr/bin/perl #use strict; #use warnings; use DBI; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; use Spreadsheet::Read; 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}); #Selecting the data to fetch @tables=("MIS_Overall","MIS_P2P","MIS_P2A","MIS_A2P"); #my $sth = $dbh->prepare("SELECT * from MIS_P2P"); #my $dates=$dbh->prepare("select Date from MIS_Overall where monthname +(Date)='August'"); #$dates->execute() or die $DBI::errstr; # Open an existing file with SaveParser my $parser = Spreadsheet::ParseExcel::SaveParser->new(); my $template = $parser->Parse('B_MUM_dashboard_month_latency_corrected +_FDB.XLS'); #********************************************************************* +************************************# foreach my $MIS_SHEET (@tables) { # Get the first worksheet. my $sheet = $template->worksheet($MIS_SHEET); my $row_in = 2; my $col_in = 0; my $sth = $dbh->prepare("SELECT * from $MIS_SHEET"); $sth->execute() or die $DBI::errstr; while (my @row = $sth->fetchrow_array()) { ++$row; foreach my $value (@row) { $sheet->AddCell( $row, $col, $value ); ++$col; } } } $template->SaveAs('B_MUM_dashboard_month_latency_corrected_FDB_2015_08 +_01.XLS');

Here I have four sheets(@tables). I want to modify the four sheets. I tried upto here. But it showing an error. Error: Can't call method "AddCell" on an undefined value at parse_excel.pl line 38.

How can i insert new row in the middle of the sheet using this ParseExcel

In reply to 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.