Tuesday, March 19, 2013

Re: Multiple excel sheet download

Hi Cricket

Did you manage to have records opening in different tabs?

On Thursday, 25 November 2010 18:08:47 UTC+2, the plumpNation wrote:
Hi guys,

I have a sales report in excel which is generated using cakephp and
PHPExcel. I am very happy with both of these frameworks/libraries. I
am really starting to feel very comfortable using them both and am
finally getting to the stage of being able to 'rapidly develop', the
whole point of cake.

Currently, the sales are generated from customers who share
distributors. So the logic goes

foreach(distributor){
   // create excel of sales using this distributor;
   // send email with sales to this distributor;
}

Then I added functionality to allow the sales manager to download the
sheet just to check it, before the cron ran and sent it to the
distributors.

foreach(distributor){
   // create excel of sales using this distributor;
  if(!browserOutput){
   // send email with sales to this distributor;
  }else{
  // output the excel sheet to the browser;
  }
}

Now it all works fine except that I only receive the first sheet,
probably because you can't do a looping download. I was just wondering
if anyone had an elegant solution to this that didn't involve me
writing the sheets to different tabs in the same excel sheet, but
allows the manager to receive all the sheets from the browser one at a
time. Maybe opening the output in different tabs or windows might
work, but not sure how to do this. At the moment I set headers to the
correct mime type like so

if($browserOutput){

                                $message .= 'for output to browser<br />';
                                header( 'Content-Type: application/vnd.ms-excel' );
                                header( 'Content-Disposition: attachment;filename="' . $filename .
'"');
                                header( 'Cache-Control: max-age=0' );

                        }

and then use PHPExcel like so

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

Whatcha fink? Is this possible or should I write all the sheets into
one file to download?

Cheers for reading

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: