Source for file CSV.php
Documentation is available at CSV.php
* Copyright (c) 2006 - 2009 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.6.5, 2009-01-05
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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* Whether to write a BOM (for UTF8).
* 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.");
// Write the UTF-8 BOM code
fwrite($fileHandle, "\xEF\xBB\xBF");
// Convert sheet to array
foreach ($cellsArray as $row) {
* @param string $pValue Delimiter, defaults to ,
* @param string $pValue Enclosure, defaults to "
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
* Get whether BOM should be used
* Set whether BOM should be used
* @param boolean $pValue Use UTF-8 byte-order mark? Defaults to false
* @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?
|