Structures_DataGrid_DataSource_Excel

Structures_DataGrid_DataSource_Excel -- Excel Spreadsheet Data Source Driver

Description

This class is a data source driver for an Excel spreadsheet.

Supported operations modes

This driver supports the following operation modes:

Table 59-1. Supported operations modes of this driver

ModeSupported?
Multiple field sortingno
Insert, update and delete recordsno

Options

This driver accepts the following options:

Table 59-2. Options for this driver

OptionTypeDescriptionDefault Value
fieldsarrayWhich data fields to fetch from the datasource. An empty array means: all fields. Form: array(field1, field2, ...)array()
generate_columnsboolGenerate Structures_DataGrid_Column objects with labels. See the 'labels' option. DEPRECATED: use Structures_DataGrid::generateColumns() insteadfalse
headerboolWhether the Excel file contains a header rowfalse
labelsarrayData field to column label mapping. Only used when 'generate_columns' is true. Form: array(field => label, ...) DEPRECATED: use Structures_DataGrid::generateColumns() insteadarray()
natsortbooleanWhether the array should be sorted naturally (e.g. example1, Example2, test1, Test2) or not (e.g. Example2, Test2, example1, test1; i.e. capital letters will come first).false
primaryKeyarrayName(s), or numerical index(es) of the field(s) which contain a unique record identifier (only use several fields in case of a multiple-fields primary key)null

General notes

Spreadsheet_Excel_Reader ("PHP-ExcelReader") is not available as a PEAR package. It is available on SourceForge.net: http://sourceforge.net/projects/phpexcelreader/

This class expects the file reader.php in the directory Spreadsheet/Excel/.

Please note that the current version (2i) of Spreadsheet_Excel_Reader contains a die() statement in the read() method in reader.php (line 171). This makes a reasonable PEAR error handling for the "file not found" error impossible.

It is therefore recommended that you replace the die() statement by something like this:
return PEAR::raiseError('The filename ' . $sFileName . ' is not readable');
This class is optimized for the changed code (but will work also with the die() in the reader class, of course), and provides then a reasonable error handling.