Tuesday, November 30, 2010

Re: Multiple excel sheet download

Thanks buddy! Will do.

On Nov 26, 7:45 pm, cricket <zijn.digi...@gmail.com> wrote:
> On Thu, Nov 25, 2010 at 11:08 AM, the plumpNation <plumpnat...@gmail.com> 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 usePHPExcellike so
>
> > $thisSheet->save('php://output');
>
> > Whatcha fink? Is this possible or should I write all the sheets into
> > one file to download?
>
> Yes, write them all to a single file. I think that makes more sense if
> the data is all related. I suppose you could write several sheets as
> separate files, zip them up, and then output that. But that seems a
> bit strange as the sheets are already part of the same file. UsePHPExcel::createSheet().

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: