How to store PHPExcel file on the server

Define path on the server where the defined file would be stored:

$filepath = "files/excels/example.xlsx";

Add headers:

header("Pragma: public"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Content-Type: application/force-download"); 
header("Content-Type: application/octet-stream"); 
header("Content-Type: application/download"); 
header("Content-Disposition: attachment;filename='example.xlsx'"); 
header("Content-Transfer-Encoding: binary ");

Save it before it gets out:

$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); 
$objWriter->save($filepath); 
$objWriter->save('php://output');

Note: folder on the server which is used for to store file should has chmod 777 property.