header('Content-Disposition: attachment;filename="planilha.xls"');
$objWriter->save('php://output');
header('Content-Disposition: attachment;filename="planilha.xls"');
$objWriter->save('php://output');
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');