Source for file CSV.php
Documentation is available at CSV.php
* Copyright (c) 2006 - 2008 PHPExcel
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2008 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.6.3, 2008-08-25
require_once 'PHPExcel/Writer/IWriter.php';
require_once 'PHPExcel/Cell.php';
require_once 'PHPExcel/RichText.php';
/** PHPExcel_Shared_String */
require_once 'PHPExcel/Shared/String.php';
* @package PHPExcel_Writer
* @copyright Copyright (c) 2006 - 2008 PHPExcel (http://www.codeplex.com/PHPExcel)
* Create a new PHPExcel_Writer_CSV
* @param PHPExcel $phpExcel PHPExcel object
* @param string $pFileName
public function save($pFilename = null) {
$fileHandle = fopen($pFilename, 'w');
if ($fileHandle === false) {
throw new Exception("Could not open file $pFilename for writing.");
$cellCollection = $sheet->getCellCollection();
foreach ($cellCollection as $cell) {
if ($currentRow != $cell->getRow()) {
$currentRow = $cell->getRow();
for ($i = 0; $i < $colCount; $i++ ) {
$rowData[$column] = $cell->getValue()->getPlainText();
$cell->getCalculatedValue(),
$sheet->getstyle( $cell->getCoordinate() )->getNumberFormat()->getFormatCode()
$sheet->getstyle( $cell->getCoordinate() )->getNumberFormat()->getFormatCode()
* @param string $pValue Delimiter, defaults to ,
* @param string $pValue Enclosure, defaults to "
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
* @param int $pValue Sheet index
* @param mixed $pFileHandle PHP filehandle
* @param array $pValues Array containing values in a row
private function _writeLine($pFileHandle = null, $pValues = null) {
foreach ($pValues as $element) {
throw new Exception("Invalid parameters passed.");
* Get Pre-Calculate Formulas
* Set Pre-Calculate Formulas
* @param boolean $pValue Pre-Calculate Formulas?
|