At 08:28 21-02-2001 +0530, [EMAIL PROTECTED] wrote:
>dear friends,
> i wan't to manipulate the datas in an already existing MS EXCEL
>Workbook. The code or any hints in all book does't give any idea for
>accessing the datas in an already existing EXCEL datas using OLE Extension.
>are u clear now. please let me to know.
Hi
There is a couple of examples in the docs
(<yourPerlDir>/html/site/lib/Win32/OLE.html) and in the PerlWin32FAQ
(<yourPerlDir>/html/faq/Windows/ActivePerl-Winfaq12.html) which can be
used. This one is a slightly modified example:
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
# uses the already open Excel application or opens one
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;});
# makes Excel visible
$Excel->{Visible} = 1;
# starts a new workbook
my $Book = $Excel->Workbooks->Add;
my $Sheet = $Book->Worksheets(1);
# sets the values in the range A2:C7
my $Range = $Sheet->Range("A2:C7");
$Range->{Value} =
[['Delivered', 'En route', 'To be shipped'],
[504, 102, 86],
[670, 150, 174],
[891, 261, 201],
[1274, 471, 321],
[1563, 536, 241]];
# fetches the values in the range A8:B9
my $array = $Sheet->Range("A4:B5")->{'Value'};
print "Values in the range A4:B5 are:\n";
foreach my $ref_array (@$array) {
foreach my $scalar (@$ref_array) {
print "$scalar\t";
}
print "\n";
}
# then saves the workbook
$Book->SaveAs('test.xls');
/Henning
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: OLE Extension VERY urgent. please
Henning Michael M�ller-Nielsen Tue, 20 Feb 2001 21:53:42 -0800
- OLE Extension VERY urgent. please ponnambalam . ma
- Henning Michael M�ller-Nielsen
