Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Spreadsheet::BasicRead
Methods to easily read data from spreadsheets

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


skipHeadings
Don't output the headings line in the first call to 'getNextRow' if true. This is the first row of the spreadsheet unless the setHeadingRow function has been called to set the heading row.



=item skipBlankRows

Skip blank lines in the spreadsheet if true.




=item log

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




=item fileName

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




=item oldCell

Empty cells returned undef pre version 1.5. They now return ''.

The old functionality can be turned on by setting argument oldCell to true

Note that new will die if the spreadsheet can not be successfully opened. As such you may wish to wrap the call to new in a eval block. See xlsgrep for an example of when this might be desirable.

getNextRow()

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


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



=head2 numSheets()

Returns the number of sheets in the spreadsheet




=head2 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.




=head2 currentSheetNum()

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




=head2 currentSheetName()

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




=head2 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'.




=head2 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.




=head2 getFirstSheet()

Returns the first sheet ``ssBook'' object.




=head2 cellValue(row, col)

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




=head2 getFirstRow()

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




=head2 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.




=head2 setRow(rowNumber)

Sets the row to be returned by the next call to 'getNextRow'. Note that if the heading row has been defined and the row number set with setRow is less than the heading row, data will be returned from the heading row regardless, unless skip heading row has been set, in which case it will be the row after the heading row.




=head2 getRowNumber()

Returns the number of the current row (that has been retrieved). Note that row numbers are zero indexed. If a row has not been retrieved as yet, -1 is returned.




=head2 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.




=head2 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.




=head1 EXAMPLE APPLICATIONS

Two sample (but usefull) applications are included with this distribution.

The simplest is dumpSS.pl which will dump the entire contents of a spreadsheet to STDOUT. Each sheet is preceeded by the sheet name (enclosed in ***) on a line, followed by each row of the spreadsheet, with cell values separated by the pipe '|' character. There is no special handling provided for cells containing the pipe character.

A more complete example is xlsgrep. This application can be used to do a perl pattern match for cell values within xls files in the current and sub directories. There are no special grep flags, however this should not be a problem since perl's pattern matching allows for most requirements within the search pattern.


 Usage is: xlsgrep.pl pattern

To do a case insensative search for ``Some value'' in any xls file in the current directory you would use:


 xlsgrep '(?i)Some value'

For further details, see each applications POD.




=head1 ACKNOWLEDGEMENTS

I would like to acknowledge the input and patches recieved from the following:

Ilia Lobsanov, Bryan Maloney, Bill (from Datacraft), nadim and D. Dewey Allen




=head1 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.

If you have any enhancement suggestions please send me an email and I will try to accommodate your suggestion.




=head1 SEE ALSO

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

The included applications dumpSS.pl and xlsgrep.pl




=head1 AUTHOR

 Greg George, IT Technology Solutions P/L, Australia

 Mobile: +61-404-892-159, Email: gng@cpan.org



=head1 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.




=head1 CVS ID

$Id: BasicRead.pm,v 1.10 2006/04/30 05:35:13 Greg Exp $




=head1 UPDATE HISTORY

 $Log: BasicRead.pm,v $

 Revision 1.10  2006/04/30 05:35:13  Greg

 - added getRowNumber()

 Revision 1.9  2006/03/05 02:43:34  Greg

 - Update of Acknowledgments

 Revision 1.8  2006/03/05 02:31:41  Greg

 - Changes to cellValue return to cater for 'GENERAL' value sometimes returned from OpenOffice spreadsheets

   patch provided by Ilia Lobsanov <samogon@gmail.com>

   see http://www.annocpan.org/~KWITKNR/Spreadsheet-ParseExcel-0.2602/ParseExcel.pm#note_18

 Revision 1.7  2006/01/25 22:17:47  Greg

 - Correction to reading of the first row of the next sheet (without calling getFirstRow).

   Error detected and reported by Tim Rossiter

 - Reviewed memory useage as reported by Ilia Lobsanov - this seems to be in the underlying OLE::Storage_Lite

 Revision 1.6  2005/02/21 09:54:08  Greg

 - Update to setCurrentSheetNum() so that the new sheet is handled by BasicRead functions

 Revision 1.5  2004/10/08 22:40:27  Greg

 - Changed cellValue to return '' for an empty cell rather than undef (requested by D D Allen).  Old functionality can be maintained by setting named parameter 'oldCell' to true in call to new().

 - Added examples to POD

 Revision 1.4  2004/10/01 11:02:21  Greg

 - Updated getNextRow to skip sheets that have nothing on them

 Revision 1.3  2004/09/30 12:32:25  Greg

 - Update to currentSheetNum and getNextSheet functions

 Revision 1.2  2004/08/21 02:30:29  Greg

 - Added setHeadingRow and setRow

 - Updated documentation

 - Remove irrelavant use lib;

 Revision 1.1.1.1  2004/07/31 07:45:02  Greg

 - Initial release to CPAN



=cut

#---< End of File >---#

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy