The online documentation explains all this very clearly.  Also, the list
archives should have hundreds of messages where this topic is covered.

Here is a sample script that does very basic stuff:

  use strict;
  use Win32::OLE;
  use Win32::OLE::Const 'Microsoft Excel';
  
  my ($XlFile) = "C:\\TEST.XLS";
  
  my ($Range, $Excel, $Book, $Sheet);
  
  $Excel = Win32::OLE->new('Excel.Application', 'Quit')
      or die Win32::OLE->LastError;
  
  $Excel->{Visible} = 1;
  $Book = $Excel->Workbooks->Add;
  $Sheet = $Book->Worksheets(1);
  
  $Sheet->Range("A1")->{'Value'} = "People I owe money to:";
  $Range = $Sheet->Range("A1");
  $Range->{Font}->{Bold} = 1;
  
  $Sheet->Range("A3")->{'Value'} = "My Cousin Joey";
  $Sheet->Range("B3")->{'Value'} = 50.00;
  
  $Sheet->Range("A4")->{'Value'} = "My Brother Jim";
  $Sheet->Range("B4")->{'Value'} = 20.00;
  
  $Sheet->Range("A5")->{'Value'} = "My Sister Mary";
  $Sheet->Range("B5")->{'Value'} = 30.00;
  
  $Sheet->Range("A6")->{'Value'} = "Grand Total:";
  $Sheet->Range("B6")->{'Value'} = "=SUM(B3:B5)";
  
  $Range = $Sheet->Range("A6:B6");
  $Range->{Font}->{Bold} = 1;
  
  $Range = $Sheet->Range("B3:B6");
  $Range->{NumberFormat} = '$#,##0.00';
  
  $Book->SaveAs ({Filename => $XlFile,
                  FileFormat => xlNormal});
  exit;

-----Original Message-----
From: Huynh, Andy [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 24, 2001 11:58 AM
To: '[EMAIL PROTECTED]'
Subject: Need Help!!


Hi All!

Can someone tell me how can I use the Win32::OLE module to write some data
into an existed Excel file?
Thanks for your help and your time!

Andy Huynh

_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to