0

配列からcsvにデータを出力してダウンロードしようとしています。

zendフレームワーク上に構築されたソーシャルエンジンを使用しています。

public function indexAction()
    {
        $this->outputCSV();
        //$this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('passport_admin_main', array(), 'passport_admin_main_outofarea');
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        header('Content-Disposition: attachment; filename="OutOfAreaReport.csv"');
        //content type
        header('Content-type: application/excel');
        //read from server and write to buffer
        readfile('spreadsheet/OutOfArea.csv');
    }

    public function outputCSV(){
        $list = array (
                    array('aaa', 'bbb', 'ccc', 'dddd'),
                    array('123', '456', '789'),
                    array('"aaa"', '"bbb"')
                );
        $fp = fopen('OutOfAreaReport.csv', 'w');

        foreach ($list as $fields) {
            fputcsv($fp, $fields);
        }

        fclose($fp);
    }
}

現時点ではCSVをダウンロードしていますが、CSVに値がありません。空です。

4

1 に答える 1

3

2つの異なるパスを使用しています。

    readfile('spreadsheet/OutOfArea.csv');
              ^^^^^^^^^^^^

    $fp = fopen('OutOfAreaReport.csv', 'w');
                 ^----no path
于 2012-08-15T15:45:59.307 に答える