View/SpreadsheetView.php
public function render($action = null, $layout = null) {
		$this->viewPath .= DS . 'Spreadsheet';

		$content = parent::render($action, false);
		if ($this->response->type() == 'text/html') {
			return $content;
		}

		ob_start();
		$writer = IOFactory::createWriter($this->Spreadsheet, CAKE_SPREADSHEET_PHPSPREADSHEET_WRITER);
		$writer->setPreCalculateFormulas(false);
		$writer->save('php://output');
		$content = ob_get_clean();

		$this->Blocks->set('content', $content);
		$fileName = $this->getFileName();
		$fileName .= '.' . CAKE_SPREADSHEET_FILE_EXTENSION;
		$this->response->download($fileName);

		return $this->Blocks->get('content');
	}
public function render($action = null, $layout = null) {
		$this->viewPath .= DS . 'Spreadsheet';

		$content = parent::render($action, false);
		if ($this->response->type() == 'text/html') {
			return $content;
		}

		ob_start();
		$writer = IOFactory::createWriter($this->Spreadsheet, CAKE_SPREADSHEET_PHPSPREADSHEET_WRITER);
		$writer->setPreCalculateFormulas(false);
		$writer->save('php://output');
		$content = ob_get_clean();

		$this->Blocks->set('content', $content);
		$fileName = $this->getFileName();
		$fileName .= '.' . CAKE_SPREADSHEET_FILE_EXTENSION;
		$this->response->download($fileName);

		return $this->Blocks->get('content');
	}
public function render ( $ action = null , $ layout = null ) { $ this -> viewPath .= DS . 'Spreadsheet' ; $ content = parent :: render ( $ action , false ) ; if ( $ this -> response -> type ( ) == 'text/html' ) { return $ content ; } ob_start ( ) ; $ writer = IOFactory :: createWriter ( $ this -> Spreadsheet , CAKE_SPREADSHEET_PHPSPREADSHEET_WRITER ) ; $ writer -> setPreCalculateFormulas ( false ) ; $ writer -> save ( 'php://output' ) ; $ content = ob_get_clean ( ) ; $ this -> Blocks -> set ( 'content' , $ content ) ; $ fileName = $ this -> getFileName ( ) ; $ fileName .= '.' . CAKE_SPREADSHEET_FILE_EXTENSION ; $ this -> response -> download ( $ fileName ) ; return $ this -> Blocks -> get ( 'content' ) ; }
Renders view for given view file and layout.

@param string $action Name of view file to use
@param string $layout Layout to use.
@return string|null Rendered content or null if content already rendered and returned earlier.
@triggers View.beforeRender $this, array($viewFileName)
@triggers View.afterRender $this, array($viewFileName)
@throws CakeException If there is an error in the view.
Renders view for given view file and layout .