Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Problem opening WriteExcel generated spreadsheets with OLE

by jrsimmon (Hermit)
on Mar 03, 2010 at 21:04 UTC ( [id://826528]=note: print w/replies, xml ) Need Help??


in reply to Problem opening WriteExcel generated spreadsheets with OLE

The problem has nothing to do with how the spreadsheet is generated. When using your code
use strict; use warnings; use 5.010; #use Spreadsheet::WriteExcel; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn=3; my $Excel=Win32::OLE->GetActiveObject('Excel.Application')|| Win32::OLE->new('Excel.Application', 'Quit'); my $book=$Excel->Workbooks->Open("./test.xls"); my $sheet=$book->Worksheets(1);
I get the same error on a spreadsheet I created myself with Excel 2003. Using the slightly modified code
use strict; use warnings; use 5.010; #use Spreadsheet::WriteExcel; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn=3; my $Excel=Win32::OLE->GetActiveObject('Excel.Application')|| Win32::OLE->new('Excel.Application', 'Quit'); my $book=$Excel->Workbooks->Open("c:\\data\\temp\\test.xls"); my $sheet=$book->Worksheets(1);
it opens the workbook just fine.

Replies are listed 'Best First'.
Re^2: Problem opening WriteExcel generated spreadsheets with OLE
by vassago (Novice) on Mar 03, 2010 at 21:50 UTC
    Well, crap, that works. The weird thing is, with the same exact code in the same folder, it would open one Excel file with the './' path, but not the others. Oh well. Thanks for clearing that up for me!

      Context, young one! Context!

      Internally, on Win32 (<==a context), Perl sees './test.xls', "./test.xls", '.\test.xls', and ".\\test.xls" as the same thing. But if you pass a pathname to something else (oh, say, part of the Windows API known as OLE, another context...), you need to make sure that thing will understand what you mean.

      To the Windows API, OLE, MS-Office, etc and so forth, "./test.xls" has no meaning.

      Capiche?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://826528]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2025-02-08 23:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (95 votes). Check out past polls.