Saving multiple workbooks

Topics: Developer Forum, User Forum
Jan 30, 2013 at 10:21 AM

Hello, 

Sorry if it's a question that's asked before. I'm wondering if it's possible to save multiple files at one time. 

I currently have this code:

for ($i = 0; $i < 4; $i++){
	$objPHPExcel = new PHPExcel();
	$objPHPExcel->setActiveSheetIndex(0);
	header("Content-Disposition: attachment;filename='$i.xls'");
	$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
	$objWriter->save('php://output');
}

but it only outputs 0.xls

Coordinator
Jan 30, 2013 at 10:50 AM

HTTP 101 - the answer is no; not when streaming output to a web browser, you can only send one file at a time; If you want to download multiple files in one go; then add them to a zip archive and then send the zip to the browser

Jan 30, 2013 at 10:53 AM

Oh okay, thanks for the reply!