diff --git a/SpreadsheetReader.php b/SpreadsheetReader.php index b019f8f..c5d0522 100644 --- a/SpreadsheetReader.php +++ b/SpreadsheetReader.php @@ -36,14 +36,24 @@ 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 string $Options array of options containing Delimiter and Enclosure, used to determine change csv file separator, optional */ - public function __construct($Filepath, $OriginalFilename = false, $MimeType = false) + public function __construct($Filepath, $OriginalFilename = false, $MimeType = false, $Options = false) { if (!is_readable($Filepath)) { throw new Exception('SpreadsheetReader: File ('.$Filepath.') not readable'); } + if ($Options){ + $Options = array_merge($this-> Options, $Options); + } + else + { + $Options = $this-> Options; + } + + // To avoid timezone warnings and exceptions for formatting dates retrieved from files $DefaultTZ = @date_default_timezone_get(); if ($DefaultTZ) @@ -167,14 +177,14 @@ public function __construct($Filepath, $OriginalFilename = false, $MimeType = fa break; case self::TYPE_CSV: self::Load(self::TYPE_CSV); - $this -> Handle = new SpreadsheetReader_CSV($Filepath, $this -> Options); + $this -> Handle = new SpreadsheetReader_CSV($Filepath, $Options); break; case self::TYPE_XLS: // Everything already happens above break; case self::TYPE_ODS: self::Load(self::TYPE_ODS); - $this -> Handle = new SpreadsheetReader_ODS($Filepath, $this -> Options); + $this -> Handle = new SpreadsheetReader_ODS($Filepath, $Options); break; } }