A class for reading Microsoft Excel Spreadsheets.

Originally developed by Vadim Tkachenko under the name PHPExcelReader. (http://sourceforge.net/projects/phpexcelreader) Based on the Java version by Andy Khan (http://www.andykhan.com). Now maintained by David Sanders. Reads only Biff 7 and Biff 8 formats.

category Spreadsheet
package Spreadsheet_Excel_Reader
author Vadim Tkachenko
copyright 1997-2005 The PHP Group
license PHP License 3.0
version Release: @package_version@
link http://pear.php.net/package/PackageName
see Spreadsheet_Excel_Writer

 Methods

Constructor

Spreadsheet_Excel_Reader() 

Some basic initialisation

_GetIEEE754()

_GetIEEE754($rknum) 

Parameters

$rknum

_GetInt4d()

_GetInt4d($data, $pos) 

Parameters

$data

$pos

_encodeUTF16()

_encodeUTF16($string) 

Parameters

$string

Parse a workbook

_parse() : boolean
access private

Returns

boolean

Parse a worksheet

_parsesheet(\todo $spos) 
access private
todo fix return codes

Parameters

$spos

\todo

addcell()

addcell($row, $col, $string, $raw = ''

Parameters

$row

$col

$string

$raw

Convert the raw Excel date into a human readable format

createDate(integer $numValue) : array

Dates in Excel are stored as number of seconds from an epoch. On Windows, the epoch is 30/12/1899 and on Mac it's 01/01/1904

access private

Parameters

$numValue

integer

The raw Excel value to convert

Returns

arrayFirst element is the converted date, the second element is number a unix timestamp

createNumber()

createNumber($spos) 

Parameters

$spos

Check whether the current record read is a date

isDate(\todo $spos) : boolean

Parameters

$spos

\todo

Returns

booleanTrue if date, false otherwise

Read the spreadsheet file using OLE, then parse

read(\filename $sFileName) 
access public
todo return a valid value

Parameters

$sFileName

\filename

Force a column to use a certain format

setColumnFormat(integer $column, string $sFormat) 
access public

Parameters

$column

integer

Column number

$sFormat

string

Format

Set the default number format

setDefaultFormat(\Default $sFormat) 
access public

Parameters

$sFormat

\Default

format

Set the encoding method

setOutputEncoding(string $encoding) 
access public

Parameters

$encoding

string

Encoding to use

todo

setRowColOffset(\offset $iOffset) 
access public

Parameters

$iOffset

\offset

$encoder = 'iconv' or 'mb' set iconv if you would like use 'iconv' for encode UTF-16LE to your encoding set mb if you would like use 'mb_convert_encoding' for encode UTF-16LE to your encoding

setUTFEncoder(string $encoder = 'iconv'
access public

Parameters

$encoder

string

Encoding type to use. Either 'iconv' or 'mb'

 Properties

 

todo

$_coloffset : integer

Default

1
access private
 

todo List of formats to use for each column

$_columnsFormat : array

Default

array()
access private
 

Default encoding

$_defaultEncoding : string

Default

access private
 

Default number format

$_defaultFormat : integer

Default

SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT
access private
 

OLE object for reading the file

$_ole : \OLE

Default

access private
 

todo

$_rowoffset : integer

Default

1
access private
 

Array of worksheets found

$boundsheets : array

Default

array()
access public
 

The data returned by OLE

$data : string

Default

access public
 

List of default date formats used by Excel

$dateFormats : array

Default

array(14 => "d/m/Y", 15 => "d-M-Y", 16 => "d-M", 17 => "M-Y", 18 => "h:i a", 19 => "h:i:s a", 20 => "H:i", 21 => "H:i:s", 22 => "d/m/Y H:i", 45 => "i:s", 46 => "H:i:s", 47 => "i:s.S")
access public
 

Array of format records found

$formatRecords : array

Default

array()
access public
 

Default number formats used by Excel

$numberFormats : array

Default

array(1 => "%1.0f", 2 => "%1.2f", 3 => "%1.0f", 4 => "%1.2f", 5 => "%1.0f", 6 => '$%1.0f', 7 => '$%1.2f', 8 => '$%1.2f', 9 => '%1.0f%%', 10 => '%1.2f%%', 11 => '%1.2f', 37 => '%1.0f', 38 => '%1.0f', 39 => '%1.2f', 40 => '%1.2f', 41 => '%1.0f', 42 => '$%1.0f', 43 => '%1.2f', 44 => '$%1.2f', 48 => '%1.0f')
access public
 

Array of worksheets

$sheets : array

Default

array()

The data is stored in 'cells' and the meta-data is stored in an array called 'cellsInfo'

Example:

$sheets --> 'cells' --> row --> column --> Interpreted value --> 'cellsInfo' --> row --> column --> 'type' - Can be 'date', 'number', or 'unknown' --> 'raw' - The raw data that Excel stores for that data cell

access public
 

todo

$sst : array

Default

array()
access public