30 if (!defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../');
38 require_once PHPEXCEL_ROOT .
'PHPExcel.php';
41 require_once PHPEXCEL_ROOT .
'PHPExcel/Reader/IReader.php';
44 require_once PHPEXCEL_ROOT .
'PHPExcel/Worksheet.php';
47 require_once PHPEXCEL_ROOT .
'PHPExcel/Cell.php';
50 require_once PHPEXCEL_ROOT .
'PHPExcel/Reader/DefaultReadFilter.php';
101 $this->_delimiter =
',';
102 $this->_enclosure =
'"';
103 $this->_lineEnding = PHP_EOL;
104 $this->_sheetIndex = 0;
117 if (!file_exists($pFilename)) {
118 throw new Exception(
"Could not open " . $pFilename .
" for reading! File does not exist.");
122 return (substr(strtolower($pFilename), -3) ==
'csv');
131 public function load($pFilename)
155 $this->_readFilter = $pValue;
168 if (!file_exists($pFilename)) {
169 throw new Exception(
"Could not open " . $pFilename .
" for reading! File does not exist.");
179 $fileHandle = fopen($pFilename,
'r');
180 if ($fileHandle ===
false) {
181 throw new Exception(
"Could not open file $pFilename for reading.");
187 while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
189 $rowDataCount = count($rowData);
190 for ($i = 0; $i < $rowDataCount; ++$i) {
192 if ($rowData[$i] !=
'' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
194 $rowData[$i] = str_replace(
"\\" . $this->_enclosure, $this->_enclosure, $rowData[$i]);
195 $rowData[$i] = str_replace($this->_enclosure . $this->_enclosure, $this->_enclosure, $rowData[$i]);
199 $columnLetter . $currentRow, $rowData[$i]
228 $this->_delimiter = $pValue;
251 $this->_enclosure = $pValue;
271 $this->_lineEnding = $pValue;
291 $this->_sheetIndex = $pValue;