2014-02-24 26 views
0

我使用這個蛋糕幫手https://github.com/segy/PhpExcel,現在我有很多問題,因爲這樣的:我想生成一個excel在CakePHP的一個輔助

方法PhpExcelHelper :: createWorksheet不存在[CORE \蛋糕\ View \ Helper.php,192行] 方法PhpExcelHelper :: addTableHeader不存在[CORE \ Cake \ View \ Helper.php,第192行] 方法PhpExcelHelper :: addTableRow不存在[CORE \ Cake \ View \ Helper .php,line 192] 方法PhpExcelHelper :: addTableRow不存在[CORE \ Cake \ View \ Helper.php,第192行] 方法PhpExcelHelper :: addTableRow不存在[CORE \ Cake \ View \ Helper.php,line 192] 方法PhpExcelHelper :: addTableFooter不存在[CORE \ Cake \ View \ Helper.php,第192行] 缺少Helper :: output()的參數1,在C:\ Program Files \ PostgreSQL \ EnterpriseDB-ApachePHP \ apache中調用\ CORE \ Cake \ View \ Helper.php,第806行] \ www \ prueba \ app \ View \ Documentos \ index.ctp並且定義了一個未定義的變量:str [CORE \ Cake \ View \ Helper.php,line 807] 方法PhpExcelHelper ::出口不存在[CORE \蛋糕\視圖\ Helper.php,線192] 模型Documento.php

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

控制器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

必須包含完整的錯誤,包括行號和文件名的錯誤報告。 –

+0

通常語法錯誤很容易修復... – skywalker

回答

1

你缺少一個分號:

$this->PhpExcel->createWorksheet(); 
+0

謝謝,但現在: – user3245260

+0

調用非對象的成員函數output() – user3245260

+0

嘗試將該代碼從視圖移至控制器。 'PhpExcel'是一個應該包含在控制器中的組件'public $ components = array('PhpExcel')' – cornelb

相關問題