Perl interaction with Office apps

07-10-2002, 04:51 PM
OK, so here I am at the absolute beginning of my (probably brief) Perl programming career.

Perl is in play in my life because I want to feed info from a shared Excel spreadsheet into a webpage.

Not to get ahead of myself (I mean I'm still learning $ vs @ and % etc), but can someone sketch out for me, vaguely, how a Perl program can extract data from programmer-designated cells in the spreadsheet, into, say, a scalar or better yet an array?

Does Perl have this capability? Would it work better with Access than with Excel?


Too confused and dizzied by what's ahead of me over here.

Derek Stone
07-10-2002, 05:55 PM
If Perl supports COM then its possible to extract data from an Access or Excel file via their associated objects. Otherwise you'll be forced to use SQL to extract the information from a database of your choosing, which in any case, is a better solution.


07-10-2002, 06:12 PM
I never tried with Excel, Here's a dust-collecting sample with Access...

# lists entries in a database.

print <<EOF
Content-type: text/html

<head><title>Company DataBase</title></head>
<center><table border>
<th>Part Number</th><th>Description</th><th>Price</th>

use Win32::ODBC;
$db = new Win32::ODBC("myDSN");
$db->Sql("SELECT * FROM Items Order by PartNumber");
while ($db->FetchRow()) {
my(%record) = $db->DataHash();
print "<tr><td>$record{'PartNumber'}</td>";
printf "<td>%-23s</td>", $record{Description};
printf "<td>%.2f</td></tr>", $record{Price};
print "</center></table></body></html>";

07-11-2002, 12:54 PM
Ok, so...ah (ahem) er...(meekly now): What is COM?

07-11-2002, 02:28 PM
Component Object Model. All ActiveX components are COM
objects, so access to either Excel or Dataaccess objects means
being able to interact with COM/ActiveX objects. Something that
isn't native in Perl, but Robby's example shows using a library that
seems to know how to do it.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum