mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-22 05:16:06 +03:00
Allow inclusion of a sep=; line when creating csv files
This commit is contained in:
parent
7d1c140974
commit
a806b79aba
@ -69,6 +69,14 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
|
|||||||
*/
|
*/
|
||||||
private $useBOM = false;
|
private $useBOM = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to write a Separator line as the first line of the file
|
||||||
|
* sep=x
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $includeSeparatorLine = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to write a fully Excel compatible CSV file.
|
* Whether to write a fully Excel compatible CSV file.
|
||||||
*
|
*
|
||||||
@ -109,15 +117,20 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->excelCompatibility) {
|
if ($this->excelCompatibility) {
|
||||||
fwrite($fileHandle, "\xEF\xBB\xBF"); // Enforce UTF-8 BOM Header
|
$this->setUseBOM(true); // Enforce UTF-8 BOM Header
|
||||||
$this->setEnclosure('"'); // Set enclosure to "
|
$this->setIncludeSeparatorLine(true); // Set separator line
|
||||||
$this->setDelimiter(";"); // Set delimiter to a semi-colon
|
$this->setEnclosure('"'); // Set enclosure to "
|
||||||
|
$this->setDelimiter(";"); // Set delimiter to a semi-colon
|
||||||
$this->setLineEnding("\r\n");
|
$this->setLineEnding("\r\n");
|
||||||
fwrite($fileHandle, 'sep=' . $this->getDelimiter() . $this->lineEnding);
|
}
|
||||||
} elseif ($this->useBOM) {
|
if ($this->useBOM) {
|
||||||
// Write the UTF-8 BOM code if required
|
// Write the UTF-8 BOM code if required
|
||||||
fwrite($fileHandle, "\xEF\xBB\xBF");
|
fwrite($fileHandle, "\xEF\xBB\xBF");
|
||||||
}
|
}
|
||||||
|
if ($this->includeSeparatorLine) {
|
||||||
|
// Write the separator line if required
|
||||||
|
fwrite($fileHandle, 'sep=' . $this->getDelimiter() . $this->lineEnding);
|
||||||
|
}
|
||||||
|
|
||||||
// Identify the range that we need to extract from the worksheet
|
// Identify the range that we need to extract from the worksheet
|
||||||
$maxCol = $sheet->getHighestDataColumn();
|
$maxCol = $sheet->getHighestDataColumn();
|
||||||
@ -229,6 +242,28 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether a separator line should be included
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function getIncludeSeparatorLine()
|
||||||
|
{
|
||||||
|
return $this->includeSeparatorLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether a separator line should be included as the first line of the file
|
||||||
|
*
|
||||||
|
* @param boolean $pValue Use separator line? Defaults to false
|
||||||
|
* @return PHPExcel_Writer_CSV
|
||||||
|
*/
|
||||||
|
public function setIncludeSeparatorLine($pValue = false)
|
||||||
|
{
|
||||||
|
$this->includeSeparatorLine = $pValue;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether the file should be saved with full Excel Compatibility
|
* Get whether the file should be saved with full Excel Compatibility
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user