php - PHPExcel Save a xls file to a specific folder -


i want save xls file specific folder on server using php excel using following code :

  $objwriter = phpexcel_iofactory::createwriter($this->excel, 'excel5'); //force user download excel file without writing server's hd          $objwriter->save('‪c:/xampp/htdocs/timesheet/files/test.xls'); 

but keep on getting following error :

a php error encountered  severity: warning  message: fopen(‪c:/xampp/htdocs/timesheet/files/test.xls): failed open stream: invalid argument  filename: pps/root.php  line number: 90       fatal error: uncaught exception 'phpexcel_writer_exception' message 'can't open ‪c:/xampp/htdocs/timesheet/files/test.xls. may in use or protected.' in c:\xampp\htdocs\timesheet\application\third_party\phpexcel\shared\ole\pps\root.php:93 stack trace: #0 c:\xampp\htdocs\timesheet\application\third_party\phpexcel\writer\excel5.php(226): phpexcel_shared_ole_pps_root->save('???c:/xampp/htd...') #1 c:\xampp\htdocs\timesheet\application\controllers\time_sheet.php(6131): phpexcel_writer_excel5->save('???c:/xampp/htd...') #2 [internal function]: time_sheet->save_time_sheet() #3 c:\xampp\htdocs\timesheet\system\core\codeigniter.php(359): call_user_func_array(array, array) #4 c:\xampp\htdocs\timesheet\index.php(202): require_once('c:\xampp\htdocs...') #5 {main} thrown in c:\xampp\htdocs\timesheet\application\third_party\phpexcel\shared\ole\pps\root.php on line 93 

please advise on best way save file on server.

try changing $objwriter->save() code following:

$objwriter->save(str_replace(__file__,'folder_path/filename.xlsx',__file__)); 

you may change filename , file type depending on need.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -