471,887 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

Win32::OLE error - No type library matching "Microsoft Excel" found

can somebody help me. I'm trying to read some excel files but i'm always getting this error

No type library matching "Microsoft Excel" found at D:\Genes_datasets\exp.pl line 4
Win32::OLE(0.16): GetOleTypeLibObject() Not a Win32::OLE::TypeLib object at C:/Perl/site/lib/Win32/OLE/Const.pm line 45.
Died at D:\Genes_datasets\exp.pl line 6.

i don't ve microsoft excel but open office installed, i think that could be a problem. But these files ve been saved in microsoft excel 97/2000/XP format

my code is

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use Win32::OLE;
  3. use Win32::OLE qw(in with);
  4. use Win32::OLE::Const 'Microsoft Excel';
  5. # get already active Excel application or open new
  6. my $Excel = Win32::OLE->GetActiveObject('Excel.Application')|| die;
  8. # storing the names of excel files present in the folder
  9. my $dir="D:/Genes_datasets/";
  10. opendir (DH, $dir) or die "cannot open the $dir !!!";
  11. my @dir_files=readdir DH;
  12. closedir DH;
  13. my @excel_files=grep(/.xls/,@dir_files);
  14. #print "@excel_files\n";
  16. # reading all excel files
  17. foreach (@excel_files) {
  18.     open Excel file
  19.     my $excelfile=$dir.$_;
  20.     print "$excelfile\n";
  21.     my $book = $Excel->Workbooks->Open($excelfile);
  22.     my $sheet= $book->Worksheets("Sheet1");
  23.     $sheet->Activate();
  24.     my $rowval = $sheet->Range("a1")->{Value};
  25.     print "$_\t$rowval\n";
  26. }
Jul 23 '07 #1
5 16288
3,503 Expert Mod 2GB
Unfortunately I don't have experience trying to read Excel files with Perl, but wonder if Excel should be installed for this to work? You may be correct in that assumption. If you can install it, it couldn't hurt to try it. If it works, let us know.


Jul 23 '07 #2
4,059 Expert 2GB
i don't ve microsoft excel but open office installed,
what is open office?
Jul 23 '07 #3
3,503 Expert Mod 2GB
Open Office is the open source "equivelant" of M$ Office. It is available on a number of platforms and now comes standard with many Linux distributions. I use it exclusively on my Linux machines as it is able to easily read and write M$ Office files, at least I haven't had any issues.

Unfortunately, I wonder if he/she is correct that the module is looking for and calling something(s) from the Excel installation.


Jul 23 '07 #4
4,059 Expert 2GB
Seems obvious, if they don't have Excel installed they can't try and use it to process the file.

On the other hand, there appears to be a number of Open Office modules posted on cpan.
Jul 23 '07 #5
It is very obvious.

The Win32:OLE module allows your code to talk to any MS Windows OLE application that is available on the system from where you are running your code.

This clearly indicates that
* You must be running your code from an MS Windows machine
* You must have the OLE application (in this case Excel) setup on your machine

An easier solution would be to write the data in a comma seperated value (csv) format into a file with .csv extension and then open it in any spreadsheet program

Hope this helps

Jul 25 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by lialie | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.