is that I have to save an excel in a temporary file but I do not know how
Originally this way I keep the excel file
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="Autolarte.xlsx"');
header('Cache-Control: max-age=0');
header('Cache-Control: max-age=1');
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header ('Cache-Control: cache, must-revalidate');
header ('Pragma: public');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
Now what I want is to create a temporary file with the contents of that excel file
I have this example but since it is not implemented in my example since I do not know what variable is the content of my excel
$temp = tmpfile();
fwrite($temp, "escribiendo en el archivo temporal");
fseek($temp, 0);
echo fread($temp, 1024);
fclose($temp);
And now it is for what I need my temporary file, I want to put the path and the name of the temporary file in addfile to add that excel to a zip
$zipname = 'file.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
$zip->addFile('/path/to/index.txt', 'newname.txt');
$zip->addFromString("testfilephp.txt", "#1 Esto es una cadena de prueba añadida como testfilephp.txt.\n");
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipname);
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
exit;