【发布时间】:2014-03-26 19:46:54
【问题描述】:
我正在使用这个蛋糕助手https://github.com/segy/PhpExcel,现在我有很多问题:
方法 PhpExcelHelper::createWorksheet 不存在 [CORE\Cake\View\Helper.php,第 192 行] 方法 PhpExcelHelper::addTableHeader 不存在 [CORE\Cake\View\Helper.php,第 192 行] 方法 PhpExcelHelper::addTableRow 不存在 [CORE\Cake\View\Helper.php,第 192 行] 方法 PhpExcelHelper::addTableRow 不存在 [CORE\Cake\View\Helper.php,第 192 行] 方法 PhpExcelHelper::addTableRow 不存在 [CORE\Cake\View\Helper.php,第 192 行] 方法 PhpExcelHelper::addTableFooter 不存在 [CORE\Cake\View\Helper.php,第 192 行] Helper::output() 缺少参数 1,在第 33 行的 C:\Program Files\PostgreSQL\EnterpriseDB-ApachePHP\apache\www\prueba\app\View\Documentos\index.ctp 中调用并定义了 [CORE\Cake\查看\Helper.php,第 806 行] 未定义变量:str [CORE\Cake\View\Helper.php,第 807 行] 方法 PhpExcelHelper::exit 不存在 [CORE\Cake\View\Helper.php,第 192 行] 模型 Documento.php
<?php
class Documento extends AppModel {
public $useTable = 'documento';
}
?>
控制器文档osController.php
<?php
class DocumentosController extends AppController {
public $helpers = array('Html', 'Form','PhpExcel.PhpExcel');
public function index() {
$this->set('documentos', $this->Documento->find('all'));
}
}
?>
这是我的视图 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();
?>
【问题讨论】:
-
您必须包含完整的错误,包括错误报告的行号和文件名。
-
通常语法错误很容易修复...