30 if (!
defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../');
35 require(PHPEXCEL_ROOT .
'PHPExcel/Autoloader.php');
119 $this->_inputEncoding = $pValue;
139 rewind($this->_fileHandle);
141 switch ($this->_inputEncoding) {
143 fgets($this->_fileHandle, 4) ==
"\xEF\xBB\xBF" ?
144 fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0);
147 fgets($this->_fileHandle, 3) ==
"\xFF\xFE" ?
148 fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
151 fgets($this->_fileHandle, 3) ==
"\xFE\xFF" ?
152 fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
155 fgets($this->_fileHandle, 5) ==
"\xFF\xFE\x00\x00" ?
156 fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
159 fgets($this->_fileHandle, 5) ==
"\x00\x00\xFE\xFF" ?
160 fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
178 fclose ($this->_fileHandle);
186 $escapeEnclosures =
array(
"\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure );
188 $worksheetInfo =
array();
189 $worksheetInfo[0][
'worksheetName'] =
'Worksheet';
190 $worksheetInfo[0][
'lastColumnLetter'] =
'A';
191 $worksheetInfo[0][
'lastColumnIndex'] = 0;
192 $worksheetInfo[0][
'totalRows'] = 0;
193 $worksheetInfo[0][
'totalColumns'] = 0;
196 while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
197 $worksheetInfo[0][
'totalRows']++;
198 $worksheetInfo[0][
'lastColumnIndex'] = max($worksheetInfo[0][
'lastColumnIndex'], count($rowData) - 1);
202 $worksheetInfo[0][
'totalColumns'] = $worksheetInfo[0][
'lastColumnIndex'] + 1;
207 return $worksheetInfo;
217 public function load($pFilename)
236 $lineEnding = ini_get(
'auto_detect_line_endings');
237 ini_set(
'auto_detect_line_endings',
true);
242 fclose ($this->_fileHandle);
256 $escapeEnclosures =
array(
"\\" . $this->_enclosure,
257 $this->_enclosure . $this->_enclosure
262 if ($this->_contiguous) {
267 while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
269 foreach($rowData as $rowDatum) {
270 if ($rowDatum !=
'' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
272 $rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);
275 if ($this->_inputEncoding !==
'UTF-8') {
280 $sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
290 if ($this->_contiguous) {
291 $this->_contiguousRow = $currentRow;
294 ini_set(
'auto_detect_line_endings', $lineEnding);
316 $this->_delimiter = $pValue;
339 $this->_enclosure = $pValue;
359 $this->_sheetIndex = $pValue;
370 $this->_contiguous = (bool) $contiguous;
372 $this->_contiguousRow = -1;
_skipBOM()
Move filepointer past any BOM marker.
getEnclosure()
Get enclosure.
getSheetCount()
Get sheet count.
static ConvertEncoding($value, $to, $from)
Convert string from one encoding to another.
getContiguous()
Get Contiguous.
setInputEncoding($pValue='UTF-8')
Set input encoding.
setDelimiter($pValue=',')
Set delimiter.
createSheet($iSheetIndex=NULL)
Create sheet and add it to this workbook.
getInputEncoding()
Get input encoding.
listWorksheetInfo($pFilename)
Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) ...
Create styles array
The data for the language used.
__construct()
Create a new PHPExcel_Reader_CSV.
getSheetIndex()
Get sheet index.
_isValidFormat()
Validate that the current file is a CSV file.
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
setActiveSheetIndex($pIndex=0)
Set active sheet index.
setEnclosure($pValue='"')
Set enclosure.
setSheetIndex($pValue=0)
Set sheet index.
getDelimiter()
Get delimiter.
_openFile($pFilename)
Open file for reading.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
Loads PHPExcel from file into PHPExcel instance.
load($pFilename)
Loads PHPExcel from file.
setContiguous($contiguous=FALSE)
Set Contiguous.