I am opening .xls template (template.xls) using

use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser;

after writing it my data into that i am saving it with

 SaveAs('updated.xls');

Like this i have a .xlsx template file. I need to open it without loosing previous data and write my data into it every day and close it in .xlsx format. For that I tried like this

#!/usr/bin/perl # # use strict; use warnings; use Spreadsheet::ParseXLSX; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; use Spreadsheet::ParseExcel::Workbook; use DBI; use POSIX qw(strftime); my $database = "ravi"; my $host = "XXX.XX.X.XXX"; my $username = "root"; my $table = "CDR"; my $dbh = DBI->connect("DBI:mysql:database=$database;host=$host;mysql_ +socket=/opt/lampstack-5.5.27-0/mysql/tmp/mysql.sock","root","", +{'RaiseError' => 1}); my $date=$ARGV[0]; $date or $date=`date --date='1 day ago' +%Y%m%d`; chomp $date; my $parser = Spreadsheet::ParseXLSX->new; my $template = $parser->parse("CDR.xlsx"); my $sth = $dbh->prepare("SELECT * from $table where Date='$date'"); $sth->execute() or die $DBI::errstr; my $sheet = $template->worksheet(2); my $row = 1; while (my @row = $sth->fetchrow_array()) { my $col=1; foreach my $value (@row) { $sheet->AddCell( $row, $col, $value ); ++$col; } $row++; } $template->SaveAs("CDR.xlsx"); print "Success";

But its showing an error

 Can't locate object method "SaveAs" via package "Spreadsheet::ParseExcel::Workbook" at ./parse_xlsx.pl line 43.

i am using linux. Cant use Win::OLE32

Thanks for any information


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