我正在使用这个Cake帮助器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';
}
?>
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'));
}
}
?>
这是我的观点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();
?>
答案 0 :(得分:1)
你错过了一个分号:
$this->PhpExcel->createWorksheet();