douchuo9476 2014-02-24 21:49
浏览 41
已采纳

我正在尝试使用cakephp中的帮助程序生成Excel

I am using this Cake helper https://github.com/segy/PhpExcel, now I have a lot problem as this:

Method PhpExcelHelper::createWorksheet does not exist [CORE\Cake\View\Helper.php, line 192] Method PhpExcelHelper::addTableHeader does not exist [CORE\Cake\View\Helper.php, line 192] Method PhpExcelHelper::addTableRow does not exist [CORE\Cake\View\Helper.php, line 192] Method PhpExcelHelper::addTableRow does not exist [CORE\Cake\View\Helper.php, line 192] Method PhpExcelHelper::addTableRow does not exist [CORE\Cake\View\Helper.php, line 192] Method PhpExcelHelper::addTableFooter does not exist [CORE\Cake\View\Helper.php, line 192] Missing argument 1 for Helper::output(), called in C:\Program Files\PostgreSQL\EnterpriseDB-ApachePHP\apache\www\prueba\app\View\Documentos\index.ctp on line 33 and defined [CORE\Cake\View\Helper.php, line 806] Undefined variable: str [CORE\Cake\View\Helper.php, line 807] Method PhpExcelHelper::exit does not exist [CORE\Cake\View\Helper.php, line 192] Model Documento.php

<?php
class Documento extends AppModel {
    public $useTable = 'documento';
}
?>

Controller DocumentosController.php

<?php
class DocumentosController extends AppController {
    public $helpers = array('Html', 'Form','PhpExcel.PhpExcel');
    public function index() {

        $this->set('documentos', $this->Documento->find('all')); 
   }
}
?>

This is my view index.ctp

<?php  

$this->PhpExcel->createWorksheet();


// define table cells
$table = array(
    array('label' => __('Nombre'), 'filter' => true),
    array('label' => __('Apellido'), 'filter' => true),
    array('label' => __('Edad individuo')),
    array('label' => __('Domicilio'), 'width' => 50, 'wrap' => true),
    array('label' => __('Fecha'))
);

// add heading with different font and bold text
$this->PhpExcel->addTableHeader($table, array('name' => 'Cambria', 'bold' => true));

// add data
foreach ($documentos as $documento) {
    $this->PhpExcel->addTableRow(array(
        $documento['Documento']['nombre'],
        $documento['Documento']['apellido'],
        $documento['Documento']['edad'],
        $documento['Documento']['domicilio'],
        $documento['Documento']['fecha']
    ));
}

// close table and output
$this->PhpExcel->addTableFooter()
    ->output();

?> 
  • 写回答

1条回答 默认 最新

  • dongxun8189 2014-02-24 21:53
    关注

    You are missing a semicolon:

    $this->PhpExcel->createWorksheet();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀