Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Opening Excel (OLE) with passwords

by rr_kreitzer (Novice)
on Jan 07, 2004 at 23:05 UTC ( #319647=perlquestion: print w/replies, xml ) Need Help??

rr_kreitzer has asked for the wisdom of the Perl Monks concerning the following question:

I am looking to parse a Password Protected Excel file. The password is known, and I can perform a similar function with VB, How can I do it with Perl?

Other Posts on this site show how to Open an Excel Object in with Perl using Win32 and required modules.
my $Book = $Excel->Workbooks->O­pen("test.xls");
Can you pass more than just filename during OLE open???

VB way to open an Excel Object
Xls = Workbooks.Open("test.xls", , , , "abc123")
where the empty variables represent data for Updating Links, Read Only, and Format.

Full VB Variables List
Workbooks.Open(TargetDoc, [UpdateLinks], [ReadOnly], Format], [Password], [WriteResPassword], IgnoreReadOnlyRecommended], [Origin], [Delimiter], [Editable], [Notify], [Converter], [AddToMru])
Similar for Word
thisDoc = Documents.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format, Encoding, Visible)
where PasswordDocument is the password required to open the document

Has anyone tried this before or can I get some direction please.

Thanks

Replies are listed 'Best First'.
Re: Opening Excel (OLE) with passwords
by sheep (Chaplain) on Jan 08, 2004 at 00:21 UTC

    Hello,

    Your answer is right in your question :)
    my $Book = Excel->Workbooks->Open( { FileName => 'test.xls', Password => 'abc123' } ) or die "Cant open excel file: $!";

    All attributes you pasted for Workbooks.Open are valid for opening excel file with Win32::OLE. You just use them as hash keys and values.

    In 318680 node I posted 2 links that might be useful.

    Hope that helps.
    -sheep

      do you know if you can do autofit from perl? I tried it eariler and it didn't translate very well from vb.
Re: Opening Excel (OLE) with passwords
by neuroball (Pilgrim) on Jan 08, 2004 at 00:21 UTC

    I haven't tried exactly this before... yet I did write my own excel/perl import/export function.

    What I learned is the following: The API is the same. Meaning: You can use the same commands and parameters. What this means for you is the following:

    Xls = Workbooks.Open ( $filename, undef, undef, undef, $password);

    Give this a spin, and if you have still problems, replace the undef's with emtpy strings.

    /oliver/

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://319647]
Approved by ysth
Front-paged by ysth
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2021-01-24 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?