Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks. I have written working code with perl5.003 which reads data from an excel spreadsheet using the OLE perl module. The client, however, will be running this script from a server machine where they will *NOT* be installing excel (no executables allowed). So my question is this: Are there ways to run the OLE without excel installed? does anyone know if there exists a library or a 'thin' instance of excel in which the OLE stuff will still work? tia, michael

Replies are listed 'Best First'.
Re: excel and OLE
by dws (Chancellor) on Nov 25, 2002 at 16:41 UTC
    Are there ways to run the OLE without excel installed?

    Short answer: It depends on what you mean by "run".

    Longer answer:
    When you read data from an Excel spreadsheet via OLE, you first, via OLE, create instances of Excel components. These same components are used when you use the Excel GUI. No components, no access to Excel via OLE.

    However, the format of an Excel spreadsheet has been reverse engineered. Spreadsheet::WriteExcel is a platform-independent way to create Excel spreadsheets. There may be platform-independent ways to read them (Spreadsheet::ParseExcel might be such a way -- I haven't looked at it.)

    Try searching CPAN for "Excel".

Re: excel and OLE
by jmcnamara (Monsignor) on Nov 25, 2002 at 17:36 UTC

    Does anyone know if there exists a library or a 'thin' instance of excel in which the OLE stuff will still work?

    This is a question that comes up from time to time in some of the Excel programming goups. The answer to date has always been no.

    Apart from Spreadsheet::ParseExcel, suggested above, you can also read an Excel file using ADO or ODBC (through DBI). There are some other suggestions here.

    --
    John.

Re: excel and OLE
by Mr. Muskrat (Canon) on Nov 25, 2002 at 16:35 UTC
Re: excel and OLE
by t0mas (Priest) on Nov 26, 2002 at 08:15 UTC
    If starting Excel on _another_ Win32 box is an option, you can try the following stunt.
    use Win32::OLE; my $excel = Win32::OLE->new(['172.16.12.100','Excel.Application']) or die "Can't start excel: $!"; my $workbook = $excel->Workbooks->Open('c:\test.xls') or die "Can't open file: ",Win32::OLE->LastError(); my $sheet = $workbook->Worksheets(1) or die "Can't open sheet: ",Win32::OLE->LastError(); my $everything=$sheet->UsedRange()->{Value} or die "Can't get range: ",Win32::OLE->LastError(); for (@$everything) { for (@$_) { print defined($_) ? "$_|" : "<undef>|"; } print "\n"; } $excel->Quit;
    This code will start Excel on 172.16.12.100 (a box with MS Office installed) using DCOM and open the file c:\test.xls (c:\test.xls on 172.16.12.100 !!!) and print a delimited output of the first worksheet.

    Can't think of a thinner way to do it ;-)

    /brother t0mas