Ya I am using

use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; use Spreadsheet::ParseExcel::Workbook;
because with when I start reading I saw that Spreadsheet::ParseXLSX an adaptor from Spreadsheet::ParseExcel . When I got error I think its necessary and included it. Note the modules above are parsers, not writers Then How its working here.

Here is the program which taking the data from DB and opening template(.xls) and writing the DB data into it using Spreadsheet::ParseExcel

#!/usr/bin/perl use DBI; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; #use Spreadsheet::Read; $date=$ARGV[0];#yyyy-mm-dd $month=$ARGV[1];#August $date or $date=`date --date='1 day ago' +%Y-%m-%d`; $month or $month=`date --date='1 day ago' +%B`; chomp $month; chomp $date; print "Month:$month\n"; $Database_name="Busy_Hour_Report"; $IP_address="xxx.xx.xx.xxx"; $command = "cp /root/prac/packages/B_Mum_Busy_hour_report_fdb.xls /roo +t/prac/packages/B_Mum_Busy_hour_report_fdb_$date.xls"; print $command; `$command`; my $dbh = DBI->connect("DBI:mysql:database=$Database_name;host=$IP_add +ress;mysql_socket=/opt/lampstack-5.5.27-0/mysql/tmp/mysql.sock","root +","", {'RaiseError' => 1}); #--------------------------------------------------------------------- +------------------------------------# #--------------------------------------------------------------------- +------------------------------------# sub parser_excel { my $sql_comm=$_[0]; my $sheet_no=$_[1]; #Selecting the data to fetch my $sth = $dbh->prepare("$sql_comm"); $sth->execute() or die $DBI::errstr; # Open an existing file with SaveParser my $parser = Spreadsheet::ParseExcel::SaveParser->new(); my $template = $parser->Parse("B_Mum_Busy_hour_report_fdb_$dat +e.xls"); # Get the first worksheet. my $sheet = $template->worksheet($sheet_no); my $row = 5; my $col = 1; while (my @row = $sth->fetchrow_array()) { foreach my $value (@row) { $sheet->AddCell( $row, $col, $value ); ++$col; } $row++; $col=1; } $template->SaveAs("B_Mum_Busy_hour_report_fdb_$date.xls"); } parser_excel("Select * from Busy_Hour where monthname(Date)='$month' O +RDER BY Date DESC",0); parser_excel("Select * from Hourly_Data where monthname(Date)='$month' + and Hour in (21,22,23) ORDER BY Date DESC",1); parser_excel("Select * from Hourly_Data where Date='$date' order by Ho +ur",2);

In reply to Re^2: Modules for xlsx files by ravi45722
in thread Modules for xlsx files 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.