473,387 Members | 1,790 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,387 software developers and data experts.

Perl OLE Open Existing Workbook & Worksheet

Hi Friends,
I am trying to open particular Worksheet from MS Excel workbook (WIN32 :: OLE).

I cannot able to work on particular sheet. Please help me on this :

Expand|Select|Wrap|Line Numbers
  1. $Excel = Win32::OLE->GetActiveObject('Excel.Application');
  2. $Excel->{'Visible'} = 0;    
  3. $Excel->{DisplayAlerts}=0;    
  4.  
  5. # Open File and WorkSheet    
  6. $Book = $Excel->Workbooks->Open("d:\test.xls");         
  7. $Sheet = $Book->WorkSheets(1)->{marks};     
  8. $Sheet = $Book->WorkSheets($Sheet);
  9. $Sheet->Activate;
  10.  
  11. $LastRow = $Sheet->UsedRange->Find({What=>"*",   SearchDirection=>xlPrevious,    SearchOrder=>xlByRows})->{Row};
  12. $LastCol = $Sheet->UsedRange->Find({What=>"*",   SearchDirection=>xlPrevious,    SearchOrder=>xlByColumns})->{Column};
  13.  
  14. $mylastcol = 'A';    
  15.  
  16. for ($m=1;    $m < $LastCol;    $m++){
  17.         $mylastcol++;            
  18. }
  19.  
  20. print "Last Row in Sheet $ARGV[2] : $LastRow, Last Col : $LastCol\n";
  21. $_    =    $Sheet -> Range("A7") -> {Value};
  22. print "Value of Test Cell : $_ \n";
  23.  
  24. $Book->Close();
  25. $Excel->Quit();
  26.  
Please point me what went wrong. Its giving Error at $sheet->Activate itself!!

One More thing : If i want to print content of the cells, i am storing it in $_ and printing it. Is there is other way to print content of cells within 'Print' Statement?
Apr 11 '11 #1
1 4118
miller
1,089 Expert 1GB
I never play around with Win32::OLE but instead use Spreadsheet::ParseExcel and Spreadsheet::WriteExcel.

Here's a tutorial on Win32::OLE that might help though: http://search.cpan.org/~gsar/libwin3...ICROSOFT_EXCEL
Apr 13 '11 #2

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

Similar topics

2
by: Xah Lee | last post by:
© # -*- coding: utf-8 -*- © # Python © © # in Python, one can define a boxed set © # of data and functions, which are © # traditionally known as "class". © © # in the following, we define a...
1
by: Lize | last post by:
Hi, I'm writing an ASP application to open an excel workbook, then run a macro stored in the excel file, which produces outputs that will be displayed back onto my ASP application. Now the...
3
by: Kimmo Laine | last post by:
Hi, one stupid question? How can i be sure that i have valid queue: using System; using System.Messaging; // . . . MessageQueue q = new MessageQueue( ".\\Private$\\myQueue" );
1
by: Joe Cletcher | last post by:
It's got to be simple, but there doesn't seem to be an "open" method for opening an existing Excel spreadsheet in a VB.Net. What do I do after the following? Dim myExcel As...
3
by: csgraham74 | last post by:
Hi guys, just wondering if anyone could - help me work out how to open an existing spreadsheet in excel and write to it then save it. I have some code that opens a new worksheet everytime but...
2
by: Sheshadrinath R | last post by:
Hello, I want to open an excel workbook, which is present in the server. I want to open this excel in the browser using ASP.NET. May I know, how can I do this? Will the File.Open() command work...
2
by: k-w | last post by:
Hi all In vb I do: Dim Ex As New Excel.Application Ex.Workbooks.Open "c:\tmp\Book1.xls" Similar code in VC doesn't work:
4
by: pablocruise77 | last post by:
We have two Perl script that use the open command to read an encrypted file. We just changed from gzip to gpg. One script works fine. The other is called from the web and fails on the open. ...
3
by: samj | last post by:
Looking at code examples, it would seem this is simple, but I can't figure it out. From an Access 2000 form command button, I want to copy all worksheets in an existing workbook to an existing...
1
by: attraankit | last post by:
hi, i am just a newbie in asp world.please tell me how to open an excel workbook using asp and also please tell me what should be the sequence of code while editing html scripts for including asp...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.