You are here

private function PHPExcel_Writer_CSV::_writeLine in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/CSV.php \PHPExcel_Writer_CSV::_writeLine()

* Write line to CSV file * *

Parameters

mixed $pFileHandle PHP filehandle: * @param array $pValues Array containing values in a row * @throws PHPExcel_Writer_Exception

1 call to PHPExcel_Writer_CSV::_writeLine()
PHPExcel_Writer_CSV::save in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/CSV.php
* Save PHPExcel to file * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/CSV.php, line 277

Class

PHPExcel_Writer_CSV
PHPExcel_Writer_CSV

Code

private function _writeLine($pFileHandle = null, $pValues = null) {
  if (is_array($pValues)) {

    // No leading delimiter
    $writeDelimiter = false;

    // Build the line
    $line = '';
    foreach ($pValues as $element) {

      // Escape enclosures
      $element = str_replace($this->_enclosure, $this->_enclosure . $this->_enclosure, $element);

      // Add delimiter
      if ($writeDelimiter) {
        $line .= $this->_delimiter;
      }
      else {
        $writeDelimiter = true;
      }

      // Add enclosed string
      $line .= $this->_enclosure . $element . $this->_enclosure;
    }

    // Add line ending
    $line .= $this->_lineEnding;

    // Write to file
    fwrite($pFileHandle, $line);
  }
  else {
    throw new PHPExcel_Writer_Exception("Invalid data row passed to CSV writer.");
  }
}