<small id='YNH92'></small><noframes id='YNH92'>

  1. <i id='YNH92'><tr id='YNH92'><dt id='YNH92'><q id='YNH92'><span id='YNH92'><b id='YNH92'><form id='YNH92'><ins id='YNH92'></ins><ul id='YNH92'></ul><sub id='YNH92'></sub></form><legend id='YNH92'></legend><bdo id='YNH92'><pre id='YNH92'><center id='YNH92'></center></pre></bdo></b><th id='YNH92'></th></span></q></dt></tr></i><div id='YNH92'><tfoot id='YNH92'></tfoot><dl id='YNH92'><fieldset id='YNH92'></fieldset></dl></div>

    • <bdo id='YNH92'></bdo><ul id='YNH92'></ul>
    <tfoot id='YNH92'></tfoot>
    1. <legend id='YNH92'><style id='YNH92'><dir id='YNH92'><q id='YNH92'></q></dir></style></legend>

      在 Zend 框架中导出 csv

      时间:2023-10-02
    2. <tfoot id='u5IGN'></tfoot>

    3. <i id='u5IGN'><tr id='u5IGN'><dt id='u5IGN'><q id='u5IGN'><span id='u5IGN'><b id='u5IGN'><form id='u5IGN'><ins id='u5IGN'></ins><ul id='u5IGN'></ul><sub id='u5IGN'></sub></form><legend id='u5IGN'></legend><bdo id='u5IGN'><pre id='u5IGN'><center id='u5IGN'></center></pre></bdo></b><th id='u5IGN'></th></span></q></dt></tr></i><div id='u5IGN'><tfoot id='u5IGN'></tfoot><dl id='u5IGN'><fieldset id='u5IGN'></fieldset></dl></div>
            • <bdo id='u5IGN'></bdo><ul id='u5IGN'></ul>

              <small id='u5IGN'></small><noframes id='u5IGN'>

              <legend id='u5IGN'><style id='u5IGN'><dir id='u5IGN'><q id='u5IGN'></q></dir></style></legend>

                  <tbody id='u5IGN'></tbody>
                本文介绍了在 Zend 框架中导出 csv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在尝试将数据库表导出为可从浏览器下载的 .csv.我的代码是基于 zend 框架的,我几乎可以通过以下操作实现:

                I'm trying to export a database table as a .csv downloadable from the browser. My code is zend framework based and I'm almost there with the following action:

                public function exportTableAction()
                {
                    $this->_helper->layout->disableLayout();
                    $this->_helper->viewRenderer->setNoRender();
                
                    $fileName = $this->_getParam('fileName');
                    $tableName = $this->_getParam('tableName');       
                
                    header('Content-type: application/octet-stream');
                    header('Content-Disposition: attachment; filename="'.$fileName.'"');
                
                    echo $this->getCsv($tableName, $fileName);
                }
                

                我可以下载包含有效数据的 .csv 文件.但是,即使我禁用了布局和渲染器,我仍然会在 .csv 文件的末尾获得页面的页眉、侧边栏和页脚的输出.有没有办法禁用除我的 exportTableAction 中生成的输出之外的任何 html 输出?或者我可以用不同的方式将标题信息和 csv 字符串发送到浏览器吗?

                I can download my .csv file containing valid data. However, even if I disabled the layout and the renderer, I still get the output of the header, sidebar, and footer of my page at the end of my .csv file. Is there a way to disable any html output other than the one generated in my exportTableAction? Or can I send the header information and the csv string to the browser in a different way?

                顺便说一句:我正在使用操作堆栈插件来帮助我呈现标题和侧边栏,如下所示:

                BTW: I'm using the action stack plugin to help me render the header and sidebar as follows:

                ...
                $actionStack = $front->getPlugin('Zend_Controller_Plugin_ActionStack');
                $actionStack->pushStack($userlogAction);
                $actionStack->pushStack($rightcolAction);
                

                干杯,阿德里安

                推荐答案

                我们找到了问题的解决方案.我替换了以下行

                We found a solution to the problem. I replaced the following line

                $this->_helper->viewRenderer->setNoRender();
                

                $this->_helper->viewRenderer->setNeverRender();
                

                如果使用 setNeverRender(),则不会渲染任何视图(也不来自插件).

                If setNeverRender() is used, no views are rendered (from plugin neither).

                这篇关于在 Zend 框架中导出 csv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Zend ACL 是否适合我的需求? 下一篇:一次运行多个 exec 命令(但要等待最后一个完成

                相关文章

                最新文章

                    • <bdo id='LnNHG'></bdo><ul id='LnNHG'></ul>

                    <tfoot id='LnNHG'></tfoot>

                    <i id='LnNHG'><tr id='LnNHG'><dt id='LnNHG'><q id='LnNHG'><span id='LnNHG'><b id='LnNHG'><form id='LnNHG'><ins id='LnNHG'></ins><ul id='LnNHG'></ul><sub id='LnNHG'></sub></form><legend id='LnNHG'></legend><bdo id='LnNHG'><pre id='LnNHG'><center id='LnNHG'></center></pre></bdo></b><th id='LnNHG'></th></span></q></dt></tr></i><div id='LnNHG'><tfoot id='LnNHG'></tfoot><dl id='LnNHG'><fieldset id='LnNHG'></fieldset></dl></div>

                    <small id='LnNHG'></small><noframes id='LnNHG'>

                    <legend id='LnNHG'><style id='LnNHG'><dir id='LnNHG'><q id='LnNHG'></q></dir></style></legend>