92 $this->_phpExcel = $phpExcel;
101 public function save($pFilename = null) {
103 $sheet = $this->_phpExcel->getSheet($this->_sheetIndex);
111 $fileHandle = fopen($pFilename,
'wb+');
112 if ($fileHandle ===
false) {
116 if ($this->_excelCompatibility) {
117 fwrite($fileHandle,
"\xEF\xBB\xBF");
121 fwrite($fileHandle,
'sep=' . $this->
getDelimiter() . $this->_lineEnding);
122 } elseif ($this->_useBOM) {
124 fwrite($fileHandle,
"\xEF\xBB\xBF");
128 $maxCol = $sheet->getHighestDataColumn();
129 $maxRow = $sheet->getHighestDataRow();
134 $cellsArray = $sheet->rangeToArray(
'A'.
$row.
':'.$maxCol.$row,
'', $this->_preCalculateFormulas);
136 $this->
_writeLine($fileHandle, $cellsArray[0]);
162 $this->_delimiter = $pValue;
185 $this->_enclosure = $pValue;
205 $this->_lineEnding = $pValue;
225 $this->_useBOM = $pValue;
246 $this->_excelCompatibility = $pValue;
266 $this->_sheetIndex = $pValue;
277 private function _writeLine($pFileHandle = null, $pValues = null) {
278 if (is_array($pValues)) {
280 $writeDelimiter =
false;
285 foreach ($pValues as $element) {
287 $element = str_replace($this->_enclosure, $this->_enclosure . $this->_enclosure, $element);
290 if ($writeDelimiter) {
293 $writeDelimiter =
true;
304 fwrite($pFileHandle, $line);
setUseBOM($pValue=false)
Set whether BOM should be used.
_writeLine($pFileHandle=null, $pValues=null)
Write line to CSV file.
getExcelCompatibility()
Get whether the file should be saved with full Excel Compatibility.
__construct(PHPExcel $phpExcel)
Create a new PHPExcel_Writer_CSV.
getDelimiter()
Get delimiter.
static setArrayReturnType($returnType)
Set the Array Return Type (Array or Value of first element in the array)
setSheetIndex($pValue=0)
Set sheet index.
setEnclosure($pValue='"')
Set enclosure.
static getArrayReturnType()
Return the Array Return Type (Array or Value of first element in the array)
setLineEnding($pValue=PHP_EOL)
Set line ending.
setExcelCompatibility($pValue=false)
Set whether the file should be saved with full Excel Compatibility.
if($is_dev) echo "Review changes write something in WHATSNEW and and then commit with log PHP_EOL
save($pFilename=null)
Save PHPExcel to file.
setDelimiter($pValue=',')
Set delimiter.
getUseBOM()
Get whether BOM should be used.
const RETURN_ARRAY_AS_VALUE
static getInstance(PHPExcel $workbook=NULL)
Get an instance of this class.
getSheetIndex()
Get sheet index.
getEnclosure()
Get enclosure.
getLineEnding()
Get line ending.