305 while ($this->currentPosition <= $this->fileSize)
307 $ch = $this->buffer[$this->bufferPosition];
308 if ($ch ===
"\r" || $ch ===
"\n")
312 while ($this->currentPosition <= $this->fileSize)
315 $ch = $this->buffer[$this->bufferPosition];
316 if ($ch !==
"\r" && $ch !==
"\n")
321 if ($this->firstHeader)
323 $this->firstHeader =
false;
334 elseif ($ch ===
"\"")
344 if ($this->buffer[$this->bufferPosition] !==
"\"")
350 elseif ($ch === $this->fieldDelimiter)
362 $this->currentPosition ++;
363 $this->bufferPosition ++;
364 if ($this->bufferPosition >= $this->bufferSize)
366 $this->buffer = $this->read(1024 * 1024);
368 $this->bufferPosition = 0;
399 while ($this->currentPosition <= $this->fileSize)
401 $ch = $this->buffer[$this->bufferPosition];
402 if ($ch ===
"\r" || $ch ===
"\n")
404 while ($this->currentPosition <= $this->fileSize)
407 $ch = $this->buffer[$this->bufferPosition];
408 if ($ch !==
"\r" && $ch !==
"\n")
413 if ($this->firstHeader)
415 $this->firstHeader =
false;
426 if ($ind === $this->widthMap[$jnd])
428 $result[] = $str. $ch;
437 $this->currentPosition ++;
438 $this->bufferPosition ++;
439 if($this->bufferPosition >= $this->bufferSize)
441 $this->buffer = $this->read( 1024 * 1024);
443 $this->bufferPosition = 0;
495 $this->currentPosition ++;
496 $this->bufferPosition ++;
497 if ($this->bufferPosition >= $this->bufferSize)
499 $this->buffer = $this->read( 1024 * 1024);
501 $this->bufferPosition = 0;
532 public function setPos(
int $position = 0): void
534 if ($position <= $this->fileSize)
536 $this->currentPosition = $position;
540 $this->currentPosition = $this->fileSize;
543 $pos = $this->currentPosition;
550 $this->buffer = $this->read(1024 * 1024);
553 $this->bufferPosition = 0;
563 public function put(array $fields): bool
566 $throw32KWarning =
false;
567 if ($this->fieldsType == self::FIELDS_TYPE_WITH_DELIMITER)
570 for ($i = 0, $n = \count($fields); $i < $n; $i++)
581 if ($fields[$i] ===
null)
585 elseif (\preg_match(
"#[\"\n\r]+#".\BX_UTF_PCRE_MODIFIER, $fields[$i]))
587 $fields[$i] = \str_replace(
"\"",
"\"\"", $fields[$i]);
591 $content .= $fields[$i];
597 $throw32KWarning =
true;
604 $length = $this->write($content);
605 if ($length !==
false)
607 $this->fileSize += $length;
613 if ($throw32KWarning)
615 if (!$this->
hasError(self::ERROR_32K_FIELD_LENGTH))
618 'Excel has limit when the total number of characters that a cell can contain is 32767 characters.',
619 self::ERROR_32K_FIELD_LENGTH
624 return ($length !==
false);