When generating spreadsheet save it to the server

0
Hello, I am generating a table in Excel using the class PHPExcel, so I generated the force for the download, but now I want it to generate it save to the server instead of force the download directly, I did not find in the documentation, the part that force the download would be

header('Content-Disposition: attachment;filename="planilha.xls"');
$objWriter->save('php://output');
    
asked by anonymous 27.09.2017 / 21:38

1 answer

1

Just remove the:

header('Content-Disposition: attachment;filename="planilha.xls"');

And change this:

$objWriter->save('php://output');

For something like this:

$objWriter->save('pasta/foo/baz.pdf');

This will save to a folder on the server, if you want to save and download at the same time, you can use:

header('Content-Disposition: attachment;filename="planilha.xls"');
$objWriter->save('php://output');

copy('php://output', 'pasta/foo/baz.pdf');

Or use (did not test, but doc does not impose any restrictions):

header('Content-Disposition: attachment;filename="planilha.xls"');
$objWriter->save('pasta/foo/baz.pdf');
$objWriter->save('php://output');
    
27.09.2017 / 21:56