1

I have to automate an excel file, I have already checked Win32:OLE, just wanted to check if there are some other ways apart from that to achieve similar functionality.

Thanks in advance!

2
  • If you want to parse excel try this module Spreadsheet::ParseXLSX and when you are trying to write something onto excel try this module Spreadsheet::WriteExcel and for reading try this module Spreadsheet::Read Commented Feb 16, 2015 at 6:06
  • You could also resort to vb script/vba called through the scripting host (cscript.exe). Create an excel application object and use that as the entry point to the excel object model. Commented Feb 16, 2015 at 8:07

1 Answer 1

1

Cpan module Spreadsheet::ParseExcel is a tool to read information from an Excel file. An example is here :

use warnings;
use strict;
use Spreadsheet::ParseExcel;

my $parser   = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse('Book1.xls');

if ( !defined $workbook ) {
    die $parser->error(), ".\n";
}

for my $worksheet ( $workbook->worksheets() ) {

    my ( $row_min, $row_max ) = $worksheet->row_range();
    my ( $col_min, $col_max ) = $worksheet->col_range();

    for my $row ( $row_min .. $row_max ) {
        for my $col ( $col_min .. $col_max ) {

            my $cell = $worksheet->get_cell( $row, $col );
            next unless $cell;

            print "Row, Col    = ($row, $col)\n";
            print "Value       = ", $cell->value(),       "\n";
            print "Unformatted = ", $cell->unformatted(), "\n";
            print "\n";
        }
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

I need to automate actions, the way win32::OLE does, I don't think Spreadsheet::ParseExcel does that.
I never used Win32::OLE, so don't have idea about this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.