in reply to Re: Win32 OLE painfully slow
in thread Win32 OLE painfully slow

use Win32::OLE;

Takes a second on my PC too (P4 1.7Ghz, 512MB memory). What takes most time is

use Win32::OLE::Const 'Microsoft Excel';

I want to use Excel because I want to save these charts so other people will be able to open them and analyze them, using no special purpose tools (only Excel).

Replies are listed 'Best First'.
Re: Re: Re: Win32 OLE painfully slow
by tachyon (Chancellor) on Apr 13, 2004 at 11:57 UTC

    Dunno what your problem is. This code:

    use Win32::OLE; use Win32::OLE::Const; my $xl = Win32::OLE::Const->Load("Microsoft Excel"); foreach my $const (sort keys %$xl) { printf "$const = %s\n", $xl->{$const}; #printf "sub $const { %d }\n", $xl->{$const}; }

    loads and prints all the constants in a couple of seconds. An ugly hack would be to hard code the constants. You could do this simply by using the code above to dump

    sub constname { NNN }

    Cut and paste the output into your code or your own constants module like Win32::OLE::Const::Excel. Leave the generator code there but comment it out. Net effect - you get the constants you need fast. If the constants change just rerun the generator and it will get updated. Not a perfect solution but quite a practical kludge.

    cheers

    tachyon

      It loads and prints all the constants in more than a minute for me (99% of it for loading).

      I'll try to dig into the suggestions other monks gave me (thanks !), but I must say that your kludge really does help, now everything works super fast. This only proves that the problem is in loading the constants.

      Thanks !