By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,310 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,310 IT Pros & Developers. It's quick & easy.

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

P: 1
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;
  7.  
  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";
  15.  
  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. }
  27.  
Jul 23 '07 #1
Share this Question
Share on Google+
5 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
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.

Regards,

Jeff
Jul 23 '07 #2

KevinADC
Expert 2.5K+
P: 4,059
i don't ve microsoft excel but open office installed,
what is open office?
Jul 23 '07 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
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.

Regards,

Jeff
Jul 23 '07 #4

KevinADC
Expert 2.5K+
P: 4,059
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

P: 8
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

-Dilip
Jul 25 '07 #6

Post your reply

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