473,382 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Opening Password Protected Excel file using Win32:OLE in Perl

Hi,
I need help to open a password protected excel file in perl using Win32:OLE.
when I tried to open file in normal way at the time of program execution it is prompting me to enter password.
I am giving the script i used for opening excel file..
So i want to know how to provide password parameter while opening the file.
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use Win32::OLE;
  3. use Win32::OLE::Const 'Microsoft Excel';
  4. use Win32::OLE::Variant qw(:DEFAULT nothing);
  5. $Win32::OLE::Warn = 3;
  6.  
  7. my $excelObj;
  8. my $fileName = "D:\\Mohan\\test.xls";
  9. $excelObj = Win32::OLE->new('Excel.Application', 'Quit');
  10. $excelObj->{'DisplayAlerts'} = 0;
  11. $excelObj->{'AskToUpdateLinks'} = 0;
  12. $excelObj->{'Visible'} = 0;
  13. my $bookObj;
  14. # If there is any problem in accessing files then auto mail will be sent.       
  15. eval
  16. {
  17.     $bookObj = $excelObj->Workbooks->Open($fileName);
  18. };
  19. if($@)
  20. {
  21.     my $msg = "";
  22.     die "A problem was encountered when accessing the file $fileName \n";
  23. }
  24. my $sheetObj = $bookObj->Worksheets(1);
  25. my $val    = $sheetObj->Cells(10,3)->{'Value'};
  26. print "Value == $val\n";
  27. $excelObj->ActiveWorkbook->Close(0);
  28. $excelObj->Quit();
  29.  
Thanks in Advance.
Dec 10 '07 #1
1 6121
numberwhun
3,509 Expert Mod 2GB
Hi,
I need help to open a password protected excel file in perl using Win32:OLE.
when I tried to open file in normal way at the time of program execution it is prompting me to enter password.
I am giving the script i used for opening excel file..
So i want to know how to provide password parameter while opening the file.
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use Win32::OLE;
  3. use Win32::OLE::Const 'Microsoft Excel';
  4. use Win32::OLE::Variant qw(:DEFAULT nothing);
  5. $Win32::OLE::Warn = 3;
  6.  
  7. my $excelObj;
  8. my $fileName = "D:\\Mohan\\test.xls";
  9. $excelObj = Win32::OLE->new('Excel.Application', 'Quit');
  10. $excelObj->{'DisplayAlerts'} = 0;
  11. $excelObj->{'AskToUpdateLinks'} = 0;
  12. $excelObj->{'Visible'} = 0;
  13. my $bookObj;
  14. # If there is any problem in accessing files then auto mail will be sent.       
  15. eval
  16. {
  17.     $bookObj = $excelObj->Workbooks->Open($fileName);
  18. };
  19. if($@)
  20. {
  21.     my $msg = "";
  22.     die "A problem was encountered when accessing the file $fileName \n";
  23. }
  24. my $sheetObj = $bookObj->Worksheets(1);
  25. my $val    = $sheetObj->Cells(10,3)->{'Value'};
  26. print "Value == $val\n";
  27. $excelObj->ActiveWorkbook->Close(0);
  28. $excelObj->Quit();
  29.  
Thanks in Advance.
To tell you the truth, I am not really sure how you would do this as I haven't played with Excel spreadsheets with Perl. I did check CPAN and it looks like the Spreadsheet::ParseExcel module has "ToDo" plans of implementing something to access protected Excel spreadsheets. It may behoove you to contact the author and see where he is with that. If he hasn't touched it, then if you get a solution in place to do so, it would be a good chance to publish either your first or another Perl module.

Regards,

Jeff
Dec 10 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: harshan | last post by:
Hi I am trying to read required worksheet from excel file using perl with module spreadsheet::parseexcel and spreadsheet::writeexcel but I am unable to read it, the error I am getting is...
2
by: Vinay Gupta | last post by:
Hi, In a Perl to Tcl conversion project, I am planning to use the following Tcl extensions as a replacement for some Perl libraries. My development environment is Windows. Win32::OLE --> "DDE"...
2
by: usenet | last post by:
Problem installing Win32::OLE under Cygwin. I have searched the web and found little documentation on installation procedure. Please help. I'd like to get Win32::OLE working under cygwin. ...
1
by: Kriston Scott | last post by:
I would like to know how to sort the rows in an Excel file, using Perl.
8
by: VinayKumarParakoti | last post by:
Hi all, I am new to this site and this is my first post. But this issue is of high priority. I am trying to print pdf file in browser using perl script. Onclick on hyperlink a child window...
3
by: rahatekarabhijeet | last post by:
I want to create excel sheet using perl, i had installed all the necessary modules from CPAN. The perl program i taken from CPAN itself it is given below, #!/usr/bin/perl -w use warnings; use...
5
by: John Randall | last post by:
Anybody got some sample code showing how to create a word doc and insert text plus images, such as .gif or jpg files? I'm new to Win32::OLE. Thanks in advance.
6
by: poolboi | last post by:
hi all, i've got the following program that needs yr help: use Win32::OLE; # use existing instance if Excel is already running eval {$ex =...
4
by: ravir81 | last post by:
Hi, I am currently working on excel validation using Perl. I am new to Excel validation but not for Perl. I have a question regarding one of the validation. Could anyone please tell me how to get...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.