Hi Alok,
   
  Hope the examples in the below links help your needs.
   
  For opening and reading an XL(Excel)
   
  use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3;                                # die on errors...
# get already active Excel application or open new
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
           || Win32::OLE->new('Excel.Application', 'Quit');
  # open Excel file
my $Book = $Excel->Workbooks->Open("test.xls");
my $Sheet = $Book->Worksheets(1);
# select worksheet number 1 (you can also select a worksheet by name)
my $Sheet = $Book->Worksheets(1);
  foreach my $row (1..4)
{
 foreach my $col (1..3)
 {
  # skip empty cells
  next unless defined $Sheet->Cells($row,$col)->{'Value'};
   # print out the contents of a cell
  printf "At ($row, $col) the value is %s and the formula is %s\n",
   $Sheet->Cells($row,$col)->{'Value'},
   $Sheet->Cells($row,$col)->{'Formula'};
 }
}
  # clean up after ourselves
$Book->Close;
   
  Refer the Below link...You can find More examples
  http://www.ibm.com/developerworks/library/l-pexcel/
   
  Regards,
  Prabu.M.A
   
  

alok nath <[EMAIL PROTECTED]> wrote:
  Hi,
Can anybody tell how to open an already existing xL file
and then probabaly do some processing using Win32::OLE
I found quite a few examples but none of them open an 
existing excel file.
Or is there some better module for XL processing ?
Here is my code ..
use strict ;
use warnings ;
use Win32::OLE;
use Win32::OLE::Const;
my $file = "Matrix.xls" ;
my $ex ;
eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')};
die "Excel not installed" if $@;
unless (defined $ex) {
$ex = Win32::OLE->new($file, sub {$_[0]->Quit;})
or die "Oops, cannot start Excel";
}
# get a new workbook
my $book = $ex->Workbooks->Add;
my $Sheet = $book->Worksheets(1);
$Sheet->{Name} = 'Candle';
$book->Close;




Thanks
Alok.



____________________________________________________________________________________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/

       
---------------------------------
Luggage? GPS? Comic books? 
Check out fitting  gifts for grads at Yahoo! Search.

Reply via email to