I use Fabrice's HTML table formatted as Excel method, but also consider ....
or use http://www.kunalbabre.com/projects/table2CSV.php On Feb 20, 10:58 am, Fabrice B <[email protected]> wrote: > I know three solutions to do Excel exports. > > - Csv > > It is in my opinion not an interesting one, unless your rows are > already formatted into arrays. In that case implode(';',$row) might be > interesting > > - HTML table formatted as Excel > > This is a nice trick I once discovered. You can do a simple HTML table > in your template, and just add the following lines to your action > $this->setLayout(false); > $response = $this->getContext()->getResponse(); > $response->clearHttpHeaders(); > $response->setHttpHeader('Content-Type', 'application/vnd.ms- > excel;charset=utf-8'); > $response->setHttpHeader('Content-Disposition:', 'attachment; > filename=export.xls'); > > Excel will open your html table as if it were an excel file and you > will not see the difference > > - PHPEscel > > If you want better formatting, include pictures, etc. then use the > following very good class :http://www.codeplex.com/PHPExcel > > As for using the filters in your export, you will need to look in your > cache folder at the auto-generated action of your admin generator and > find the functions which create the criteria from the filters and call > them from your own export action. This should work : > > public function executeExportExcel() > { > $this->processSort(); > $this->processFilters(); > $this->filters = $this->getUser()->getAttributeHolder()->getAll > ('sf_admin/bar/filters'); > $c = new Criteria(); > $this->addSortCriteria($c); > $this->addFiltersCriteria($c); > > $this->objects_to_export = ObjectPeer::doSelect$c); > > // if you use solution 2 : > $this->setLayout(false); > $response = $this->getContext()->getResponse(); > $response->clearHttpHeaders(); > $response->setHttpHeader('Content-Type', 'application/vnd.ms- > excel;charset=utf-8'); > $response->setHttpHeader('Content-Disposition:', 'attachment; > filename=export.xls'); > > } > > Fabrice > --http://www.allomatch.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---
