Warning: mysql_real_escape_string(): No such file or directory in /home/sites/heteml/users/n/a/k/nakajijapan/web/nakajijapan.blog/wp-content/plugins/easy-google-syntax-highlighter/easy-google-syntax-highlighter.php on line 50

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/sites/heteml/users/n/a/k/nakajijapan/web/nakajijapan.blog/wp-content/plugins/easy-google-syntax-highlighter/easy-google-syntax-highlighter.php on line 50
Nakajijapan » [zend]ZendFrameworkでCSV出力をおこなう方法
24

2011/07

突貫工事ではありますが、controllerからデータをCSV出力させるようにさせてみた。

        // csv?
        if (isset($params['csvFlg'])) {
            $this->getResponse()
                 ->setHeader('Content-disposition','attachment; filename="data_'.date('YmdHis').'.csv"' )
                 ->setHeader('Content-type', 'test/x-csv')
                 ->sendHeaders();
            foreach($users as $user) {
                $this->getResponse()->appendBody( implode(',', $user) . "\r\n" );
            }
            $this->getResponse()->outputBody();
            exit;
        }

1 comment so far

Add Your Comment
  1. […] >>Nakajijapan » [zend]ZendFrameworkでCSV出力をおこなう方法 Author: […]