ravi45722 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Open a file in append mode
by Corion (Patriarch) on Aug 11, 2015 at 12:16 UTC | |
by ravi45722 (Pilgrim) on Aug 11, 2015 at 12:41 UTC | |
by Corion (Patriarch) on Aug 11, 2015 at 13:35 UTC | |
by ravi45722 (Pilgrim) on Aug 12, 2015 at 03:35 UTC | |
by afoken (Chancellor) on Aug 12, 2015 at 19:08 UTC | |
by Corion (Patriarch) on Aug 12, 2015 at 06:44 UTC | |
by poj (Abbot) on Aug 11, 2015 at 13:21 UTC | |
|
Re: Open a file in append mode
by chacham (Prior) on Aug 11, 2015 at 13:25 UTC |