I want to edit a excel file without losing previous data

For that I try a code

#!usr/bin/perl #use warnings; #use strict; use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; use Spreadsheet::XLSX; use Spreadsheet::Read; use DBI; #use POSIX qw(strftime); 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 my $sth = $dbh->prepare("SELECT * from MIS_P2P"); $sth->execute() or die $DBI::errstr; my $file_path= "/root/prac/packages/B_MUM_dashboard_month_latency_corr +ected_FDB.XLS"; my $workbook = ReadData($file_path,cells => 0 ); if(defined $workbook->[0]{'error'}) { print "Error occurred while processing $file_path:".$workbook->[0] +{'error'}."\n"; exit(-1); } my $worksheet = $workbook->[1]; my $max_rows = $worksheet->{'maxrow'}; my $max_cols = $worksheet->{'maxcol'}; print "Rows : $max_rows\n"; print "Colomns : $max_cols\n"; while (my @row = $sth->fetchrow_array()) { my $excel_col=0; foreach my $value (@row) { $worksheet->write($max_rows+1,$excel_col,$value); $excel_col++; } }

But I am getting an error

Error: Can't call method "write" on unblessed reference at excel_write.pl line 48.

I install that Spreadsheet::WriteExcel several times but still it showing error. I am not getting where I missed it


In reply to Open a file in append mode 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.