• <tfoot id='9j9Pw'></tfoot>

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

  • <small id='9j9Pw'></small><noframes id='9j9Pw'>

    <legend id='9j9Pw'><style id='9j9Pw'><dir id='9j9Pw'><q id='9j9Pw'></q></dir></style></legend>

        在 Zend 框架中导出 csv

        时间:2023-05-30

            <tfoot id='TWQoJ'></tfoot>

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

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

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

                  本文介绍了在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文章

                  1. <small id='FXyWX'></small><noframes id='FXyWX'>

                  2. <legend id='FXyWX'><style id='FXyWX'><dir id='FXyWX'><q id='FXyWX'></q></dir></style></legend>
                    • <bdo id='FXyWX'></bdo><ul id='FXyWX'></ul>
                    <tfoot id='FXyWX'></tfoot>

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