in reply to Win32::OLE and Excel

I ran your code, and I am able to open the file in NT with no problems. I tried:
  1. Open Excel, open file from menu (and tool bar). OK
  2. Double-click on file in folder. OK
  3. Move file to desktop, double-click. OK
  4. Drag file onto Excel icon to open. OK

I'm running NT4 SP4 with Office 97, so I don't know how your specific setup differs. Since it seems to work for me, my best guess would be that somehow something's goofy with your Excel setup. I know that file associations and such get mangled at random. If you have more specific errors, maybe I can test some more.
Update: Somehow I missed the last two lines in your test script. Adding those lines makes goofy stuff happen. I get these errors:
retrying default method at D:/Perl/site/lib/Win32/OLE/Lite.pm line 156 +. Can't call method "Add" on an undefined value at D:/Perl/site/lib/Exce +l 36. retrying default method at D:/Perl/site/lib/Win32/OLE/Lite.pm line 156 +. retrying default method at D:/Perl/site/lib/Win32/OLE/Lite.pm line 156 +.

Also, I get an Excel prompt asking if I would like to save "Book1". I've tried saying yes and no, but I get the same output - none. For some reason, neither .xls file is created.
If I have Excel running then run the script, both files are created and they're loaded right into Excel. Strange.

Guildenstern
Negaterd character class uber alles!

Replies are listed 'Best First'.
RE: (Guildenstern) Re: Win32::OLE and Excel
by nop (Hermit) on Sep 18, 2000 at 20:22 UTC
    Yeah, the simple solution will be to write only one output file... My problems, too, arose when I tried to have two books or more books under one instance of Excel... Sigh.
      Maybe you need to add an explicit Close that does the same thing as DESTROY. That way you could have one at a time open, which might avoid problems. As an example, I changed your test code to this:
      use Excel; { my $s = Excel->new("here.xls"); $s->print("one", "Hello World\nThis\tis\ta\ttest\n"); $s->print("one", join("\t", 1 ..10)); $s->print("one", "bye\n"); $s->print("one", join("\n",3 .. 5) . scalar(localtime)); $s->print("two", join("\n",13 .. 25) . scalar(localtime)); $s->print("eight", join("\n",13 .. 20) . scalar(localtime)); } { my $t = Excel->new("c:/temp/there.xls"); $t->print("two", join("\n",13 .. 25) . scalar(localtime)); }
      and it worked perfectly. (Notice the braces around the two sections.) Putting the sections in blocks like that forces DESTROY to be called before the next new is called.

      Guildenstern
      Negaterd character class uber alles!