Wrap things up and write xlsx.

@param string $fileName
183357
public function writeToFile($fileName = 'report.xlsx')
    {
        $this->output = fopen($fileName, 'w');
        $finalizer = new Finalizer($this->sheet, $this->styler, $this->sheetFile);
        $finalizer->finalize($this->output);
    }
409037
public function writeXml($filename)
    {
        $dom           = new DOMImplementation;
        $dtd           = $dom->createDocumentType('entity', '', $this->entityDtd);
        $xml           = $dom->createDocument('', '', $dtd);
        $xml->encoding = 'UTF-8';

        $root = $this->createRootElement($xml);
        $root->appendChild($this->createStorageElement($xml));
        $root->appendChild($this->createFieldsElement($xml));
        $root->appendChild($this->createRelationsElement($xml));

        $xml->formatOutput = true;
        $xml->save($filename);
    }
203480
public function close()
    {
        $writer = IOFactory::createWriter($this->phpExcelObject, 'Xlsx');
        //\PHPExcel_IOFactory::createWriter($this->phpExcelObject, 'Excel2007');
        $writer->save($this->filename);
    }
904675
public function write(string $fileName) : void
    {
        file_put_contents(
            $fileName,
            // str_replace here is to convert empty arrays into empty JS objects, which is expected by
            // codecov.io. Owner of the service said he was going to patch it, haven't tested since
            // Note: Can't use JSON_FORCE_OBJECT here as we **do** want arrays for the 'b' structure
            // which FORCE_OBJECT turns into objects, breaking at least the Istanbul coverage reporter
            str_replace('[]', '{}', (string) json_encode($this->coverage, JSON_UNESCAPED_SLASHES))
        );
    }
79717
public function handleDownload(string $fileName): void
	{
		$file = $this->getFileInfo($fileName);
		if ($file->isDir) {
			$archive = new TempFile;
			File::zip($this->getFullPath($file->name), (string) $archive);
			$response = new FileResponse($archive, $file->name . '.zip');
		} else {
			$response = new FileResponse($this->getFullPath($file->name));
		}
		$this->presenter->sendResponse($response);
	}
1191795
public static function clean($filename = null)
    {
        static::filename($filename);

        static::$description   =
        static::$keywords      =
        static::$title         =
        static::$jsTextOnReady = '';
        static::$css           =
        static::$js            =
        static::$jsText        =
        static::$jsMgr         = [];
    }
291504
public function setFileName($filename)
    {
        $this->load();
        $this->filename = $filename;
        $this->io = new Real($filename);
    }
343403
public function store($filename, $filext=DEFAULTS::EXTENSION)
    {	
      return FileHandler::save($filename, $this->data);
    }
304930
public function save($fileName = null)
	{
		file_put_contents(empty($fileName) ? $this->fileName : $fileName, '<?php return ' . var_export($this->data, true) . ';', LOCK_EX);
	}
485289
protected function writeCache( $fileName )
	{
		$file		= new FS_File_Writer( $fileName, 0777 );
		$content	= serialize( $this->getConfigValues() );
		$file->writeString( $content );
		touch( $fileName, filemtime( $this->pathConfig.$this->fileName ) );
	}
183316
public function sendToBrowserDownload($filename)
    {
        ReportRenderer::sendToBrowser(
            $filename,
            ReportRenderer::CSV_FORMAT,
            "text/" . ReportRenderer::CSV_FORMAT,
            $this->getRenderedReport()
        );
    }
819860
public function purgeFile($filename)
    {
        if (isset($this->_fileHandlers[$filename])) {
            $this->_fileHandlers[$filename]->close();
        }
        unset($this->_fileHandlers[$filename]);
    }
1915
public function save($fileName = null)
	{
		file_put_contents(empty($fileName) ? $this->fileName : $fileName, json_encode($this->data), LOCK_EX);
	}
1040423
private function warmUpCacheFromFile($filename)
    {
        if (preg_match('#\.php$#', $filename) == false) {
            throw new \InvalidArgumentException('The cache filename must ends with the extension ".php".');
        }

        if (file_exists($filename) == false) {
            $this->hasPendingChasges = true;

            return;
        }

        $fileContent = include_once($filename);

        if (is_array($fileContent) == false) {
            throw new \InvalidArgumentException('Cache file invalid format.');
        }

        foreach ($fileContent as $filename => $hash) {
            $this->write($filename, $hash);
        }

        $this->isInitialized = true;
    }
1193926
public function writeFixedSizeFile($fileName, $fileSize)
    {
        $this->createFile($fileName, '');
        $this->inCurrentDir(function() use ($fileName, $fileSize) {
            $fh = fopen($fileName, 'w');
            fseek($fh, $fileSize - 1);
            fwrite($fh, "\0", 1);
            fclose($fh);
        });
    }
626978
public function write($filename)
    {
        if (count($this) == 0) return;
        $file = fopen($filename, 'w');
        fwrite($file, $this->toJson());
        fclose($file);
        unset($file);
    }
1353253
public function download($fileName){
        header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8');
        header('Content-Disposition: attachment; filename="' . $fileName.'.xlsx"');
        header('Cache-Control: cache, must-revalidate"');
        header('Last-Modified: '.date('Y-m-d'));
        header('Pragma: public"');
        $objWriter = PHPExcel_IOFactory::createWriter($this->engine, 'Excel2007');
        return $objWriter->save("php://output");
    }