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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |