Notice: Undefined property: stdClass::$user_nicename in /home/petra47/public_html/wp-includes/user.php on line 1705

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); 

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