Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Csv.php
public function save($pFilename)
    {
        // Fetch sheet
        $sheet = $this->spreadsheet->getSheet($this->sheetIndex);

        $saveDebugLog = Calculation::getInstance($this->spreadsheet)->getDebugLog()->getWriteDebugLog();
        Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog(false);
        $saveArrayReturnType = Calculation::getArrayReturnType();
        Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);

        // Open file
        $fileHandle = fopen($pFilename, 'wb+');
        if ($fileHandle === false) {
            throw new Exception("Could not open file $pFilename for writing.");
        }

        if ($this->excelCompatibility) {
            $this->setUseBOM(true); //  Enforce UTF-8 BOM Header
            $this->setIncludeSeparatorLine(true); //  Set separator line
            $this->setEnclosure('"'); //  Set enclosure to "
            $this->setDelimiter(';'); //  Set delimiter to a semi-colon
            $this->setLineEnding("\r\n");
        }
        if ($this->useBOM) {
            // Write the UTF-8 BOM code if required
            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
        $maxCol = $sheet->getHighestDataColumn();
        $maxRow = $sheet->getHighestDataRow();

        // Write rows to file
        for ($row = 1; $row <= $maxRow; ++$row) {
            // Convert the row to an array...
            $cellsArray = $sheet->rangeToArray('A' . $row . ':' . $maxCol . $row, '', $this->preCalculateFormulas);
            // ... and write to the file
            $this->writeLine($fileHandle, $cellsArray[0]);
        }

        // Close file
        fclose($fileHandle);

        Calculation::setArrayReturnType($saveArrayReturnType);
        Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog);
    }
public function save($pFilename)
    {
        // Fetch sheet
        $sheet = $this->spreadsheet->getSheet($this->sheetIndex);

        $saveDebugLog = Calculation::getInstance($this->spreadsheet)->getDebugLog()->getWriteDebugLog();
        Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog(false);
        $saveArrayReturnType = Calculation::getArrayReturnType();
        Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);

        // Open file
        $fileHandle = fopen($pFilename, 'wb+');
        if ($fileHandle === false) {
            throw new Exception("Could not open file $pFilename for writing.");
        }

        if ($this->excelCompatibility) {
            $this->setUseBOM(true); //  Enforce UTF-8 BOM Header
            $this->setIncludeSeparatorLine(true); //  Set separator line
            $this->setEnclosure('"'); //  Set enclosure to "
            $this->setDelimiter(';'); //  Set delimiter to a semi-colon
            $this->setLineEnding("\r\n");
        }
        if ($this->useBOM) {
            // Write the UTF-8 BOM code if required
            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
        $maxCol = $sheet->getHighestDataColumn();
        $maxRow = $sheet->getHighestDataRow();

        // Write rows to file
        for ($row = 1; $row <= $maxRow; ++$row) {
            // Convert the row to an array...
            $cellsArray = $sheet->rangeToArray('A' . $row . ':' . $maxCol . $row, '', $this->preCalculateFormulas);
            // ... and write to the file
            $this->writeLine($fileHandle, $cellsArray[0]);
        }

        // Close file
        fclose($fileHandle);

        Calculation::setArrayReturnType($saveArrayReturnType);
        Calculation::getInstance($this->spreadsheet)->getDebugLog()->setWriteDebugLog($saveDebugLog);
    }
public function save ( $ pFilename ) { // Fetch sheet $ sheet = $ this -> spreadsheet -> getSheet ( $ this -> sheetIndex ) ; $ saveDebugLog = Calculation :: getInstance ( $ this -> spreadsheet ) -> getDebugLog ( ) -> getWriteDebugLog ( ) ; Calculation :: getInstance ( $ this -> spreadsheet ) -> getDebugLog ( ) -> setWriteDebugLog ( false ) ; $ saveArrayReturnType = Calculation :: getArrayReturnType ( ) ; Calculation :: setArrayReturnType ( Calculation :: RETURN_ARRAY_AS_VALUE ) ; // Open file $ fileHandle = fopen ( $ pFilename , 'wb+' ) ; if ( $ fileHandle === false ) { throw new Exception ( "Could not open file $pFilename for writing." ) ; } if ( $ this -> excelCompatibility ) { $ this -> setUseBOM ( true ) ; //  Enforce UTF-8 BOM Header $ this -> setIncludeSeparatorLine ( true ) ; //  Set separator line $ this -> setEnclosure ( '"' ) ; //  Set enclosure to " $ this -> setDelimiter ( ';' ) ; //  Set delimiter to a semi-colon $ this -> setLineEnding ( "\r\n" ) ; } if ( $ this -> useBOM ) { // Write the UTF-8 BOM code if required 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 $ maxCol = $ sheet -> getHighestDataColumn ( ) ; $ maxRow = $ sheet -> getHighestDataRow ( ) ; // Write rows to file for ( $ row = 1 ; $ row <= $ maxRow ; ++ $ row ) { // Convert the row to an array... $ cellsArray = $ sheet -> rangeToArray ( 'A' . $ row . ':' . $ maxCol . $ row , '' , $ this -> preCalculateFormulas ) ; // ... and write to the file $ this -> writeLine ( $ fileHandle , $ cellsArray [ 0 ] ) ; } // Close file fclose ( $ fileHandle ) ; Calculation :: setArrayReturnType ( $ saveArrayReturnType ) ; Calculation :: getInstance ( $ this -> spreadsheet ) -> getDebugLog ( ) -> setWriteDebugLog ( $ saveDebugLog ) ; }
Save PhpSpreadsheet to file.

@param string $pFilename

@throws Exception
Save PhpSpreadsheet to file .