web blazonry web development scripts and tutorials Get best price on Prepaid Samsung Galaxy A10e
   PHP       Name Generators       Perl       CSS       Javascript       Java       MySql       How Tos       Resources   

Perl Home

Perl Scripts
  Count Links
  Mail to MySQL
  ProcLog Files
  Search and Replace
  Site Monitor
  UnTabify

Perl Articles
  csv2htm Converter
  OLE Automation
  Regular Expressions
  SubDir Recursion

Perl Resources
  Regular Expressions Quick Reference
  Regular Expressions Examples
  Recommended Sites
  Bestselling Perl Books
  Free Perl Books (new)
  Free Python Books(new)

Bookmark and Share




Perl: OLE Automation and Microsoft Excel

Perl for Win32 comes with the OLE.pm module. This module lets you program Perl scripts to communicate with OLE objects, such as Microsoft Excel. This means you can write a Perl script that can add data, get data, and even create charts in a Microsoft Excel file.

The following example shows how to open a Microsoft Excel file and read values from cells in a worksheet.

use OLE;

$xlfile ="c:\\filename.xls";

##### OLE - Excel Connection

# Create OLE object - Excel Application Pointer
$xl_app = CreateObject OLE 'Excel.Application' || die $!;

# Set Application Visibility
# 0 = Not Visible
# 1 = Visible
$xl_app->{'Visible'} = 0;

# Open Excel File
$workbook = $xl_app->Workbooks->Open($xlfile);

# setup active worksheet
$worksheet = $workbook->Worksheets(1);

# retrieve value from worksheet
$cellA1 = $worksheet->Range("A1")->{'Value'};
$cellB1 = $worksheet->Range("B1")->{'Value'};

# Close It Up
$xl_app->ActiveWorkbook->Close(0);
$xl_app->Quit();

 

Related Links for Perl OLE Automation:

Perl CPAN Win32::OLE documentation

"Perl In a Nutshell" Chapter on OLE Automation

Perl Win32 FAQs

Working with Microsoft Excel Objects   I'm not sure if this is the best link. Microsoft continually moves their stuff around and makes it difficult to link to.

 

Newest Pages
Test Google Ads Ver. 2
Free Linux Admin Books
Free Linux Books for Programmers
Free Books for Linux on the Desktop
Free PHP Books
Free JavaScript Books
Free Java Books - Advanced
Free Java Books - Basic
Free Perl Books
Free Python Books
Quote of the Day (PHP)
Debugging Part 2
How to Test Google Ads
Most Popular Pages
Baby Name Generator
U.S. Name Generator
Wu Name Generator
Popup Windows (JavaScript)
Upload and Resize an Image (PHP)
How To Install Apache + PHP + MySQL
Intro to Web Databases (PHP, MySQL)

Least Popular Pages
iNews Applet (Java)
Java Resources
Site Monitor (Perl)
PHP Resources
 
 

  privacy policy     ||     © 1997-2016. astonishinc.com   All Rights Reserved.