Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2010
    Posts
    1

    Unanswered: 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.

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    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]

  3. #3
    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 12:55.

  4. #4
    Join Date
    Feb 2006
    Posts
    173
    Provided Answers: 1
    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

  5. #5
    Join Date
    Aug 2003
    Location
    West
    Posts
    101
    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}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •