NAME

Spreadsheet::Edit::Preload - load and auto-import column variables

SYNOPSIS

use Spreadsheet::Edit::Preload {OPTIONS}, PATH

use Spreadsheet::Edit::Preload
  {sheet => "Sheet1", title_rx => 2}, "/path/to/file.xls" ;

apply {
  say "row ",($rx+1)," has $FIRST_NAME $LAST_NAME";
};

say "Row 4, column B contains ", $rows[3]{B};
say "Row 4: "First Name" is ", $rows[3]{"First Name"};
say "Row 4: "Last Name" is ", $rows[3]{Last_Name};
say "There are ", scalar(@rows), " rows of data.";
say "There are $num_cols columns";

DESCRIPTION

This is a wrapper for Spreadsheet::Edit which loads a spreadsheet at compile time. Tied variables are imported having names derived from column titles or letter codes; these may be used during "apply" operations to access the corresponding column in the "current row".

The example above is equivalent to

use Spreadsheet::Edit qw(:FUNCS :STDVARS);
BEGIN {
  read_spreadsheet {sheet => "Sheet1"}, "/path/to/file.xls";
  title_rx 2;
  tie_column_vars ':all';
}
...

You need not (and may not) explicitly declare the tied variables.

OPTIONS

The {OPTIONS} hashref is optional and may specify a workbook sheetname, CSV parsing options, etc. (see read_spreadsheet in Spreadsheet::Edit).

title_rx => ROWINDEX

explicitly specifies the 0-based row index of the title row. If not specified, the title row is auto-detected.

SECURITY

A fatal error occurs if a column letter ('A', 'B' etc.), a title, or identifier derived from a title (that is, any COLSPEC) clashes with something already existing in the caller's package or in package "main".

SEE ALSO

Spreadsheet::Edit