Beispiel #1
0
 public function open()
 {
     if (!isset($this->handler) || !is_resource($this->handler)) {
         $filename = $this->getDSN();
         if (!file_exists($filename)) {
             throw new \Exception(sprintf('File not exist (%s)', $filename));
         }
         if (!is_readable($filename)) {
             throw new \Exception(sprintf('File is not readable(%s)', $filename));
         }
         $this->handler = new \SpreadsheetReader($filename, false, false, $this->getOption('options'));
         // changing worksheet if needed
         $sheet = $this->getOption('worksheet');
         if (!empty($sheet)) {
             if (!is_numeric($sheet)) {
                 $index = $this->getSheetIndexForName($sheet);
                 // the rewing  is done only if index > 0 then move next before
                 $this->handler->next();
                 $this->handler->ChangeSheet($index);
             } else {
                 $this->handler->next();
                 $this->handler->ChangeSheet($sheet);
             }
         }
         if ($this->reporter) {
             $this->reporter->setTotalLines($this->handler->count());
         }
         $this->line = 0;
     }
 }
Beispiel #2
0
 public function open()
 {
     if (!isset($this->handler) || !is_resource($this->handler)) {
         $filename = $this->getDSN();
         if (!file_exists($filename)) {
             throw new \Exception(sprintf('File not exist (%s)', $filename));
         }
         if (!is_readable($filename)) {
             throw new \Exception(sprintf('File is not readable(%s)', $filename));
         }
         $this->handler = new SpreadsheetReader($filename, false);
         $this->nbRow = $this->handler->rowcount();
         $this->nbCol = $this->handler->colcount();
         $this->currentRow = 1;
         if ($this->reporter) {
             $this->reporter->setTotalLines($this->nbRow);
         }
     }
 }
Beispiel #3
0
 public function open()
 {
     if (!isset($this->handler) || !is_resource($this->handler)) {
         $filename = $this->getDSN();
         if (!file_exists($filename)) {
             throw new \Exception(sprintf('File not exist (%s)', $filename));
         }
         if (!is_readable($filename)) {
             throw new \Exception(sprintf('File is not readable(%s)', $filename));
         }
         $this->handler = fopen($filename, 'r');
         if (!is_resource($this->handler)) {
             throw new \Exception(sprintf('Could not open (%s) for reading', $filename));
         }
     }
     $this->line = 0;
     if ($this->reporter) {
         $this->reporter->setTotalLines($this->getTotalLines());
     }
 }