If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > Writing to an excel sheet...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-19-10, 09:39
rejeesh rejeesh is offline
Registered User
 
Join Date: Feb 2010
Posts: 1
Writing to an excel sheet...

Hi all,
I have never used perl before, so I request your help.

I have an excel document. I am looking for a perl script that does the following.
1. Open the excel doc

Inside a loop
2. Copy existing sheet to another one and rename the sheet
3. Insert values into 3 columns
exit loop

4. Save the excel file


Could you please help? I appreciate you help.
Reply With Quote
  #2 (permalink)  
Old 02-23-10, 15:17
MCrowley MCrowley is online now
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
First, you will need to learn the Excel Application methods, and properties. This might get you started, but it has been a while since I had to do this myself:

http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx

Object Model Map*[Excel 2007 Developer Reference]
Reply With Quote
  #3 (permalink)  
Old 09-23-10, 21:07
chewie74 chewie74 is offline
Registered User
 
Join Date: Sep 2010
Location: Calif,USA
Posts: 1
Cool perl and excel

Maybe if i knew what you were trying to record/achiev, it would be easier to formulate a program for you.

Gerald

health&fitness

About

Last edited by Pat Phelan; 10-05-10 at 11:55.
Reply With Quote
  #4 (permalink)  
Old 09-29-10, 17:02
spacebar spacebar is offline
Registered User
 
Join Date: Feb 2006
Posts: 73
You could save the excel spreadsheet(s) as delimited files(i.e. tab, comma, etc) and just create new tab delimited files with an extension(.xls) and excel will automagically place each column in it's own row/cell.

If you want to act directly on a .xls spreadsheet created in excel take a look at these modules:
Read information from an Excel file:
http://search.cpan.org/~jmcnamara/Spreadsheet-ParseExcel-0.58/lib/Spreadsheet/ParseExcel.pm

Create an Excel file:
http://search.cpan.org/~gwyn/Data-Tabular-Dumper-0.08/Dumper.pm#Data::Tabular:umper::Excel

Or just search on terms 'Spreadsheet' and 'excel' at this link and you will see lots of modules for use with spreadsheets:
The CPAN Search Site - search.cpan.org

hth
Reply With Quote
  #5 (permalink)  
Old 10-05-10, 11:35
Ida Hoe Ida Hoe is offline
Registered User
 
Join Date: Aug 2003
Location: West
Posts: 98
Quote:
Originally Posted by rejeesh View Post
Hi all,
I have never used perl before, so I request your help.

I have an excel document. I am looking for a perl script that does the following.
1. Open the excel doc

Inside a loop
2. Copy existing sheet to another one and rename the sheet
3. Insert values into 3 columns
exit loop

4. Save the excel file


Could you please help? I appreciate you help.
start with this, and see how far you can get
{code}
use warnings;
use strict;
use OLE;
my $excel = CreateObject OLE 'Excel.Application' or die $!;
$excel->{'Visible'} = 1;
my $workbook = $excel -> Workbooks -> Add;
$workbook -> ActiveSheet -> Range('A1')->{'Value'} = "Hello";
$workbook -> ActiveSheet -> Range('C2: D3')->{'Value'} = [
['one', 'two' ],
['three', 'four'],
];
$workbook -> SaveAs ('C:\\perl.xls') or die $!;
$excel -> Quit;
{code}
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On