1

Possible Duplicate:
How to download multiple files with one HTTP request?

I have two excel workbooks that I need to create, I have coded them on the same php page and tested each separate by commenting out the other, and they loading the required workbook then edit and then saves them no problem.

The action is created on one button click. But the issue I am now having is how do i create both separate workbooks on the one click. I have tried to call them separate one after each other and also on from the same file but it just either created the first one and not the second or it corrupts the first one.

What would be the best way around this, other than to have to download buttons for the user to select.

my structure in the one on the same php page would be somethign like:

  $objPHPExcel = new PHPExcel();
  $objPHPExcel = PHPExcel_IOFactory::load(??????);
  $objPHPExcel->setActiveSheetIndex(0);
  //add several of 
  $objPHPExcel->setActiveSheetIndex(0)->setCellValue(???);
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  $objWriter->save('php://output');

  //-- the second workbook
  $objPHPExcel2 = new PHPExcel();
  $objPHPExcel2 = PHPExcel_IOFactory::load(??????);
  $objPHPExcel2->setActiveSheetIndex(0);
  //add several of 
  $objPHPExcel2->setActiveSheetIndex(0)->setCellValue(???);
  $objWriter2 = PHPExcel_IOFactory::createWriter($objPHPExcel2, 'Excel2007');
  $objWriter2->save('php://output');

  exit;
Cœur
  • 32,421
  • 21
  • 173
  • 232
Simon Davies
  • 3,574
  • 8
  • 37
  • 67
  • Dont think so, as this relates to PHPExcel and excel documents that question dealt with images directly – Simon Davies Oct 23 '12 at 20:13
  • 1
    @Simon - This is __not__ specifically a PHPExcel question: PHPExcel may be used to generate the files, but you're trying to download two files in a single http response.... irrespective of how files are generated, or what type of files you're trying to download, that's an http issue. I can help with PHPExcel-specific issues, if the files themselves couldn't be generated; but I'd say that sending multiple files in a single http response is impossible irrespective of file type or method of creation – Mark Baker Oct 23 '12 at 21:28
  • The following answer http://stackoverflow.com/questions/1806228/browser-support-of-multipart-responses may give some indication of how well supported the multipart/mixed response option is – Mark Baker Oct 23 '12 at 22:16
  • @Mark Baker many thanks for this will have a look – Simon Davies Oct 24 '12 at 08:52

0 Answers0