NAME

Spreadsheet::XlateExcel - Trigger a callback subroutine on each row of an Excel spreadsheet

VERSION

Version 0.03

SYNOPSIS

This modules triggers a callback subroutine on each row of an Excel spreadsheet.

Wrote this simple module because I was fed up from writing the same boilerplate code ever when I had to mine spreadsheets for data.

Operates on every sheet unless a given sheet is targeted by name, RE inclusion or RE exclusion.

Operates on every column unless targeted by column head name or RE (inclusion).

For example:

use Spreadsheet::XlateExcel;

my $id = Spreadsheet::XlateExcel->new ({ file => 'sheet.xls' });

# rip odd rows of "Sheet2" sheet

my $lol;

$id->xlate ({
    on_sheet_named  => 'Sheet2',
    for_each_row_do => sub {
        my ( $sheet_id, $row, $row_vs ) = @_;

        push @$lol, $row_vs unless $row % 2;
    },
});

METHODS

new

my $id = Spreadsheet::XlateExcel->new ({ file => 'sheet.xls' [, formatter => Spreadsheet::ParseExcel::Fmt->new })

Ye constructor.

Optional formatter attribute is a Spreadsheet::ParseExcel formatter instance. Refer to http://metacpan.org/module/Spreadsheet::ParseExcel#parse-filename-formatter- for more about such formatters.

xlate

$self->xlate ({ for_each_row_do => sub { my ( $sheet_id, $row, $row_vs ) = @_ ; ... } })

Applies for_each_row_do sub to each row of each sheet (unless filtered, see below) of the book.

Options:

  • on_sheet_named: targets a given book sheet by name

  • on_sheets_like: targets a given book sheet by RE inclusion on name

  • on_sheets_unlike: targets a given book sheet by RE exclusion on name

  • on_columns_heads_named: targets columns via a listref of strings

  • on_columns_heads_like: targets columns via a listref of regular expressions

Callback function gets called for each row, fed with Spreadsheet::ParseExcel::Worksheet ID, row index and arrayref of row values parameters.

Returns self.

book_id

my $book_id = $self->book_id ()

Accessor to Spreadsheet::ParseExcel::Workbook instance ID.

AUTHOR

Xavier Caron, <xav at cpan.org>

BUGS

Please report any bugs or feature requests to bug-spreadsheet-xlateexcel at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Spreadsheet-XlateExcel. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Spreadsheet::XlateExcel

You can also look for information at:

Code is available through github (http://github.com/maspalio/Spreadsheet-XlateExcel).

ACKNOWLEDGEMENTS

To Kawai Takanori, Gabor Szabo and John McNamara, authors of cool http://search.cpan.org/dist/Spreadsheet-ParseExcel/ module.

LICENSE AND COPYRIGHT

Copyright 2010 Xavier Caron.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.