Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions SpreadsheetReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ class SpreadsheetReader implements SeekableIterator, Countable
* @param string Path to file
* @param string Original filename (in case of an uploaded file), used to determine file type, optional
* @param string MIME type from an upload, used to determine file type, optional
* @param array Options passed to reader for file type, see documentation for specific reader class
*/
public function __construct($Filepath, $OriginalFilename = false, $MimeType = false)
public function __construct($Filepath, $OriginalFilename = false, $MimeType = false, Array $Options = null)
{
if (!is_readable($Filepath))
{
Expand All @@ -63,6 +64,11 @@ public function __construct($Filepath, $OriginalFilename = false, $MimeType = fa
throw new Exception('SpreadsheetReader: Mime type (3nd parameter) path is not a string or a scalar value.');
}

if ($Options)
{
$this -> Options = $Options;
}

// 1. Determine type
if (!$OriginalFilename)
{
Expand Down Expand Up @@ -141,7 +147,7 @@ public function __construct($Filepath, $OriginalFilename = false, $MimeType = fa
if ($this -> Type == self::TYPE_XLS)
{
self::Load(self::TYPE_XLS);
$this -> Handle = new SpreadsheetReader_XLS($Filepath);
$this -> Handle = new SpreadsheetReader_XLS($Filepath, $this -> Options);
if ($this -> Handle -> Error)
{
$this -> Handle -> __destruct();
Expand All @@ -163,7 +169,7 @@ public function __construct($Filepath, $OriginalFilename = false, $MimeType = fa
{
case self::TYPE_XLSX:
self::Load(self::TYPE_XLSX);
$this -> Handle = new SpreadsheetReader_XLSX($Filepath);
$this -> Handle = new SpreadsheetReader_XLSX($Filepath, $this -> Options);
break;
case self::TYPE_CSV:
self::Load(self::TYPE_CSV);
Expand Down Expand Up @@ -226,10 +232,10 @@ private static function Load($Type)

// !Iterator interface methods

/**
/**
* Rewind the Iterator to the first element.
* Similar to the reset() function for arrays in PHP
*/
*/
public function rewind()
{
$this -> Index = 0;
Expand All @@ -239,7 +245,7 @@ public function rewind()
}
}

/**
/**
* Return the current element.
* Similar to the current() function for arrays in PHP
*
Expand All @@ -254,10 +260,10 @@ public function current()
return null;
}

/**
* Move forward to next element.
* Similar to the next() function for arrays in PHP
*/
/**
* Move forward to next element.
* Similar to the next() function for arrays in PHP
*/
public function next()
{
if ($this -> Handle)
Expand All @@ -269,12 +275,12 @@ public function next()
return null;
}

/**
/**
* Return the identifying key of the current element.
* Similar to the key() function for arrays in PHP
*
* @return mixed either an integer or a string
*/
*/
public function key()
{
if ($this -> Handle)
Expand All @@ -284,12 +290,12 @@ public function key()
return null;
}

/**
/**
* Check if there is a current element after calls to rewind() or next().
* Used to check if we've iterated to the end of the collection
*
* @return boolean FALSE if there's nothing more to iterate over
*/
*/
public function valid()
{
if ($this -> Handle)
Expand Down