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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rssd
    New Member
    • Jul 2007
    • 1

    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_datase ts\exp.pl line 4
    Win32::OLE(0.16 ): GetOleTypeLibOb ject() Not a Win32::OLE::Typ eLib object at C:/Perl/site/lib/Win32/OLE/Const.pm line 45.
    Died at D:\Genes_datase ts\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

    [CODE=perl]
    use strict;
    use Win32::OLE;
    use Win32::OLE qw(in with);
    use Win32::OLE::Con st 'Microsoft Excel';
    # get already active Excel application or open new
    my $Excel = Win32::OLE->GetActiveObjec t('Excel.Applic ation')|| die;

    # storing the names of excel files present in the folder
    my $dir="D:/Genes_datasets/";
    opendir (DH, $dir) or die "cannot open the $dir !!!";
    my @dir_files=read dir DH;
    closedir DH;
    my @excel_files=gr ep(/.xls/,@dir_files);
    #print "@excel_files\n ";

    # reading all excel files
    foreach (@excel_files) {
    open Excel file
    my $excelfile=$dir .$_;
    print "$excelfile \n";
    my $book = $Excel->Workbooks->Open($excelfil e);
    my $sheet= $book->Worksheets("Sh eet1");
    $sheet->Activate();
    my $rowval = $sheet->Range("a1")->{Value};
    print "$_\t$rowval\n" ;
    }
    [/CODE]
    Last edited by miller; Jul 23 '07, 06:38 PM. Reason: Code Tag and ReFormatting
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    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

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      Originally posted by rssd
      i don't ve microsoft excel but open office installed,
      what is open office?

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        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

        Comment

        • KevinADC
          Recognized Expert Specialist
          • Jan 2007
          • 4092

          #5
          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.

          Comment

          • dilipkvarma
            New Member
            • Jul 2007
            • 8

            #6
            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

            Comment

            • HaoRan
              New Member
              • Aug 2023
              • 1

              #7
              If you have installed excel, see if you are using a 64-bit version, if so, please add a win32 registry, the same content as win64.

              Registry position: \HKEY_LOCAL_MAC HINE\SOFTWARE\C lasses\TypeLib\ {00020813-0000-0000-C000-000000000046}\1 .9\0\win32

              Comment

              • dew075732
                New Member
                • Aug 2023
                • 2

                #8
                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

                Comment

                • EggyUen
                  New Member
                  • Aug 2023
                  • 1

                  #9
                  It works! I also found the win32::ole error for my software after windows system upgrading. It seems the operation delete excel registry of Win32. With HaoRan‘s suggestion, I finally fix the glitch.

                  Comment

                  Working...