473,850 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Spreadsheet::Wr iteExcel


there's a module called Spreadsheet::Wr iteExcel. It allows me to create
a new worksheet and edit its cells:

my $workbook = Spreadsheet::Wr iteExcel->new('my.xls' );
my $worksheet = $workbook->addworksheet() ;
$worksheet -> write('A2', 222);

But how can I put some values into the cells of an existing worksheet?
Thanks for any advice.

...:: fabio

Jul 19 '05 #1
2 7387
Fabio <fa***@anti-spam.inet.alpha .pl> wrote in message >
But how can I put some values into the cells of an existing worksheet?
Thanks for any advice.

Use either Spreadsheet::Pa rseExcel::SaveP arser for rudimentary changes
to existing workbooks. If you need to do complex stuff, it may
(unfortunately) be easier to use OLE to do it.

Jul 19 '05 #2
Fabio <fa***@anti-spam.inet.alpha .pl> wrote in message news:<c2******* ***@nemesis.new s.tpi.pl>...

there's a module called Spreadsheet::Wr iteExcel. It allows me to create
a new worksheet and edit its cells:

my $workbook = Spreadsheet::Wr iteExcel->new('my.xls' );
my $worksheet = $workbook->addworksheet() ;
$worksheet -> write('A2', 222);

But how can I put some values into the cells of an existing worksheet?
Thanks for any advice.

..:: fabio

Dunno Spreadsheet::Wr iteExcel.
Here is sth I wrote recently using Win32::OLE
#for OLE automation
use Win32::OLE;
use Win32::OLE::Con st "Microsoft Excel";
use Win32::OLE 'in';
use Win32::OLE::Var iant;
#get current directory
use Cwd;

#writes array of changes to existing excel spreadsheet as new excel spreadsheet
# input_file - name of existing Excel spreadsheet
# output_file - name under which changed file is to be save under (SaveAs option)
# change_array_re f - reference to array of changes - (row \t column \t new value)

sub write_changes_i nto_excel_file
#name of existing Excel spreadsheet
my $input_file = shift;
#name under which changed file is to be save under (SaveAs option)
my $output_file = shift;

#reference to array of changes - (row, column, new value)
my $change_array_r ef = shift;

my $dir = cwd();
my $fullname_input _file = $dir.'/'.$input_file;
my $fullname_outpu t_file = $dir.'/'.$output_file;

#check if input file exists in first place
unless(-f $fullname_input _file)
print STDERR "Input file: $fullname_input _file does not exists.\n";

# use existing instance if Excel is already running
$excel = Win32::OLE->GetActiveObjec t('Excel.Applic ation')
die "Excel not installed" if $@;

unless (defined $excel)
$excel = Win32::OLE->new('Excel.App lication', 'Quit')
or die "Oops, cannot start Excel";
#to avoid excessive dialogs when saving in non-Excel format
$excel->{DisplayAlerts } = 0;

my $wbook;
if($wbook = Win32::OLE->GetObject($ful lname_input_fil e)){;}
#the failure og GetObject is potentially due to the fact
#that file $fullname_input _file is already opened.
#In such case we need to find workbook that corresponds
#to already opened file and if we cannot we print error
#message and exit.
my $wbooks = $excel->Workbooks();
my $name = Variant($fullna me_input_file);
$wbook = $wbooks->{"$name"};
print STDERR "Could not open the file $fullname_input _file: $!\n";

# write to a particular cell
my $wsheet = $wbook->Worksheets(1 );

my $line;
my $cell_value;
my $row_num;
my $col_num;
my $do_next;
foreach $line (@{$change_arra y_ref})
= split("\t",$lin e);

$row_num =~ s/\s//g;
$col_num =~ s/\s//g;

$wsheet->Cells($row_num ,$col_num)->{Value} = "$cell_valu e";
$wsheet->Cells($row_num ,$col_num)->Select();

$wbook->SaveAs($fullna me_output_file) ;
undef $wbook;
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Dorthe Luebbert | last post by:
Hi, there is a new(er) version of John McNammara's Excel package for Perl: http://homepage.eircom.net/~jmcnamara/perl/prerel/Spreadsheet-WriteExcel-0.49.7.tar.gz The package writes Excel97 instead of Excel5, it has e.g. no longer the 255 char's limit for one cell etc. See:
by: FSD | last post by:
I am using the Spreadsheet-WriteExcel-211 module to write values into a spreadsheet. The module is very powerful and robust, but there is one thing that I cannot seem to do. I need to open a spreadsheet daily and write values to it. Not a problem, but I do not know how to append to a sheet. That is, I do not know how to find the last row in the sheet and then simply write to $lastrow+1. Does anyone have an idea how I can do this? Thanks...
by: tito | last post by:
I am using Active Perl for running perl programs.I am finding difficulty in installing Spreadsheet::WriteExcel,Spreadsheet:ParseExcel to the machine for writing a program which will retrieve data from an Excel Sheet. Can anyone explain me the steps to install Spreadsheet::WriteExcel,Spreadsheet:ParseExcel in Windows machine.
by: tito | last post by:
I would like to write a program which will retrieve the data from the EXCEL file and write into an SQL Server using Perl script.Spreadsheet::WriteExcel programs are working fine.But while executing Spreadsheet::ParseExcel i am getting the error like Can't locate Spreadsheet/ParseExcel.pm in @INC (@INC contains: D:/Perl/lib D:/Pe rl/site/lib .) at parse.pl line 5. I used the following program.Can anyone tell me whether the problem arise...
by: rasmitasah25 | last post by:
hi, I am very new to perl.I have written a perl script which is writing data into an excel file.The problem is that it is creating one new excel file while executing but my need id to write into an existing .xls file. currently I am using: my $workbook = Spreadsheet::WriteExcel::Big->new("file.xls"); for that which method Should I use?? can anyone please help me... Thanks
by: bvithya | last post by:
Hi Gurus, I am in need of your guidance. I have installed Perl5.8.8 on my server running with SunOS 5.8 and then I installed Spreadsheet::WriteExcel perl module. It has been installed successfully. Howver when I try to run a command to check whether it emails an excel sheet or not, it showed me the below. # /home/oracle8/oradba/admin/utils/sqlplus2xls/sqlplus2xls.pl ERROR (Missing Parameter): <config_file> not specified!
by: Perl Beginner | last post by:
I am using Win32. I have created an excel spreadsheet, formatted the columns and rows, and would like to write to the cells…all of this using Spreadsheet::WriteExcel. My issue is, my script is very vast with a lot of subroutines, but I need the excel spreadsheet created in the main subroutine becasue this is where the data is that i want to capture. So if I create and format the spreadsheet within the main subroutine, and as it loops through,...
by: lavsaxena | last post by:
Can we edit a worksheet of excel through spreadsheet::writeExcel. Because when I am using my $workbook = Spreadsheet::WriteExcel->new('D:\test_result.xls'); this statement is creating the excel file again. I want to update an excel sheet means if the some data already exist, the new data should be append to it... Thanks in Advance -Lav
by: somsub | last post by:
Hi, When I tried to open excel sheet created by below code with MSexcel it showing "Unable to read file " error . use Spreadsheet::WriteExcel; $workbook = Spreadsheet::WriteExcel->new("sm2.xls"); I am using winxp OS and MS excel 2003 ....
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.