Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Perl script extracting data from Excel

Avatar of drezner7
drezner7 asked on
Perl
9 Comments1 Solution2060 ViewsLast Modified:
I have written a Perl script to go out to the web open an excel spreadsheet and copy all the contents from Column 1 from rows 1 - 70 and then extract the data and print it to a notepad in this manner ' $Value','$Value', ... and so on. When I run my perl script it only pulls the first row and prints it. Can someone tell me what did I do wrong here is the code:

#!/usr/bin/perl -w

use warnings;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';

$Win32::OLE::Warn = 3;                                # die on errors...

# get already active Excel application or open new
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
    || Win32::OLE->new('Excel.Application', 'Quit');  

# open Excel file
my $Book = $Excel->Workbooks->Open("http:/6.1 (April 10, 2010)/3 - Content (Build Lists)/Release 6.1 - R2 PT Build Listing 030410.xls");

# You can dynamically obtain the number of worksheets, rows, and2 columns
# through the Excel OLE interface.  Excel's Visual Basic Editor has more
# information on the Excel OLE interface.  Here we just use the first
# worksheet, rows 1 through 80 and columns 1.

# select worksheet number 1 (you can also select a worksheet by name)
my $Sheet = $Book->Worksheets(1);



#print out the contents of a cell  
#printf "At ($row, $col) the value is %s and the formula is %s\n",
#$Sheet->Cells($row,$col)->{'Value'},
#$Sheet->Cells($row,$col)->{'Formula'};        
 
#Open the output file.
open(OUTPUT_FILE,">output.txt");


foreach my $row (1..70)
{
   foreach my $col (1)
   

{
     
      $value = $Sheet->Cells($row,$col)->{'Value'}
   }
         # Print the value to the file.
         
  {
 print {OUTPUT_FILE} ("\' $value\',");
   
}
      # End of the line, put a new line in.
{
   print{OUTPUT_FILE}("\n");
   }

close(OUTPUT_FILE);
#REMNANCE OF PREVIOUS LOOP. # # # # # # # # # # # # # #

# clean up
}$Book->Close;
ASKER CERTIFIED SOLUTION
Avatar of Nem Schlecht
Nem SchlechtFlag of United States of America imageIT Engineering Manager
Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answers