Spreadsheet::BasicRead - Methods to easily read data from spreadsheets

- NAME
- DESCRIPTION
- SYNOPSIS
- REQUIRED MODULES
- METHODS

- new
- `getNextRow()`
- `numSheets()`
- `openSpreadsheet(fileName)`
- `currentSheetNum()`
- `currentSheetName()`
- `setCurrentSheetNum(num)`
- `getNextSheet()`
- `getFirstSheet()`
- cellValue(row, col)
- `getFirstRow()`
- `setHeadingRow(rowNumber)`
- `logexp(message)`
- logmsg(debug, message)

- KNOWN ISSUES
- SEE ALSO
- AUTHOR
- LICENSE
- CVS ID

# NAME

Spreadsheet::BasicRead - Methods to easily read data from spreadsheets

# DESCRIPTION

Provides methods for simple reading of a Excel spreadsheet row at a time returning the row as an array of column values. Properties can be set so that blank rows are skipped

# SYNOPSIS

     use Spreadsheet::BasicRead;

     my $xlsFileName = 'Test.xls';

     my $ss = new Spreadsheet::BasicRead($xlsFileName) ||
            die "Could not open '$xlsFileName': $!";

     # Print the row number and data for each row of the
     # spreadsheet to stdout using '|' as a separator
     my $row = 0;
     while (my $data = $ss->getNextRow())
     {
            $row++;
            print join('|', $row, @$data), "\n";
     }

     # Print the number of sheets
     print "There are ", $ss->numSheets(), " in the spreadsheet\n";

     # Set the heading row to 4
     $ss->setHeadingRow(4);

     # Skip the first data line, it's assumed to be a heading
     $ss->skipHeadings(1);

     # Print the name of the current sheet
     print "Sheet name is ", $ss->currentSheetName(), "\n";

     # Reset back to the first row of the sheet
     $ss->getFirstRow();

# REQUIRED MODULES

The following modules are required:

     Spreadsheet::ParseExcel

Optional module File::Log can be used to allow simple logging of errors.

# METHODS

There are no class methods, the object methods are described below. Private class method start with the underscore character '_' and should be treated as Private.

## new

Called to create a new BasicReadNamedCol object. The arguments can be either a single string (see 'SYNOPSIS') which is taken as the filename of the spreadsheet of as named arguments.

     eg.  my $ss = Spreadsheet::BasicReadNamedCol->new(
                      fileName      => 'MyExcelSpreadSheet.xls',
                      skipHeadings  => 1,
                      skipBlankRows => 1,
                      log           => $log,
                  );

The following named arguments are available:

skipHeadings
  Don't output the headings line in the first call to 'getNextRow' if true.

skipBlankRows
  Skip blank lines in the spreadsheet if true.

log
  Use the File::Log object to log exceptions. If not provided error conditions are logged to STDERR

fileName
  The name (and optionally path) of the spreadsheet file to process.

## `getNextRow()`

Get the next row of data from the spreadsheet. The data is returned as an array reference.

     eg.  $rowDataArrayRef = $ss->getNextRow();

## `numSheets()`

Returns the number of sheets in the spreadsheet

## `openSpreadsheet(fileName)`

Open a new spreadsheet file and set the current sheet to the first sheet. The name and optionally path of the spreadsheet file is a required argument to this method.

## `currentSheetNum()`

Returns the current sheet number or undef if there is no current sheet. 'setCurrentSheetNum' can be called to set the current sheet.

## `currentSheetName()`

Return the name of the current sheet or undef if the current sheet is not defined. see 'setCurrentSheetNum'.

## `setCurrentSheetNum(num)`

Sets the current sheet to the integer value 'num' passed as the required argument to this method. Note that this should not be bigger than the value returned by 'numSheets'.

## `getNextSheet()`

Returns the next sheet ``ssBook'' object or undef if there are no more sheets to process. If there is no current sheet defined the first sheet is returned.

## `getFirstSheet()`

Returns the first sheet ``ssBook'' object.

## cellValue(row, col)

Returns the value of the cell defined by (row, col)in the current sheet.

## `getFirstRow()`

Returns the first row of data from the spreadsheet (possibly skipping the column headings 'skipHeadings') as an array reference.

## `setHeadingRow(rowNumber)`

Sets the effective minimum row for the spreadsheet to 'rowNumber', since it is assumed that the heading is on this row and anything above the heading is not relavent.

Note: the row (and column) numbers are zero indexed.

## `logexp(message)`

Logs an exception message (can be a list of strings) using the File::Log object if it was defined and then calls die message.

## logmsg(debug, message)

If a File::Log object was passed as a named argument 'new') and if 'debug' (integer value) is equal to or greater than the current debug Level (see File::Log) then the message is added to the log file.

If a File::Log object was not passed to new then the message is output to STDERR.

# KNOWN ISSUES

None, however please contact the author at gng@cpan.org should you find any problems and I will endevour to resolve then as soon as possible

# SEE ALSO

Spreadsheet:ParseExcel on CPAN does all the hard work, thanks Kawai Takanori (Hippo2000) kwitknr@cpan.org

# AUTHOR

Greg George, IT Technology Solutions P/L, Australia Mobile: +61-404-892-159, Email: gng@cpan.org

# LICENSE

Copyright (c) 1999- Greg George. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

# CVS ID

$Id$