943,740 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Unsolved
  • Views: 3461
  • Perl RSS
Apr 28th, 2009
0

How to call a excel sheet from perl

Expand Post »
Hi,

I am working on a assignment where I have results sheet which is in form of text file;
I want text file content to be written in excel sheet; generally we manually copy and paste the results in excel sheet.
Our existing excel sheet has 70(sub-sheets) e.g result of test case A will paste in sheet A, like tat result of B will go in sheet B and so on...
Now i want to know is there any way by which we can call a excel sheet through Perl and can add the result at specific location.

Any help is appreciated;

Regards,
rAnA
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rana03 is offline Offline
9 posts
since Mar 2009
Apr 30th, 2009
0

Re: How to call a excel sheet from perl

Can Somebody tell me how to read cells of excel sheet using perl
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rana03 is offline Offline
9 posts
since Mar 2009
Apr 30th, 2009
0

Re: How to call a excel sheet from perl

Try this for excel
Perl Syntax (Toggle Plain Text)
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4. use Spreadsheet::Read;
  5. use Data::Dumper;
  6.  
  7. my $xls = ReadData ("Input/sample.xls");
  8.  
  9. print $xls->[1]{'A1'};
  10. exit;
Regards,
Balaji S
Last edited by Ancient Dragon; Apr 30th, 2009 at 9:11 pm. Reason: add code tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
soubalaji is offline Offline
2 posts
since Apr 2009
May 1st, 2009
0

Re: How to call a excel sheet from perl

Perl Syntax (Toggle Plain Text)
  1. use OLE;
  2. use Win32::OLE::Const 'Microsoft Excel';
  3. my($xapp) = CreateObject OLE 'Excel.Application' || die $!;
  4. $xapp->{'Visible'} = 1;
  5.  
  6. # Open the excel file
  7. $wkb = $xapp->Workbooks->Open('filename');
  8. if ( ! $wkb )
  9. { print "Can't open filename\n"; exit; }
  10. $wks = $wkb->Worksheets("Sheet1"); #what ever the sheet name
  11. $wks->Cells(1,1)->{'Value'} = 'whatever'; #assign to 'whatever'
  12.  
  13. $val=$wks->Cells(1,1)->{'Value'}; #which reads from cell 1,1 and answers the next questioner
  14. $wkb->SaveAs({Filename => 'newfile'});
  15. $wkb->Close();
  16. $xapp->Quit();
Last edited by mitchems; May 1st, 2009 at 12:09 pm.
Reputation Points: 26
Solved Threads: 38
Posting Whiz in Training
mitchems is offline Offline
293 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: How to convert text file to binary file and Binary to text using perl
Next Thread in Perl Forum Timeline: Why doesn't this work? (filehandling+regexp)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC