At the moment I am working on XP/Vista, Perl is installed on this system as is Excel 2007.
I also have access to UNIX although this is limted and not available at present.
Main Topics
Browse All TopicsI have just started to learn perl so I am a complete novice.
I have a basic excel table(which will be exported to mySQL eventually).
At the moment the table has columns for title,author, description, category and imageurl.
I would like a perl program which would take the existing .xls file, open it, and add 3 new columns called ID, Price, and Currentstock, and to have each of these columns populated with random numerical (1-9999 for ID, 1-50 for Price, and 0-200 for Currentstock) for each title listed in the title column.
I hope I have explained clearly, and thanks for your help.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thank you for that, although I have not got it working, Its probably something simple, I am currently getting the error
Can't call method "worksheets" on an undefined value at C:\.(path)\test.pl line 8
Sorry this is probably to with me being clueless at the moment for the most part when it comes to Perl.
yes the or die has been added, the message i get when i try to run it is could not open workbook.
I tried a different perl program, which opens up, creates a new workbook and adds some values, this worked fine, although this does not help me, for some reason the existing workbook is unable to be opened by the perl program.
Try this:
....
my $FileName = 'book1.xls'; #NOTE: This line is new
my $xl_app = CreateObject OLE 'Excel.Application' || die $!;
$xl_app->{'Visible'} = 0;
die "File does not exist, or is not readable\n" unless -r $FileName; #NOTE: This line is new
my $workbook = $xl_app->Workbooks->Open($
or die "Could not open workbook: $!\n"; #NOTE: This line is new
my $worksheet = $workbook->Worksheets(1);
...
Here is another change...
#!/usr/bin/perl -w
use strict;
use OLE;
my $FileName = 'c:\path\to\files\book1.xl
my $xl_app = CreateObject OLE 'Excel.Application' || die "Could not create app: $!";
$xl_app->{'Visible'} = 0;
die "File does not exist, or is not readable\n" unless -r $FileName;
my $workbook = $xl_app->Workbooks->Open($
if($workbook) {
print "Workbook is created\n";
}
else {
print "Workbook NOT created:\n $!\n $@\n";
}
my $worksheet = $workbook->Worksheets(1);
$worksheet->Range("F1")->{
$worksheet->Range("G1")->{
$worksheet->Range("H1")->{
my $currow=2;
while($worksheet->Range("A
$worksheet->Range("F$curro
$worksheet->Range("G$curro
$worksheet->Range("H$curro
$currow++;
}
$workbook->Save();
$xl_app->ActiveWorkbook->C
$xl_app->Quit();
What is the output from this:
...
my $worksheet = $workbook->Worksheets(1);
print "A1 = " . $worksheet->Range("A1") . "\n";
print "B1 = " . $worksheet->Range("B1") . "\n";
print "A2 = " . $worksheet->Range("A2") . "\n";
print "B2 = " . $worksheet->Range("B2") . "\n";
Are those values what is actually in the worksheet?
Business Accounts
Answer for Membership
by: Adam314Posted on 2007-11-20 at 13:01:20ID: 20323189
What OS will this be running on? If windows: Is Excel installed on the computer?